<div dir="ltr"><br><br><div class="gmail_quote">2008/9/4 Joel J. Adamson <<a href="mailto:adamsonj@email.unc.edu">adamsonj@email.unc.edu</a>> <span dir="ltr"><<a href="mailto:adamsonj@email.unc.edu">adamsonj@email.unc.edu</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Dear Gambit-List,<br>
<br>
I've been accumulating a library of functions for simulating population<br>
processes (called "genxic"), and I'm running into some pesky errors.<br>
This code includes quite a lot of foreign functions, interfacing with<br>
the GNU Scientific Library.<br>
<br>
1)  When running numerically intense simulations, I'll get a segfault:<br>
<br>
,----<br>
| Process scheme segmentation fault<br>
`----<br>
<br>
This might be after 50 iterations of a simulation when I'd planned to do<br>
1152.<br>
<br>
Where do I go from there?  I've tried running gsc and gsi in GDB, but<br>
pretty often I can't get a backtrace after the segfault.  The conditions<br>
under which the segfault occurs varies.  Sometimes I get it after<br>
loading the library.</blockquote><div><br>Recompile Gambit with debug options flipped on:<br><br>Unpack the Gambit sources.<br><br>Run ./configure --enable-single-host<br><br>(Should we flip on --enable-debug here also ?? )<br>
<br>Replace the two occurrences -O1 in Makefile with -O0 -g (more important than -O0 is -g, I heard a rumor that debugging info may be better if you do -O1 -g but have no idea).<br><br>make; make install <br><br>Ensure your sourcecode is compiled with (declare (safe)) (that's the default setting). I don't remember if the -O0 -g will be reflected to gcc/g++ when you do compile-file from within your app, so consider adding this to cc-opts of compile-file.<br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
2)  I've gotten this bizarre error from one of my procedures, and would<br>
like to know where to go to debug it:<br>
<br>
,----<br>
| *** ERROR IN | genxic.o1#31| -- (Argument 1) F64VECTOR expected<br>
| (f64vector-ref<br>
|  '#u16(47806 51966 47806 51966 47806 51966 47806 51966 47806 51966 47806 519...<br>
|  1)<br>
`----<br>
<br>
I am not initializing any u16 vectors (that I know of), so how can I<br>
tell where this comes from, and how do I investigate, or find what<br>
procedure genxic.o1#31 is?  I tried repeating the compilation, and this<br>
is what I got<br>
<br>
Dumping:<br>
  #<primitive | genxic.o2|><br>
  #<primitive | genxic.o2#0|><br>
  #<primitive | genxic.o2#1|><br>
  #<primitive | genxic.o2#2|><br>
  #<primitive | genxic.o2#3|><br>
...<br>
  #<primitive | genxic.o2#30|><br>
  #<primitive | genxic.o2#31|><br>
  #<procedure 1+><br>
  #<procedure 1-><br>
  #<procedure atom?><br>
  #<procedure xcons><br>
  #<procedure make-list>...<br>
<br>
How are these procedures labeled, and how do I figure out which one it<br>
is?</blockquote><div><br>Using the instructions above, this should be fixed.<br><br>In order to track down the source of your bugs, it may be important for you to note that<br><br> - Throwing exceptions with no handler/catcher may sigsegv your app.<br>
<br> - You should presuppose that ___argXX variables inside Scheme-to-C calls are trashed after C-to-Scheme calls. I.e.: If you have declared a c-define or c-lambda that takes parameters, these will appear as ___arg0, ___arg1 etc. in the C code of the c-define / c-lambda. These will have correct contents all until you invoke Scheme functions from the C code. not afterwards. So back them up to the stack if you do.<br>
<br> - Ensure you didn't call the version of any Gambit-internal function with broken parameters. The names of them start with ##. Very simple example:<br><br><div style="margin-left: 40px;">>(cadr 4)<br>*** ERROR IN (console)@3.1 -- (Argument 1) PAIR expected<br>
(cadr 4)<br>1><br>>(##cadr 4)<br>/usr/local/bin/gsc: line 5: 17999 Segmentation fault<br></div><br>If your problems persist, ask the list further.<br><br></div></div>M<br><br></div>