11

I am teaching myself to use gdb and am running some random tests. It may be worth mentioning that I am using a portable installation of MinGW on Windows 7 x64. I've created a program which I know results in a stack overflow, and as I run through it in gdb I first get two SIGSEGV signals (no surprise), and then it exits (again no surprise) with code 030000000375.

Program received signal SIGSEGV, Segmentation fault.
Program received signal SIGSEGV, Segmentation fault.
Program exited with code 030000000375.

Curiosity getting the best of me... what the heck is that code? I googled it and found very little.

Thanks!

UPDATE: For reference I tried the same program on Ubuntu, and the results are slightly different:

Program received signal SIGSEGV, Segmentation fault.
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
The111
  • 5,757
  • 4
  • 39
  • 55
  • Do you always get the same code? If so, have you tried changing the data of your program and seeing if you still get the same code? – Shahbaz Jul 08 '12 at 21:49

1 Answers1

11

gdb prints out the exit code in octal format. Not obvious, but indicated by the leading 0.

So 030000000375 is 0xC00000FD in hex, which makes the code look much more common to a windows programmer.

0xC00000FD is STATUS_STACK_OVERFLOW and should be defined in ntstatus.h.

alk
  • 69,737
  • 10
  • 105
  • 255
  • 1
    Good find, thanks! And very interesting that Windows actually tells you when you get a stack overflow, but linux does not. – The111 Jul 09 '12 at 16:40
  • You are welcome! Btw: Perhaps you should modify the topic of this question to "*gdb: **Program** exited with code 030000000375*" as it's not `gdb` exiting with this code. @The111 – alk Jul 09 '12 at 16:47
  • Done. And to answer your other question in the comments, the test program I was using is one I came up with long ago in this post where I inadvertently taught myself about the existence of stack overflows: http://stackoverflow.com/questions/8611198/understanding-memory-allocation-test-program-crashing – The111 Jul 09 '12 at 17:19