Skip to content

Instantly share code, notes, and snippets.

@STRd6
Created April 3, 2012 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save STRd6/2288230 to your computer and use it in GitHub Desktop.
Save STRd6/2288230 to your computer and use it in GitHub Desktop.
Mysterious array allocation
(gdb) break XModule.cpp:1882
Breakpoint 1 at 0x407d84: file XModule.cpp, line 1882. (2 locations)
(gdb) run
Starting program: /home/daniel/Desktop/milkytracker-0.90.85/src/milkyplay/extractor
Breakpoint 1, XModule (this=0x76c670) at XModule.cpp:1882
1882 phead = new TXMPattern[256];
(gdb) print phead
$1 = (TXMPattern *) 0x0
(gdb) print header
$2 = {sig = '\000' <repeats 16 times>, name = '\000' <repeats 31 times>, whythis1a = 0 '\000', tracker = '\000' <repeats 31 times>, ver = 0, hdrsize = 0, ordnum = 0,
restart = 0, channum = 0, patnum = 0, insnum = 0, smpnum = 0, volenvnum = 0, panenvnum = 0, frqenvnum = 0, vibenvnum = 0, pitchenvnum = 0, freqtab = 0,
uppernotebound = 0 '\000', relnote = 0 '\000', flags = 0, tempo = 0, speed = 0, mainvol = 0, ord = '\000' <repeats 255 times>, pan = '\000' <repeats 255 times>}
(gdb) step
1883 instr = new TXMInstrument[256];
(gdb) print phead
$3 = (TXMPattern *) 0x0
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Program not restarted.
(gdb) continue
Continuing.
Greensleeves.xm exists!
Program received signal SIGSEGV, Segmentation fault.
XModule::cleanUp (this=0x76c670) at XModule.cpp:1840
1840 if (phead[i].patternData)
(gdb) print i
$4 = <value optimized out>
(gdb) print phead
$5 = (TXMPattern *) 0x0
(gdb) backtrace
#0 XModule::cleanUp (this=0x76c670) at XModule.cpp:1840
#1 0x0000000000425d36 in LoaderXM::load (this=<value optimized out>, f=..., module=0x76c670) at LoaderXM.cpp:73
#2 0x0000000000409ee9 in XModule::loadModule (this=0x76c670, f=..., scanForSubSongs=false) at XModule.cpp:1984
#3 0x0000000000409f98 in XModule::loadModule (this=0x76c670, fileName=<value optimized out>, scanForSubSongs=112) at XModule.cpp:1962
#4 0x000000000040051d in main ()
(gdb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment