<br><br><div class="gmail_quote">On Sat, Dec 25, 2010 at 9:23 PM, Hernán Morales Durand <span dir="ltr">&lt;<a href="mailto:hernan.morales@gmail.com">hernan.morales@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Thanks for the answers guys. It is very dissapointing to try a fix<br>
when the VM suddenly dissapears over and over again. I have no time<br>
for building a plugin, so our best options are to wait a fix from<br>
someone with VM/FFI knowledge or slowly specify the struct alignments<br>
of the Z39.50 structures (and not sure if it&#39;s the real cause<br>
because... the VMs segfaults).<br></blockquote><div><br></div><div>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&#39;ll make progress, albeit slowly.  Also, try writing a C program that prints out the struct offsets, e.g.</div>
<div><br></div><div>#define printoffset(struct,field) printf(&quot;&amp;&quot; #struct &quot;.&quot; #field &quot;=%d\n&quot;, (char *)&amp;(struct.field) - (char *)&amp;field)</div><div><br></div><div>Better still get the FFI to generate such a file for you automagically that prints out the relevant Smalltalk source.</div>
<div><br></div><div>HTH</div><div>Eliot</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Cheers,<br>
<br>
Hernán<br>
<br>
2010/12/24 David T. Lewis &lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt;:<br>
&gt;<br>
&gt; On Fri, Dec 24, 2010 at 12:44:50PM -0300, Hern??n Morales Durand wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi David,<br>
&gt;&gt;<br>
&gt;&gt; 2010/12/24 David T. Lewis &lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt;:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Hern??n,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; A segmentation fault that occurs when calling the function in an<br>
&gt;&gt; &gt; external library would most likely indicate that the arguments being<br>
&gt;&gt; &gt; passed to the library function are not correct for some reason.<br>
&gt;&gt; &gt; Probably it is something related to the ExternalStructure as you<br>
&gt;&gt; &gt; mention.<br>
&gt;&gt;<br>
&gt;&gt; The strange thing is that in the Windows VM goes fine.<br>
&gt;<br>
&gt; There are differences in the Windows an unix implementations, so<br>
&gt; sometimes a declaration that works on Windows may need to be done<br>
&gt; differently on unix. I don&#39;t have any examples, but I know I have<br>
&gt; seen this in the past.<br>
&gt;<br>
&gt;&gt; Is there a<br>
&gt;&gt; special VM debug flag or parameter specifically for this cases? Maybe<br>
&gt;&gt; I could check with that.<br>
&gt;<br>
&gt; I do not know of anything that would help here. In the past I have<br>
&gt; done debugging by setting gdb breakpoints right before running<br>
&gt; the workspace script. It&#39;s a real pain but it can be done.<br>
&gt;<br>
&gt; I know that this does not answer your question, but if you can<br>
&gt; consider building a plugin rather than using FFI, I think you may<br>
&gt; find it to be easier to debug and more reliable overall.<br>
&gt;<br>
&gt; Dave<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; &gt; You must use a normal 32-bit VM and 32-bit libraries. I think that<br>
&gt;&gt; &gt; you are doing this, but I mention it because using 64-bit VM or<br>
&gt;&gt; &gt; libraries will definitely crash FFI.<br>
&gt;&gt; &gt; ??&lt;<a href="http://bugs.squeak.org/view.php?id=7237" target="_blank">http://bugs.squeak.org/view.php?id=7237</a>&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; Yes, I&#39;m sure because Ubuntu 8.10 doesn&#39;t allow to install libraries<br>
&gt;&gt; compiled for another architecture.<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt;<br>
&gt;&gt; &gt; Dave<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Fri, Dec 24, 2010 at 08:33:33AM +0100, laurent laffont wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Which VM have you used ?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; I cross post to vm-dev list.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Laurent.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On Fri, Dec 24, 2010 at 3:54 AM, Hern??n Morales Durand &lt;<br>
&gt;&gt; &gt;&gt; <a href="mailto:hernan.morales@gmail.com">hernan.morales@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; Laurent, not much progress here :(<br>
&gt;&gt; &gt;&gt; &gt; I just reproduced the Unix VM crash. First I&#39;ve linked the library so<br>
&gt;&gt; &gt;&gt; &gt; we do not have to change every module name call<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; user@ubuntu:/usr/lib$ ln -T -s /usr/lib/libyaz.so.3.0.0 yaz<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; and I&#39;ve tried to execute the library tracer in the shell script<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; ltrace -f -l /usr/lib/libyaz.so.3.0.0 -o out.txt &quot;$BASE/squeakvm&quot; \<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??-plugins &quot;$BASE&quot; \<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??-encoding latin1 \<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??-vm-display-X11 \<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??&quot;$ROOT/Contents/Resources/pharo.image&quot;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; but it crash the VM too with an unhandled exception even before the<br>
&gt;&gt; &gt;&gt; &gt; GUI is displayed.<br>
&gt;&gt; &gt;&gt; &gt; What I&#39;ve observed is that every FFI call which receives an<br>
&gt;&gt; &gt;&gt; &gt; ExternalStructure as parameter kills the VM. This is weird because<br>
&gt;&gt; &gt;&gt; &gt; this doesn&#39;t happen in the Windows VM. I ran this little script I use<br>
&gt;&gt; &gt;&gt; &gt; to debug the library<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; | conn lib rs rsSize records |<br>
&gt;&gt; &gt;&gt; &gt; lib := Z3950FFILibrary default.<br>
&gt;&gt; &gt;&gt; &gt; conn := lib<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??createConnectionTo: #Alabama asZ3950Server hostName<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??port: 7090.<br>
&gt;&gt; &gt;&gt; &gt; lib createOptions.<br>
&gt;&gt; &gt;&gt; &gt; lib<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??setConnection: conn<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??optionName: &#39;preferredRecordSyntax&#39;<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??optionValue: &#39;USMARC&#39;.<br>
&gt;&gt; &gt;&gt; &gt; rs := lib<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??searchPqf: conn<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??query: ??&#39;@attr 1=1003 collins&#39;.<br>
&gt;&gt; &gt;&gt; &gt; rsSize := lib resultSetSize: rs.<br>
&gt;&gt; &gt;&gt; &gt; rsSize &gt; 0<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??ifFalse: ??[ &#39;no results&#39; ].<br>
&gt;&gt; &gt;&gt; &gt; records := Array new: rsSize.<br>
&gt;&gt; &gt;&gt; &gt; 0 to: rsSize - 1 do: [: pos |<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??record := lib resultSetRecord: rs position: pos.<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ??record isNil not<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ?? ?? ?? ?? ??ifTrue: ??[<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??records<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??at: pos + 1<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??put: ( lib<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??getRecord: record<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??function: &#39;render; charset=marc8,<br>
&gt;&gt; &gt;&gt; &gt; iso8859-1&#39;<br>
&gt;&gt; &gt;&gt; &gt; ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??length: nil ). ] ].<br>
&gt;&gt; &gt;&gt; &gt; records<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; and the the doIt just hangs the VM, the console output going through<br>
&gt;&gt; &gt;&gt; &gt; the Debugger is the following:<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Segmentation fault<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; -1370902312 ContextPart&gt;doPrimitive:method:receiver:args:<br>
&gt;&gt; &gt;&gt; &gt; -1370902404 ContextPart&gt;tryPrimitiveFor:receiver:args:<br>
&gt;&gt; &gt;&gt; &gt; -1370902788 ContextPart&gt;send:to:with:super:<br>
&gt;&gt; &gt;&gt; &gt; -1370902896 ContextPart&gt;send:super:numArgs:<br>
&gt;&gt; &gt;&gt; &gt; -1370902988 InstructionStream&gt;interpretExtension:in:for:<br>
&gt;&gt; &gt;&gt; &gt; -1370903080 InstructionStream&gt;interpretNextInstructionFor:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Hern??n Morales<br>
&gt;&gt; Information Technology Manager,<br>
&gt;&gt; Institute of Veterinary Genetics.<br>
&gt;&gt; National Scientific and Technical Research Council (CONICET).<br>
&gt;&gt; La Plata (1900), Buenos Aires, Argentina.<br>
&gt;&gt; Telephone: +54 (0221) 421-1799.<br>
&gt;&gt; Internal: 422<br>
&gt;&gt; Fax: 425-7980 or 421-1799.<br>
</blockquote></div><br>