errorProcExt2 failure

Q&A's, tips, howto's
Post Reply
sunmountain
Posts: 39
Joined: Tue Mar 15, 2011 5:11 am

errorProcExt2 failure

Post by sunmountain »

Hi,
in my FFI code, I need to sure that ffi_prep_cif went ok, so I added this:

Code: Select all

status = ffi_prep_cif(&cif,FFI_DEFAULT_ABI,2,&ffi_type_uint,argt);
if(status != FFI_OK)
    {
    return(errorProcExt2(ERR_FFI_PREP_FAILED, stuffString(ffi->name)));
    }
else
    {
    ffi_call(&cif,ffi->func,&result,aval);
    }
For debugging purposes I changed status != FFI_OK to status == FFI_OK, to provoke an error.
If I now try this newLisp snippet:

Code: Select all

(import "msvcrt" "printf" "cdecl")
(fcall printf a b c)
(exit 0)
the program crashes and calls the debugger.

Last message is (after adding additional messages and error numbers):

ERR: ffi preparation failed in function fcall : "printf"

As said, the newLisp.exe crashes.

It doesn't matter, at which point I call errorProcExt2, even right after entering the function.

Lutz
Posts: 5282
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: errorProcExt2 failure

Post by Lutz »

in newlisp.c lines 2444 to 2448 should look like this:

Code: Select all

#ifdef FFI
        varPrintf(device,"%s<%lX>", (char *)((FFIMPORT *)cell->aux)->name, 
                                                 cell->contents);
#else
        varPrintf(device,"%s<%lX>", (char *)cell->aux, cell->contents);
#endif
the two lines were swapped and the structure name had a typo.

also updated here: http://www.newlisp.org/downloads/develo ... nprogress/

ps: you are based on official development 10.3.6, right? There where still changes in nl-import.c after my initial FFI preparations.

ps: FFI now by default disabled (2011-11-20)

sunmountain
Posts: 39
Joined: Tue Mar 15, 2011 5:11 am

Re: errorProcExt2 failure

Post by sunmountain »

It did not solve all problems (it still crashes at the same point),
but first I will create functioning ffi interface (at least fcall), before digging into this.
Yes, I took 10.3.7 and integrated my code.
I think I'll have to ask gdb what is wrong here.

Man, I learn alot these days.
But as more as I do so, the more I appreciate the way newLisp works :-)

Lutz
Posts: 5282
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: errorProcExt2 failure

Post by Lutz »

The crash was happening when printing the name of the imported function. Just make sure lines 2444 to 2448 in newlisp.c are as outlined in my previous post and based on 10.3.6. The 10.3.7 file can change several times during the day and often is an untested snapshot.

If you want, you can send me intermediate work, which I can merge and post a version in a private directory for you on newlisp.org. This is, how I have worked with others in the past.

Post Reply