DISQUS

Olaf's thoughts about Delphi, IntraWeb and other dev stuff : Delphi 2009 / Windows 7 / 64 bit Debugger Crash Workaround

  • Michael · 5 months ago
    So who is in charge of this to fix this annoying bug? I don't think it's Microsoft actually - so I guess CG is responsible to hot fix this in their latest flagship D2009 (and hopefully not in an upcoming version)

    Michael
  • Olaf Monien · 5 months ago
    CG will certainly say, that D2009 was released before Win7 and Win7 is not even officially released yet.
    I talked to some Q&A guy of CodeGear, he checked that error on their current internal build, and the error does not seem to be reproducible anymore. So chances are that we might get an update somewhen.

    One question here is certainly: what will be released earlier? Delphi next version (Weaver) or Win7?
  • Michael · 5 months ago
    Regarding your last question: In this case I would prefer Win 7 to be released earlier. Let's see if the Delphi community has got enough power to 'force' CG to release a hot fix for this issue.

    Michael
  • remko · 5 months ago
    Interesting issue. If we look into the pseudo code of this function:
    *(_DWORD *)(a1 + 3548) = 65551;
    if ( SetThreadContext(*(HANDLE *)(v1 + 684), (const CONTEXT *)(a1 + 3548)) != 1 )
    {
    if ( byte_455BAC )
    {
    v8 = GetLastError();
    v9 = (*(int (__cdecl **)(int))(*(_DWORD *)v1 + 132))(v1);
    sub_401B08("setContext osTId 0x%x failed %d", v9, v8);
    }
    if ( "SetThreadContext failed" )
    sub_40C6AC("(!\"SetThreadContext failed\")", "..\\win32src\\thread32.cpp", 434);
    }

    We can see that the Context flag is set to 65551 and if we look into the comments in the header file (winnt.h):
    #define CONTEXT_AMD64 0x100000
    #define CONTEXT_i386 0x00010000
    ...
    #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x00000004L) // DS, ES, FS, GS

    so all other flags are combines with either CONTEXT_AMD64 or CONTEXT_i386. It might be worth trying to patch this flag to the corresponding value for AMD64. If someone wants to try:
    .text:0043C7F5 C7 83 DC 0D 00 00 0F 00 01 00 mov dword ptr [ebx+0DDCh], 1000Fh

    /edit: found this link: http://www.nynaeve.net/?p=129
  • Olaf Monien · 5 months ago
    Thanks for your comment - esp. for the highly interesting link about GetThreadConbtext on WOW64
  • remko · 5 months ago
    I don't have an x64 os so I can't try but you can also try to make the following change:
    C7 83 DC 0D 00 00 0F 00 01 00 to C7 83 DC 0D 00 00 15 00 01 00

    It changes the Context flag from 65551 (CONTEXT_FULL or CONTEXT_FLOATING_POINT) to 65557 (CONTEXT_ALL)
  • Name · 5 months ago
    Have tested it .. Changed 0x0F to 0x15

    Additional assertion errors not seen before occured.
  • Name · 5 months ago
    Thanks a million, dude. From your information I have a created a fully automatic patcher. The patcher has been used by 8 colleagues (so far) of mine, and they all report success .. no more assertion errors.
  • Olaf Monien · 5 months ago
    Whohoo! Do you mind sharing that patcher? If you don't have a webspace, I can easily host it here on the blog.
  • Name · 5 months ago
    I dont mind at all.

    Please instruct me where to upload (FTP?), or give me an email adress I can send the attachment to :-)

    Best regards
  • Olaf Monien · 5 months ago
    Please send via e-mail to olaf (at) monien (dot) net

    My mailbox has no size limit.

    Regards,
    Olaf
  • Name · 5 months ago
    Mail on its way.
    Hope it will solve the problem for all you guys.

    Best regards
    LordByte
  • Olaf Monien · 5 months ago
    Great - thanks! I have posted a link to the patcher under "Update 2" above.
  • Name · 5 months ago
    Will even update it for other versions of Delphi,
    if anyone so desire. You must provide the
    native BORDBGxxxN.dll for inspection, and the
    BDS-basekey in the HKEY_CURRENT_USER registry-hive.

    Anyway, I hope it works for all of you.

    Best regards
    Lordbyte
  • Ron Sharp · 1 month ago
    Thanks! That did the trick with Delphi 2009 and Windows 7 for me (after I remembered to run it as an admin). There still seems to be a delay between closing the app and control returning to the IDE, but that's preferable to having to restart Delphi.

    It would be nice if there was an official patch for this, short of Delphi 2010, since it wasn't that long ago that I upgraded to 2009.
  • claudio68 · 5 months ago
    Hi Olaf's

    GREAT! GREAT! GREAT!!!

    Thank you very muche for this solution!!

    best Regards
  • zvyagaaa · 4 months ago
    Thanks a lot for your solution :) With Love From Siberia
  • John · 4 months ago
    Sweet dude, the automatic patch tool works like a charm, I can finally debug again!
  • Carl Clark · 4 months ago
    Hoo Haa!
    Thanks a million Olaf and LordByte (Patcher worked on my Delphi 2007).
  • Mason Wheeler · 3 months ago
    Not sure how much this affects older versions of Windows. I've been running Delphi 2009 under Vista 64 for almost a year now and never seen this problem once, even in multi-threaded apps.
  • OnasJ · 2 months ago
    thx alot for this solution!
  • CRM455 · 3 weeks ago
    Thanks guys,
    This saved me a lot of time trying to figure out what is going on.
    Patch program worked great on D2007.
    :)
    Chris
  • Davit · 3 weeks ago
    THANK YOU VERY MUCH
  • philipljackson · 6 days ago
    Thanks guys,
    I would never have been able to solve this one myself
    Patch program worked great on D2007.
  • piranha · 5 days ago
    Thanks dude!