BTW: I found the problem: (See my answer below)
When I build my program at home it works fine, but when I use my universities system is crashing on me. When I go at it with GDB I get this:
(gdb) r t.c- Starting program: /home/shro8822/p5/c- t.c- *--Code Gen Function: main *--in function 'main' variable offsets start at 2 Program received signal SIGSEGV, Segmentation fault. 0x08084410 in ObjectCode::ResolveRef (this=0xbfb3dd20) at CodeOutput.cpp:44
44 p->Resolve(this);
(gdb) list
39 {
40 std::list<Patch*>::iterator pos;
41 for(pos = Patchups.begin(); pos != Patchups.end(); ++pos)
42 {
43 Patch* p = *pos;
44 p->Resolve(this);
45 //delete p;
46 }
47
48 }
(gdb) p p $1 = (class ObjectCode::Patch *) 0x2064696c (gdb) p this $2 = (ObjectCode * const) 0xbfb3dd20
It crashes from a SEG-V on a line with a virtual function call involving 2 variable and neither is NULL. I don't think there is anywhere else that stuff from this list is deleted.
Tossing it a Valgrind gives one error:
==5714== Invalid read of size 4 ==5714== at 0x8084410: ObjectCode::ResolveRef() (CodeOutput.cpp:44) ==5714== by 0x8086E00: ObjectCode::Finish() (CodeOutput.cpp:196) ==5714== by 0x807EC97: WalkGlobal::Finish() (CodeGen_G.cpp:211) ==5714== by 0x808D53C: Compile::RunV() (cs445.cpp:120) ==5714== by 0x808D7C2: ProcessFile::Run() (cs445.cpp:49) ==5714== by 0x808CCD9: main (cs445.cpp:234) ==5714== Address 0x2064696C is not stack'd, malloc'd or (recently) free'd Seg fault
Any idea were to start looking?
BTW: I populate the list using only statements like this: Patchups.push_back(new PatchType());
shro8822 p5 $ grep Patchups *.cpp *.h -n CodeOutput.cpp:41: for(pos = Patchups.begin(); pos != Patchups.end(); ++pos) CodeOutput_Slot.cpp:124: { Stream->Patchups.push_back(new FunctionPatch(it,GetSlotBefor(),at)); } CodeOutput_Slot.cpp:126: { Stream->Patchups.push_back(new GotoPatch(target,GetSlotBefor(),at,"goto")); } CodeOutput_Slot.cpp:128: { Stream->Patchups.push_back(new GotoPatch(target,GetSlotBefor(),at,c)); } CodeOutput_Slot.cpp:130: { Stream->Patchups.push_back(new BranchPatch(target,GetSlotBefor(),type,from,at,c)); } CodeOutput.h:222: std::list Patchups;
Yet more: It happens that the home and school systems are both x86 (RHEL 3 and 5 respectively) so I ran the binary I compiled at home on the system at school and it runs fine.