So, I'm using void* for now, but it would be nice to go back to using char*, char* works when I do regular (not extended) import of function foo, and the char* integration with native newlisp strings is really nice, not having to do the extra get-string step, especially because I'm dealing with a library that brings in binary data, and the strings are not \0 terminated ones.

Last edited by TedWalther on Thu May 07, 2015 10:39 pm, edited 1 time in total.

Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.

After a bit more testing, I can reduce it to this: if an extended libffi imported function has a return type of char*, and it returns NULL when it is called, newlisp segfaults.

Perhaps the least surprising response to this is to return a "nil", since "char*" does map to a newlisp string type.

I verified that (get-string NULL) also segfaults, but perhaps this is the correct behavior. It is conceivable that memory permissions could be set such that you could legitimately try to grab the byte at memory location 0.

Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.

Lutz... anytime you deal with pointers, no matter what type, NULL can come up, and not necessarily be an error. It is the standard "end of list" marker. Even with documentation and an error code instead of a segfault, this is still very surprising behavior.

Can we do a conference offline by phone so you can fill me in more on the things that would be affected by making (import char*) return nil instead of an error, for NULL? I propose the phone conference because I communicate and process information much more rapidly by voice, and language barrier will not be an issue for us. I promise.

I'd like to get a better feel for how I can assist; I've been requesting a lot lately, and I'd like to become more of a bug-fixer and contributor, rather than bug-reporter and requestor.

Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.

If you expect 0 then either use void* and check for 0/NULL before calling get-string or if using char* use catch. I don't want to start a nil/NULL confusion. Also, when using libffi, nil is already used as return value for void return.