Re: Problems running self-building code with Unicode

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ivan Brugiolo [MSFT] (ivanbrug_at_online.microsoft.com)
Date: 06/09/04


Date: Wed, 9 Jun 2004 09:30:53 -0700

When the application has the dialog-box of the C-Runtime abort function out,
you can attach a non invasive debugger (cdb/ntsd/windbg -pv -p PID),
and then inspect all the threads (execute the `~*kb` command).
You will find a thread with a stack that has on top the messagebox code from
your C-Runtime,
and, in the middle, the abort()/terminate() functions from C-Runtime, and
at, the bottom,
something that looks like an exception filter.
Switch to that thread (`~XXXs`, where XXX is the debugger thread ordinal).
Execute the following command
0:001>s -d poi(@$teb+8) poi(@$teb+4) 1003f
at this point you will have a list of stack based CONTEXT records.
Pick-up the one at the bottom of the displayed list.
Issue the command
0:001>.cxr <address from the previous step>
and then issues the `kb` command.
You should be able to see what's the cause of your problem over there.

-- 
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Toby Sharp" <toby_sharp at hotmail dot com> wrote in message
news:u$UKbriTEHA.1984@TK2MSFTNGP12.phx.gbl...
> I have an app developed with C++ and inline assembly, compiled with MSDEV
> .NET.
>
> In the program, I generate code in memory at run-time which is then
> executed. The memory where the code is built is allocated with
VirtualAlloc
> with PAGE_EXECUTE_READWRITE access. After building the code I call
>     FlushInstructionCache(::GetCurrentProcess(), NULL, 0);
>
> The program runs very well in all but one circumstance. It works in Debug
> mode, in Release mode, in Unicode Debug mode. It works in Unicode Release
> mode if run from within the debugger (F5). But if run outside the debugger
> in Unicode Release mode, it crashes with:
>
> "Runtime Error!
> Program: <appname>.exe
> This application has requested the Runtime to terminate in an unusual way.
> Please contact the application's support team for more information."
>
> Then:
>
> "The instruction at 0x7c2b88b5 referenced memory at 0x0000001c. The memory
> could not be read. Click on OK to terminate the program."
>
> Then:
>
> "Runtime Error!
> Program: <appname>.exe
> R6025 - pure virtual function call"
>
> I use the same code in a test app and it works fine. The only substantial
> difference that I can think of is that in the real app (where it crashes),
> this code is executed in a separate thread.
>
> Does the FlushInstructionCache call work OK with threads?
>
> Any ideas on this would be really welcome.
>
> Thanks,
> Toby.
>
>


Relevant Pages

  • Re: Problems running self-building code with Unicode
    ... > Switch to that thread (`~XXXs`, where XXX is the debugger thread ordinal). ... > Execute the following command ... >> mode, in Release mode, in Unicode Debug mode. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Problem with UPDATE_COMMAND_UI
    ... I am using the debugger and it is not called until I try to execute the menu ... >>called at this point but the COMMAND event is no longer called. ... > Doug Harrison ...
    (microsoft.public.vc.mfc)
  • gnome-settings-daemon crashed twice
    ... To debug your program, run it with the --sync command line ... backtrace from your debugger if you break on the gdk_x_errorfunction.) ...
    (GNOME)
  • Re: URGENT
    ... But I've got a pretty good imagination, and may be able to "see" how they'd look in a debugger without actually doing it. ... But as best as I can imagine how the'd work in RosAsm, ... Run the Assembler and this file to read its Source. ... hit (compile & execute in Debugger mode) and then ...
    (alt.lang.asm)
  • Debugging
    ... On my WinXP Professional box at home, I can't get the debugger to start from ... I get the same error using NetBeans 3.5.1, ... The command the IDE is trying to execute - shown in the output window - is ...
    (comp.lang.java.softwaretools)