Which VM have you used ?<div><br></div><div>I cross post to vm-dev list.</div><div><br></div><div>Laurent.</div><div><br><div class="gmail_quote">On Fri, Dec 24, 2010 at 3:54 AM, Hernán Morales Durand <span dir="ltr"><<a href="mailto:hernan.morales@gmail.com" target="_blank">hernan.morales@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Laurent, not much progress here :(<br>
I just reproduced the Unix VM crash. First I've linked the library so<br>
we do not have to change every module name call<br>
<br>
user@ubuntu:/usr/lib$ ln -T -s /usr/lib/libyaz.so.3.0.0 yaz<br>
<br>
and I've tried to execute the library tracer in the shell script<br>
<br>
ltrace -f -l /usr/lib/libyaz.so.3.0.0 -o out.txt "$BASE/squeakvm" \<br>
-plugins "$BASE" \<br>
-encoding latin1 \<br>
-vm-display-X11 \<br>
"$ROOT/Contents/Resources/pharo.image"<br>
<br>
but it crash the VM too with an unhandled exception even before the<br>
GUI is displayed.<br>
What I've observed is that every FFI call which receives an<br>
ExternalStructure as parameter kills the VM. This is weird because<br>
this doesn't happen in the Windows VM. I ran this little script I use<br>
to debug the library<br>
<br>
| conn lib rs rsSize records |<br>
lib := Z3950FFILibrary default.<br>
conn := lib<br>
createConnectionTo: #Alabama asZ3950Server hostName<br>
port: 7090.<br>
lib createOptions.<br>
lib<br>
setConnection: conn<br>
optionName: 'preferredRecordSyntax'<br>
optionValue: 'USMARC'.<br>
rs := lib<br>
searchPqf: conn<br>
query: '@attr 1=1003 collins'.<br>
rsSize := lib resultSetSize: rs.<br>
rsSize > 0<br>
ifFalse: [ 'no results' ].<br>
records := Array new: rsSize.<br>
0 to: rsSize - 1 do: [: pos |<br>
record := lib resultSetRecord: rs position: pos.<br>
record isNil not<br>
ifTrue: [<br>
records<br>
at: pos + 1<br>
put: ( lib<br>
getRecord: record<br>
function: 'render; charset=marc8, iso8859-1'<br>
length: nil ). ] ].<br>
records<br>
<br>
and the the doIt just hangs the VM, the console output going through<br>
the Debugger is the following:<br>
<br>
Segmentation fault<br>
<br>
-1370902312 ContextPart>doPrimitive:method:receiver:args:<br>
-1370902404 ContextPart>tryPrimitiveFor:receiver:args:<br>
-1370902788 ContextPart>send:to:with:super:<br>
-1370902896 ContextPart>send:super:numArgs:<br>
-1370902988 InstructionStream>interpretExtension:in:for:<br>
-1370903080 InstructionStream>interpretNextInstructionFor:<br>
-1370903172 ContextPart>step<br>
-1370903280 Process>step<br>
-1370903372 Process>step:<br>
-1370920392 Debugger>send<br>
-1370937720 PluggableButtonMorph>performAction<br>
-1370937812 PluggableButtonMorph>mouseUp:<br>
-1370937996 SequenceableCollection>do:<br>
-1370957140 PluggableButtonMorph>mouseUp:<br>
-1370957232 Morph>handleMouseUp:<br>
-1370957324 MouseButtonEvent>sentTo:<br>
-1370957416 Morph>handleEvent:<br>
-1370957584 Morph>handleFocusEvent:<br>
-1370957676 HandMorph>sendFocusEvent:to:clear:<br>
-1370957768 PasteUpMorph>becomeActiveDuring:<br>
-1370957860 BlockClosure>on:do:<br>
-1370957992 PasteUpMorph>becomeActiveDuring:<br>
-1370958084 HandMorph>sendFocusEvent:to:clear:<br>
-1370958260 HandMorph>sendEvent:focus:clear:<br>
-1370958352 HandMorph>sendMouseEvent:<br>
-1370958444 HandMorph>handleEvent:<br>
-1370966728 HandMorph>processEvents<br>
-1370966836 WorldState>doOneCycleNowFor:<br>
-1370966952 SequenceableCollection>do:<br>
-1370967044 WorldState>handsDo:<br>
-1370967136 WorldState>doOneCycleNowFor:<br>
-1370969680 WorldState>doOneCycleFor:<br>
-1370969772 PasteUpMorph>doOneCycle<br>
-1383611064 >spawnNewProcess<br>
-1383611192 BlockClosure>newProcess<br>
Aborted<br>
<br>
it would be nice if someone could tell something about debugging FFI<br>
calls, or just any idea to try.<br>
Cheers,<br>
<br>
Hernán<br>
<br>
2010/12/23 laurent laffont <<a href="mailto:laurent.laffont@gmail.com" target="_blank">laurent.laffont@gmail.com</a>>:<br>
<div><div></div><div>> Hi,<br>
> I have unmangled all function names. Image also crashes when evaluating the<br>
> Kant test. (but this time I get ILLEGAL INSTRUCTION on strace). I've tried<br>
> with Cog and the VM in the Seaside OneClick.<br>
> I've uploaded the modified packages on squeaksource<br>
> here: <a href="http://www.squeaksource.com/LaurentLSandbox.html" target="_blank">http://www.squeaksource.com/LaurentLSandbox.html</a> (you can use<br>
> Z3950Slice to load all at once).<br>
> Laurent<br>
><br>
><br>
><br>
> On Thu, Dec 23, 2010 at 1:57 AM, Hernán Morales Durand<br>
> <<a href="mailto:hernan.morales@gmail.com" target="_blank">hernan.morales@gmail.com</a>> wrote:<br>
>><br>
>> Hi Laurent,<br>
>><br>
>> Thanks for the feedback, I've uploaded the repository with the missing<br>
>> method but I cannot reproduce the crash in Windows. Have you unmangled<br>
>> every function name tested? Are you running just the<br>
>> Z3950FFILibraryTest? Notice the Z3950FFIServerLibraryTest tests are<br>
>> performed against a Z39.50 server running in local host, otherwise<br>
>> will fail (however that shouldn't crash the VM), so you may want to<br>
>> run only the Z3950FFILibraryTest suite. If you or anyone want a local<br>
>> Zebra server for Win32 - although most configuration files should work<br>
>> with other platforms - for testing purposes please let me know.<br>
>><br>
>> Does the Kant test crash the VM too?<br>
>><br>
>> Z3950Client new<br>
>> server: #Acadia;<br>
>> query: ( Z3950Query new author: 'Kant' ).<br>
>><br>
>> (see <a href="http://67.222.12.200:8889/WebOpus/52" target="_blank">http://67.222.12.200:8889/WebOpus/52</a> for sample successful results)<br>
>><br>
>> I will set up a Linux box tomorrow and try to reproduce there.<br>
>> Cheers,<br>
>><br>
>> 2010/12/22 laurent laffont <<a href="mailto:laurent.laffont@gmail.com" target="_blank">laurent.laffont@gmail.com</a>>:<br>
>> > Hi Hernan,<br>
>> > finally I switch back to Linux to make it work, OSX gives me headaches.<br>
>> > So on linux the yaz module is found. I get the "Unable to find function<br>
>> > address" but I found that writing:<br>
>> > <cdecl: ZOOMOptions 'ZOOM_options_create' (void) module: 'yaz'><br>
>> > instead of<br>
>> > <cdecl: ZOOMOptions '_ZOOM_options_create@0' (void) module: 'yaz3'><br>
>> > works. If I understand, function names are not mangled when compiling<br>
>> > with<br>
>> > gcc on Linux.<br>
>> ><br>
>> > Trying to run tests I've also had a "could not coerce arguments" in<br>
>> > Z3950FFILibrary>>createConnectionTo:port because<br>
>> > Z3950TestCase>>portNumber<br>
>> > answers a String and<br>
>> > <cdecl: ZOOMConnection 'ZOOM_connection_new' (char* short) module:<br>
>> > 'yaz'><br>
>> > so it's waiting for a short. I've replaced portNumber to answer a<br>
>> > SmallInteger.<br>
>> > And now the image crashes on connectionIsIdle call:<br>
>> > write(1, "\ncreateConnectionTo:port:", 25) = 25<br>
>> > write(1, "\nconnectionIsIdle:", 18) = 18<br>
>> > rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0<br>
>> > write(1, "\n", 1) = 1<br>
>> > tgkill(25830, 25830, SIGABRT) = 0<br>
>> > --- SIGABRT (Aborted) @ 0 (0) ---<br>
>> ><br>
>> > Any idea ?<br>
>> ><br>
>> > Laurent Laffont<br>
>> ><br>
>> > On Tue, Dec 21, 2010 at 7:58 AM, laurent laffont<br>
>> > <<a href="mailto:laurent.laffont@gmail.com" target="_blank">laurent.laffont@gmail.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> The module is found ! How:<br>
>> >> - Using VM Squeak 5.8b12 2 (instead of Cog or the VM provided in<br>
>> >> Seaside<br>
>> >> One-Click image)<br>
>> >> - go in Squeak\ 5.8b12\ 2.app/Contents/Resources/, then ln -s<br>
>> >> /usr/local/lib/libyaz.3.dylib .<br>
>> >> Now I have the "Unable to find function address" you have talked<br>
>> >> earlier<br>
>> >> :) I will look at the mangled function names.<br>
>> >><br>
>> >> Laurent --- on the road to the FFI mountain.<br>
>> >><br>
>> >> On Tue, Dec 21, 2010 at 6:59 AM, Hernán Morales Durand<br>
>> >> <<a href="mailto:hernan.morales@gmail.com" target="_blank">hernan.morales@gmail.com</a>> wrote:<br>
>> >>><br>
>> >>> Laurent,<br>
>> >>> I forward this e-mail to the squeak mailing list, may be someone there<br>
>> >>> have a better idea how the OSX VM works. BTW there are more<br>
>> >>> commentaries here<br>
>> >>><br>
>> >>><br>
>> >>> <a href="http://forum.world.st/squeak-dev-Alien-amp-Squeak-FFI-issues-on-Snow-Leopard-td85608.html" target="_blank">http://forum.world.st/squeak-dev-Alien-amp-Squeak-FFI-issues-on-Snow-Leopard-td85608.html</a><br>
>> >>> Cheers,<br>
>> >>><br>
>> >>> Hernán<br>
>> >>><br>
>> >>> 2010/12/20 laurent laffont <<a href="mailto:laurent.laffont@gmail.com" target="_blank">laurent.laffont@gmail.com</a>>:<br>
>> >>> > Hi Hernan,<br>
>> >>> > the strace equivalent on OSX seems to be dtruss (yes I'm learning<br>
>> >>> > OSX<br>
>> >>> > too :)<br>
>> >>> > sudo dtruss -p [pid of process]<br>
>> >>> > in the trace I have this:<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > stat("/Users/laurentlaffont/Downloads/Seaside.app/Contents/Resources/yaz3.bundle/Contents/MacOS/yaz3\0",<br>
>> >>> > 0xBFF59440, 0xBFF5AB28) = -1 Err#2<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > stat64("/Users/laurentlaffont/Downloads/Seaside.app/Contents/Resources/yaz3.bundle/Contents/MacOS/yaz3\0",<br>
>> >>> > 0xBFF5892C, 0xBFF5AB28) = -1 Err#2<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > stat("/Users/laurentlaffont/Downloads/Seaside.app/Contents/Resources/yaz3\0",<br>
>> >>> > 0xBFF59440, 0xBFF5AB28) = 0 0<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > stat64("/Users/laurentlaffont/Downloads/Seaside.app/Contents/Resources/yaz3\0",<br>
>> >>> > 0xBFF5892C, 0xBFF5AB28) = 0 0<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > open("/Users/laurentlaffont/Downloads/Seaside.app/Contents/Resources/yaz3\0",<br>
>> >>> > 0x0, 0x0) = 12 0<br>
>> >>> > pread(0xC, "\317\372\355\376\a\0", 0x1000, 0x0) = 4096 0<br>
>> >>> > close(0xC) = 0 0<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > stat("/Users/laurentlaffont/Downloads/Plugins/yaz3.bundle/Contents/MacOS/yaz3\0",<br>
>> >>> > 0xBFF59440, 0x1000) = -1 Err#2<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > stat64("/Users/laurentlaffont/Downloads/Plugins/yaz3.bundle/Contents/MacOS/yaz3\0",<br>
>> >>> > 0xBFF5892C, 0x1000) = -1 Err#2<br>
>> >>> > stat("/Users/laurentlaffont/Downloads/Plugins/yaz3\0", 0xBFF59440,<br>
>> >>> > 0x1000) =<br>
>> >>> > -1 Err#2<br>
>> >>> > stat64("/Users/laurentlaffont/Downloads/Plugins/yaz3\0", 0xBFF5892C,<br>
>> >>> > 0x1000)<br>
>> >>> > = -1 Err#2<br>
>> >>> ><br>
>> >>> > so it looks like the VM is trying to find yaz3 at non standard Unix<br>
>> >>> > places<br>
>> >>> > (I don't know if it's SqueakVM or OSX related).<br>
>> >>> > I've created Contents/Resources/yaz3.bundle/Contents/MacOS/, put yaz<br>
>> >>> > lib<br>
>> >>> > there, ln -s libyaz.3.dylib yaz3 but no success.<br>
>> >>> ><br>
>> >>> > I've read good<br>
>> >>> > post <a href="http://forum.world.st/FFI-Documentation-td2225150.html" target="_blank">http://forum.world.st/FFI-Documentation-td2225150.html</a> :<br>
>> >>> ><br>
>> >>> > Module Location - where the external library file lives<br>
>> >>> > - depends on the platform<br>
>> >>> > - Mac<br>
>> >>> > - pre Snow Leopard<br>
>> >>> > - checks VM path and common library<br>
>> >>> > paths<br>
>> >>> > - Snow Leopard<br>
>> >>> > - only looks in VM bundle's Resources<br>
>> >>> > file, you must either [5]:<br>
>> >>> > - store all external libraries<br>
>> >>> > there<br>
>> >>> > - ln -s path/to/library<br>
>> >>> > path/to/VM/Resources/library_name<br>
>> >>> > - Change the VM's Info.plist<br>
>> >>> > "SqueakPluginsBuiltInOrLocalOnly" key from<br>
>> >>> > "true" to "false."<br>
>> >>> ><br>
>> >>> > For this SqueakPluginsBuiltInOrLocalOnly I suppose I need to compile<br>
>> >>> > a<br>
>> >>> > VM ?<br>
>> >>> > Cheers,<br>
>> >>> > Laurent Laffont<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > On Mon, Dec 20, 2010 at 4:12 PM, Hernán Morales Durand<br>
>> >>> > <<a href="mailto:hernan.morales@gmail.com" target="_blank">hernan.morales@gmail.com</a>> wrote:<br>
>> >>> >><br>
>> >>> >> Hi Laurent<br>
>> >>> >><br>
>> >>> >> I've read there is a couple of system calll monitors in MacOS,<br>
>> >>> >> ktrace<br>
>> >>> >> and dtrace (<a href="http://en.wikipedia.org/wiki/Ktrace" target="_blank">http://en.wikipedia.org/wiki/Ktrace</a> ,<br>
>> >>> >> <a href="http://en.wikipedia.org/wiki/DTrace" target="_blank">http://en.wikipedia.org/wiki/DTrace</a>) so you may attach to the VM<br>
>> >>> >> and<br>
>> >>> >> see what's missing?<br>
>> >>> >> Cheers,<br>
>> >>> >><br>
>> >>> >> Hernán<br>
>> >>> >><br>
>> >>> >> 2010/12/20 laurent laffont <<a href="mailto:laurent.laffont@gmail.com" target="_blank">laurent.laffont@gmail.com</a>>:<br>
>> >>> >> > Thanks Hernan.<br>
>> >>> >> > It still doesn't work. I've also tried to play with LD_LOAD_PATH<br>
>> >>> >> > /<br>
>> >>> >> > LD_LIBRARY_PATH no success.... I want to make it work so I need<br>
>> >>> >> > to<br>
>> >>> >> > learn<br>
>> >>> >> > :)<br>
>> >>> >> ><br>
>> >>> >> > For the mangled function names, on Linux and OSX there's nm.<br>
>> >>> >> > Here's what I get:<br>
>> >>> >> > $ nm -g libyaz.3.dylib | grep ZOOM_connection_create<br>
>> >>> >> > 0000000000046a30 T _ZOOM_connection_create<br>
>> >>> >> > Cheers,<br>
>> >>> >> > Laurent<br>
>> >>> >> ><br>
>> >>> >> > On Sun, Dec 19, 2010 at 6:23 PM, Hernán Morales Durand<br>
>> >>> >> > <<a href="mailto:hernan.morales@gmail.com" target="_blank">hernan.morales@gmail.com</a>> wrote:<br>
>> >>> >> >><br>
>> >>> >> >> Hi Laurent,<br>
>> >>> >> >><br>
>> >>> >> >> Thanks for reporting. The correct #moduleName for MacOS was<br>
>> >>> >> >> missing,<br>
>> >>> >> >> I've uploaded a new version answering 'libyaz.3.dylib' which I<br>
>> >>> >> >> guess<br>
>> >>> >> >> is the corresponding for 'yaz3.dll' (according to<br>
>> >>> >> >> <a href="http://en.wikipedia.org/wiki/Dynamic_library#Naming" target="_blank">http://en.wikipedia.org/wiki/Dynamic_library#Naming</a> ).<br>
>> >>> >> >><br>
>> >>> >> >> I haven't access to a MacOS, but in Windows I've had to find the<br>
>> >>> >> >> mangled function names (i.e. _ZOOM_connection_create@4) so FFI<br>
>> >>> >> >> can<br>
>> >>> >> >> find the function addresses and you don't get the classic<br>
>> >>> >> >> "Error:<br>
>> >>> >> >> Unable to find function address". I don't know if it's related<br>
>> >>> >> >> since<br>
>> >>> >> >> talks about C++, but you may want to check<br>
>> >>> >> >> <a href="http://wiki.squeak.org/squeak/3735" target="_blank">http://wiki.squeak.org/squeak/3735</a><br>
>> >>> >> >><br>
>> >>> >> >> The tool I've used to find the mangled function names in Windows<br>
>> >>> >> >> is<br>
>> >>> >> >> the Steve Miller's Dependency Walker<br>
>> >>> >> >> <a href="http://www.dependencywalker.com/" target="_blank">http://www.dependencywalker.com/</a><br>
>> >>> >> >><br>
>> >>> >> >> 2010/12/19 laurent laffont <<a href="mailto:laurent.laffont@gmail.com" target="_blank">laurent.laffont@gmail.com</a>>:<br>
>> >>> >> >> > Hi,<br>
>> >>> >> >> ><br>
>> >>> >> >> > I want to use <a href="http://www.squeaksource.com/Z3950" target="_blank">http://www.squeaksource.com/Z3950</a><br>
>> >>> >> >> > Following install instructions, I've dowloaded yaz sources<br>
>> >>> >> >> > (I've<br>
>> >>> >> >> > tried<br>
>> >>> >> >> > 4.1.2<br>
>> >>> >> >> > and 3.0.52) as it seems there's no binary for OSX, ./configure<br>
>> >>> >> >> > && make<br>
>> >>> >> >> > &&<br>
>> >>> >> >> > make install.<br>
>> >>> >> >> > Then using latest Seaside One Click image I've copied<br>
>> >>> >> >> > /usr/local/lib/*yaz*<br>
>> >>> >> >> > in Seaside.app/Contents/MacOS<br>
>> >>> >> >> > $ ls ~/Downloads/Seaside.app/Contents/MacOS/<br>
>> >>> >> >> > Squeak VM Opt libyaz.a <a href="http://libyaz.la" target="_blank">libyaz.la</a><br>
>> >>> >> >> > libyaz_icu.a <a href="http://libyaz_icu.la" target="_blank">libyaz_icu.la</a> libyaz_server.a<br>
>> >>> >> >> > <a href="http://libyaz_server.la" target="_blank">libyaz_server.la</a> libyaz.3.dylib libyaz.dylib<br>
>> >>> >> >> > libyaz_icu.3.dylib libyaz_icu.dylib<br>
>> >>> >> >> > libyaz_server.3.dylib<br>
>> >>> >> >> > libyaz_server.dylib<br>
>> >>> >> >> ><br>
>> >>> >> >> ><br>
>> >>> >> >> > But then I have a External Module Not Found on<br>
>> >>> >> >> > YAZPQFFFILibrary>>createParser<br>
>> >>> >> >> > " YAZPQDFFILibrary default createParser "<br>
>> >>> >> >> > <cdecl: YAZPQFParser 'yaz_pqf_create' (void) module: 'yaz3'><br>
>> >>> >> >> > ^ self externalCallFailed<br>
>> >>> >> >> ><br>
>> >>> >> >> > Any hint ?<br>
>> >>> >> >> > Cheers,<br>
>> >>> >> >> > Laurent Laffont -- FFI newbie<br>
>> >>> >> >> ><br>
>> >>> >> >> > Pharo Smalltalk Screencasts: <a href="http://www.pharocasts.com/" target="_blank">http://www.pharocasts.com/</a><br>
>> >>> >> >> > Blog: <a href="http://magaloma.blogspot.com/" target="_blank">http://magaloma.blogspot.com/</a><br>
>> >>> >> >> ><br>
>> >>> >> >><br>
>> >>> >> >> --<br>
>> >>> >> >> Hernán Morales<br>
>> >>> >> >> Information Technology Manager,<br>
>> >>> >> >> Institute of Veterinary Genetics.<br>
>> >>> >> >> National Scientific and Technical Research Council (CONICET).<br>
>> >>> >> >> La Plata (1900), Buenos Aires, Argentina.<br>
>> >>> >> >> Telephone: +54 (0221) 421-1799.<br>
>> >>> >> >> Internal: 422<br>
>> >>> >> >> Fax: 425-7980 or 421-1799.<br>
>> >>> >> ><br>
</div></div></blockquote></div><br>
</div>