On Sat, Dec 25, 2010 at 9:23 PM, Hernán Morales Durand < hernan.morales@gmail.com> wrote:
Thanks for the answers guys. It is very dissapointing to try a fix when the VM suddenly dissapears over and over again. I have no time for building a plugin, so our best options are to wait a fix from someone with VM/FFI knowledge or slowly specify the struct alignments of the Z39.50 structures (and not sure if it's the real cause because... the VMs segfaults).
Program in the debugger. Seriously, run the VM from within gdb. You have the changes file for crash recovery. You use gdb for identifying the cause of the crash. You'll make progress, albeit slowly. Also, try writing a C program that prints out the struct offsets, e.g.
#define printoffset(struct,field) printf("&" #struct "." #field "=%d\n", (char *)&(struct.field) - (char *)&field)
Better still get the FFI to generate such a file for you automagically that prints out the relevant Smalltalk source.
HTH Eliot
Cheers,
Hernán
2010/12/24 David T. Lewis lewis@mail.msen.com:
On Fri, Dec 24, 2010 at 12:44:50PM -0300, Hern??n Morales Durand wrote:
Hi David,
2010/12/24 David T. Lewis lewis@mail.msen.com:
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.
The strange thing is that in the Windows VM goes fine.
There are differences in the Windows an unix implementations, so sometimes a declaration that works on Windows may need to be done differently on unix. I don't have any examples, but I know I have seen this in the past.
Is there a special VM debug flag or parameter specifically for this cases? Maybe I could check with that.
I do not know of anything that would help here. In the past I have done debugging by setting gdb breakpoints right before running the workspace script. It's a real pain but it can be done.
I know that this does not answer your question, but if you can consider building a plugin rather than using FFI, I think you may find it to be easier to debug and more reliable overall.
Dave
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
Yes, I'm sure because Ubuntu 8.10 doesn't allow to install libraries compiled for another architecture.
Cheers,
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:
-- Hern??n Morales Information Technology Manager, Institute of Veterinary Genetics. National Scientific and Technical Research Council (CONICET). La Plata (1900), Buenos Aires, Argentina. Telephone: +54 (0221) 421-1799. Internal: 422 Fax: 425-7980 or 421-1799.