Question

I'm using Xcode with Clang as the compiler, and I'm currently getting an EXC_BAD_ACCESS when calling a function on a pointer whose address is 0xCDCDCDCD. I've also seen some variables set to 0xABABABAB around. I've looked around and noticed that these values are used as magic numbers in Visual Studio, to help see what the problem is. However I can't find a list of magic numbers used by Xcode (or Clang, not sure if it's a mechanism from the compiler or IDE). Does anyone know where I can find one?

Était-ce utile?

La solution

I'm not aware of any comprehensive list, which seems to be what you are searching for, but 0xCDCDCDCD is typically used by the C runtime when you allocate a block of memory with a Debug build.

Autres conseils

I don't know of any such list except for the Wikipedia "magic debug value" list which lists various magic numbers used in debugging.


As Mike said above, chances are the pointers are being initialised to an invalid memory address in your debug build to make it easier to catch potential pointer-related errors.

It's a compiler or runtime feature, but the exact value they're being initialised to shouldn't matter since the feature is there to make pointer debugging simpler. The EXC_BAD_ADDRESS is simply a result of trying to perform actions on unallocated memory and is, in fact, expected behaviour.

The numbers are being used as magic numbers in Visual Studio probably precisely for the reason that they can be used to locate uninitialised pointers when running compiled programs.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top