Author Topic: c::b SIGSEGV  (Read 2232 times)

Offline frithjofh

  • Regular
  • ***
  • Posts: 373
c::b SIGSEGV
« on: December 02, 2007, 07:53:04 pm »
hi everybody,

I just got a SIGSEGV on a line I wrote. Checking this with the debugger it said:

cannot acces memory at adress: 0xbaadf00d

I took some time to understand ... could this mean, this adress is "bad food" and will cause an error ...

Not knowing wether this is coded like this on pupose or not at least it gave me a laugh.

greetings from asturias

nausea

ps: is this coded on purpose to spell bad food ?????
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: c::b SIGSEGV
« Reply #1 on: December 02, 2007, 08:44:24 pm »
0xbaadf00d is a magic constant. What exactly it means depends on your operating system (you did not say which one you use).

On some systems, it is the constant which unallocated memory is initialised to, as such a "funny number" has the property of being so "obviously wrong", that you can immediately see what's wrong, even without a sophisticated debugger.
In that case, it would mean you either deleted a memory block and then used it, or you never allocated it.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline frithjofh

  • Regular
  • ***
  • Posts: 373
Re: c::b SIGSEGV
« Reply #2 on: December 02, 2007, 08:47:09 pm »
the OS is windows XP, and yes, i found out I din't allocate the memory. a case of one object using another when this does not exist yet...  :?

and yes, it is so obviously wrong that I din't see it ...
« Last Edit: December 02, 2007, 08:48:55 pm by nausea »
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: c::b SIGSEGV
« Reply #3 on: December 02, 2007, 08:50:24 pm »
Little quote from Wikipedia on that topic:
Quote
0xBAADF00D ("bad food") is used by Microsoft's LocalAlloc(LMEM_FIXED) to indicate uninitialised allocated heap memory.
0xBADDCAFE ("bad cafe") is used by 'watchmalloc' in OpenSolaris to mark allocated but uninitialized memory.
0xDEADBEEF ("dead beef") is used by IBM RS/6000 systems, Mac OS on 32-bit PowerPC processors and the Commodore Amiga as a magic debug value. On Sun Microsystems' Solaris, marks freed kernel memory
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline frithjofh

  • Regular
  • ***
  • Posts: 373
Re: c::b SIGSEGV
« Reply #4 on: December 02, 2007, 08:52:32 pm »
I have looked there allready, it helped me a lot to know where to search the error, but thanks anyway...  :D

Is there any useful list somewhere with those magic numbers in the context of debugging?

greetings from asturias

nausea
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100