I'm struggling with the debugger. I have a function called foo, I try
to call it, and save the results, and it segfaults:
Error in function UNIX::SIGSEGV-HANDLER: Segmentation Violation at #x4A3C7182.
Restarts:
0: [ABORT] Return to Top-Level.
Debug (type H for help)
(UNIX::SIGSEGV-HANDLER #<unused-arg>
#<unused-arg>
#.(SYSTEM:INT-SAP #x3FFFE730))
Source:
; File: target:code/signal.lisp
; File has been modified since compilation:
; target:code/signal.lisp
; Using form offset instead of character position.
(DEFINE-SIGNAL-HANDLER SIGSEGV-HANDLER "Segmentation Violation")
0]
So I run a backtrace:
0] backtrace
0: (UNIX::SIGSEGV-HANDLER #<unused-arg>
#<unused-arg>
#.(SYSTEM:INT-SAP #x3FFFE730))
1: ("Foreign function call land")
2: ("Foreign function call land")
3: ("Foreign function call land")
4: ("Foreign function call land")
5: (SCORE-TRAIN-MODEL "3843"
#2A((2.134015 2.1975312 2.2404096 2.3555758 2.362708 ...)
(3.6013038 3.6857574 3.8026226 3.835586 3.8511353
...)
(2.0084505 2.0255628 2.0512905 2.1162856 2.1207612
...)
(3.1654859 3.3876834 3.429235 3.4307926 3.5012054
...)
(2.0243797 2.0924115 2.1061792 2.2444265 2.3977294
...)
...)
#2A(("3112" "3107" "3966" "3607" "3869" ...)
("3764" "3764" "3255" "3897" "3764" ...)
("3626" "3966" "3256" "3626" "3869" ...)
("3927" "3377" "3764" "3263" "3299" ...)
("3734" "3419" "3171" "3339" "3171" ...)
...)
1)
6: (SCORE-TEST-MODEL #<Stream for file "../Data/multi1000K/baaf.bin">
500
500
#<Closure Over Function "DEFUN MAKE-POINT-TO-MODEL-FUN"
{483A1051}>
...)
7: (SCORE-ANN-DIR "../Data/multi1000K/" "../verySmall" 500 500 ...)
8: (FOO)
9: (EVAL (SETF LR (FOO)))
10: (INTERACTIVE-EVAL (SETF LR (FOO)))
11: (COMMON-LISP::%TOP-LEVEL)
12: (COMMON-LISP::RESTART-LISP)
0]
I head to frame 5, which is where it looks like my error has to be,
and look at the locals and the source:
5] list-locals
DISTS-ARR = #2A((2.134015 2.1975312 2.2404096 2.3555758 2.362708 ...)
(3.6013038 3.6857574 3.8026226 3.835586 3.8511353 ...)
(2.0084505 2.0255628 2.0512905 2.1162856 2.1207612 ...)
(3.1654859 3.3876834 3.429235 3.4307926 3.5012054 ...)
(2.0243797 2.0924115 2.1061792 2.2444265 2.3977294 ...)
...)
IDS-ARR = #2A(("3112" "3107" "3966" "3607" "3869" ...)
("3764" "3764" "3255" "3897" "3764" ...)
("3626" "3966" "3256" "3626" "3869" ...)
("3927" "3377" "3764" "3263" "3299" ...)
("3734" "3419" "3171" "3339" "3171" ...)
...)
SIGMA = 1
TM = "3843"
5] source
Unknown location: using block start.
; File: /home/rif/Projects/SpeakerRecog/NIST98/Lisp/ProcessOutput.lisp
(AREF DISTS-ARR I J)
5]
Alright, so I think the aref is producing the error. i and j are both
local variables of score-train-model, defined as the iteration
variables for a pair of nested dotimes loops, the aref call is inside
both loops. I'm not sure why they're not listed by list-locals, which
seems to only list the parameters of the function, rather than the
variables where I'm executed.
The manual suggests using debug:var to inspect the value of a
variable. I think I have to call this as a function, as opposed to
list-locals, which seems to just be a variable:
5] (debug:var i)
#<Debug-Variable COMMON-LISP-USER:I:0> has :invalid or :unknown value in
#<Compiled-Frame SCORE-TRAIN-MODEL, interrupted>.
5] (debug:var j)
#<Debug-Variable COMMON-LISP-USER:J:0> has :invalid or :unknown value in
#<Compiled-Frame SCORE-TRAIN-MODEL, interrupted>.
I'm just not sure what to do next. I've used gdb extensively to debug
C/C++ programs, but I just feel lost here. Any help you can offer
would be appreciated.
rif
ps. If it's relevant, ProcessOutput.lisp was compiled with debug set
to 3.