In my 32-bit Delphi XE2 application (Update 4 Hotfix 1 Version 16.0.4504.48759), I use the Format () routine to register pointer values.
For instance:
Format('MyObject (%p)', [Pointer(MyObject)]);
However, the resulting string sometimes contains garbage characters (for example, in this case "?" Or "|" instead of hexadecimal digits):
MyObject (4E?|2010)
I also get the same result when replacing "% p" with "% x" as follows:
Format('MyObject (%x)', [Integer(MyObject)]);
However, using an integer value always works:
Format('MyObject (%d)', [Integer(MyObject)]); MyObject (1291453120)
Is there an error that I donβt know about, or could it be due to a problem that occurred here?
Why is the format crashing for anything other than "% s" used with the option?
UPDATE
I accepted Jeroen's answer as it led me to a decision on the troubleshooting process. After the situation with the launch of the application through F7 (in accordance with the comment), I thought that something should happen much earlier in this process. On suspicion, I disabled madExcept from my IDE menu, rebuilt the application, and the problem disappeared. Obviously, no matter which madExcept code was associated with my application, this caused a rewrite in the SysUtils TwoHexLookup constant. Re-enabling madExcept and rebuilding (without any changes on my part) also worked, so there must have been some corruption at the linking stage.
Jeroneβs strategy for detecting memory corruption was a useful exercise and should be useful if I came across a similar situation.