Hern??n,
A segmentation fault that occurs when calling the function in an external library would most likely indicate that the arguments being passed to the library function are not correct for some reason. Probably it is something related to the ExternalStructure as you mention.
You must use a normal 32-bit VM and 32-bit libraries. I think that you are doing this, but I mention it because using 64-bit VM or libraries will definitely crash FFI. http://bugs.squeak.org/view.php?id=7237
Dave
On Fri, Dec 24, 2010 at 08:33:33AM +0100, laurent laffont wrote:
Which VM have you used ?
I cross post to vm-dev list.
Laurent.
On Fri, Dec 24, 2010 at 3:54 AM, Hern??n Morales Durand < hernan.morales@gmail.com> wrote:
Laurent, not much progress here :( I just reproduced the Unix VM crash. First I've linked the library so we do not have to change every module name call
user@ubuntu:/usr/lib$ ln -T -s /usr/lib/libyaz.so.3.0.0 yaz
and I've tried to execute the library tracer in the shell script
ltrace -f -l /usr/lib/libyaz.so.3.0.0 -o out.txt "$BASE/squeakvm" \ -plugins "$BASE" \ -encoding latin1 \ -vm-display-X11 \ "$ROOT/Contents/Resources/pharo.image"
but it crash the VM too with an unhandled exception even before the GUI is displayed. What I've observed is that every FFI call which receives an ExternalStructure as parameter kills the VM. This is weird because this doesn't happen in the Windows VM. I ran this little script I use to debug the library
| conn lib rs rsSize records | lib := Z3950FFILibrary default. conn := lib createConnectionTo: #Alabama asZ3950Server hostName port: 7090. lib createOptions. lib setConnection: conn optionName: 'preferredRecordSyntax' optionValue: 'USMARC'. rs := lib searchPqf: conn query: '@attr 1=1003 collins'. rsSize := lib resultSetSize: rs. rsSize > 0 ifFalse: [ 'no results' ]. records := Array new: rsSize. 0 to: rsSize - 1 do: [: pos | record := lib resultSetRecord: rs position: pos. record isNil not ifTrue: [ records at: pos + 1 put: ( lib getRecord: record function: 'render; charset=marc8, iso8859-1' length: nil ). ] ]. records
and the the doIt just hangs the VM, the console output going through the Debugger is the following:
Segmentation fault
-1370902312 ContextPart>doPrimitive:method:receiver:args: -1370902404 ContextPart>tryPrimitiveFor:receiver:args: -1370902788 ContextPart>send:to:with:super: -1370902896 ContextPart>send:super:numArgs: -1370902988 InstructionStream>interpretExtension:in:for: -1370903080 InstructionStream>interpretNextInstructionFor: