[m-users.] Segmentation violation on FFI wrapper for linenoise-ng

Sean Charles (emacstheviking) objitsu at gmail.com
Sat Jun 19 23:24:24 AEST 2021



I took that print line out, removed ’the fix’/…….I don’t think I need tell you how it went.

Sometimes it never fails to baffle me, after 35 years, that sometimes you can fail to read and understand your own code.


Sigh… you live and learn. I hope.

Thanks Julien, I am going outside to self-flagellate with some nettles I mowed down this morning…..

> On 19 Jun 2021, at 14:21, Julien Fischer <jfischer at opturion.com> wrote:
> On Sat, 19 Jun 2021, Sean Charles (emacstheviking) wrote:
>> Hi Julien,
>> Yes, the C++ code uses fgets() which returns NULL on end of file, one is supposed to then use feof() I guess but I didnt write that code.
>> As I am checking the value of LineNull first and foremost on return, I
>> didn’t (still don’t!) see the harm in what I have done i.e. I only use
>> the value in Line to call execute() with if LineNull is 0 i.e. there
>> is something, even an empty line, in it. If you press RETURN, it
>> allocates a zero length buffer but that is still a non-null address
>> which should be fine, and seems to be the case.
> Your Mercury code executes the following line
>    io.format("LNG: NULL:%d, len:%d, \n", [i(LineNull), i(length(Line))], !IO),
> regardless of what the value of LineNull is.  I suspect the call to
> length/1 is causing the segmentation fault, since in the case where
> LineNull is 1, Line is not set by the foreign code.
> Julien.

More information about the users mailing list