When you hit the segfault, use the "up" command a couple of times so you're looking at this frame
#2 0x000171f8 in Compressor::compress ()
Then list the source code lines so you know exactly where you are.
Then start examining variables (in particular, whatever string you're trying to assign) to see if it's valid.
Maybe your parser returned rubbish.
> The program seems to stop at line 96212. Any ideas?
Use a counting breakpoint at some point where a whole line is read, and make it run for 96211 times. Then start single stepping until you discover something new.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
> but removing the str = idNode + "\t"; seems to have fixed the segfault.
Yeah, idNode is an int, and "\t" is a string constant.
Which basically means a char at "\t"[idNode]
Which is perfectly valid (if obscure) code, so long as idNode is actually zero, but would be increasingly way off the end of the array until (inevitably) you stepped off the end of valid memory and got a segfault.
Didn't you see lots of random garbage instead of the "nnn\t" you were expecting whilst testing this code?
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
> No, that line was never being used in my code
You mean you weren't using str later on.
But it was still doing all the work, marching off into unknown memory and the like.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953