CxxFrameHandler problem

John K. Hohm jhohm at acm.org
Fri Apr 11 01:27:50 CDT 2003


On Wed, Jul 17, 2002 at 04:40:16PM -0500, John K. Hohm wrote:
> Alexandre Julliard <julliard at winehq.com> wrote:
> > Uwe Bonnes <bon at elektron.ikp.physik.tu-darmstadt.de> writes:
> > 
> > > Appended program uses CxxFrameHandler and crashes in wine with builtin
> > > msvcrt, but not with native. Compile as Release version and include the
> > MFC
> > > dll. Can somebody compile for Alexandre? Alexandre, is this a start or do
> > > you need something complete?
> > 
> > That's a start, yes, thanks. I'll need a more complete example with
> > nested try blocks, destructors all over the place, typed exceptions,
> > etc. to make sure I understand all the compiler internal structures;
> > but I can at least try to make that simple case not crash...
> 
> Although this may duplicate effort, I am familiar with several strange 
> combinations of exception handling that I know work with Visual C++ 6.0; I 
> will put them a test program for you.  You can never have too many test 
> programs, right?

I'm obviously a slacker, since I just now got around to this test.  ;-)
It still does not test the more esoteric typed exception requirements.

With current CVS wine, my test program breaks into the debugger when it
should result entirely in handled exceptions.  The test actually
triggers a bug in the C library (including MSVCRT.DLL) from Visual
Studio 6 SP3 and later, which is only fixed in the MSVCRT.DLL from
Windows XP: the destructor for a re-thrown object gets called twice,
which results in the last line ending in -1 rather than 0 as it should. 
Wine starts out like XP, avoiding the first (incorrect) destructor call,
but fails to make it all the way back out of main.

I have attached (inline) the source, the output on Windows 2000 (wrong),
the output on Windows XP (correct), and my results from Wine (debugger).  
Also, in a zip file is the executable with debug info.
-------------- next part --------------
//
// Exception-handling test
// written 2003 by John K. Hohm, placed in public domain
//
#include <stdio.h>

class A
{
  char const* name;
  static int extant;
public:
  explicit A(char const* name)
    : name(name) { printf(" %s, %d\n", name, extant++); }
  A(A const& rhs)
    : name(rhs.name) { printf("+%s, %d\n", name, extant++); }
  ~A() { printf("~%s, %d\n", name, --extant); }
};

int A::extant = 0;

void f()
{
  A a("f() before throw");
  throw A("thrown by f()");
}

void g()
{
  A a("g() before try");
  try {
    A a("g() in try");
    throw;
  }
  catch(A&) {
    A a("g() in catch");
    try {
      A a("g() in sub-try");
      throw A("thrown by g()");
    }
    catch(...) {
      A a("g() in sub-catch");
      throw;
    }
  }
}

int main()
{
  A a("main() before try");
  try {
    A a("main() in try");
    f();
  }
  catch(...) {
    A a("main() in catch");
    try {
      A a("main() in sub-try");
      g();
    }
    catch(A&) {
      A a("main() in sub-catch");
    }
  }
  return 0;
}
-------------- next part --------------
 main() before try, 0
 main() in try, 1
 f() before throw, 2
 thrown by f(), 3
~f() before throw, 3
~main() in try, 2
 main() in catch, 2
 main() in sub-try, 3
 g() before try, 4
 g() in try, 5
~g() in try, 5
 g() in catch, 5
 g() in sub-try, 6
 thrown by g(), 7
~g() in sub-try, 7
 g() in sub-catch, 7
~thrown by f(), 7
~g() in sub-catch, 6
~g() in catch, 5
~g() before try, 4
~main() in sub-try, 3
 main() in sub-catch, 3
~main() in sub-catch, 3
~thrown by g(), 2
~main() in catch, 1
~thrown by f(), 0
~main() before try, -1
-------------- next part --------------
 main() before try, 0
 main() in try, 1
 f() before throw, 2
 thrown by f(), 3
~f() before throw, 3
~main() in try, 2
 main() in catch, 2
 main() in sub-try, 3
 g() before try, 4
 g() in try, 5
~g() in try, 5
 g() in catch, 5
 g() in sub-try, 6
 thrown by g(), 7
~g() in sub-try, 7
 g() in sub-catch, 7
~g() in sub-catch, 7
~g() in catch, 6
~g() before try, 5
~main() in sub-try, 4
 main() in sub-catch, 4
~main() in sub-catch, 4
~thrown by g(), 3
~main() in catch, 2
~thrown by f(), 1
~main() before try, 0
-------------- next part --------------
 main() before try, 0
 main() in try, 1
 f() before throw, 2
 thrown by f(), 3
~f() before throw, 3
~main() in try, 2
 main() in catch, 2
 main() in sub-try, 3
 g() before try, 4
 g() in try, 5
~g() in try, 5
 g() in catch, 5
 g() in sub-try, 6
 thrown by g(), 7
~g() in sub-try, 7
 g() in sub-catch, 7
~g() in sub-catch, 7
~g() in catch, 6
~g() before try, 5
~main() in sub-try, 4
 main() in sub-catch, 4
~main() in sub-catch, 4
~thrown by g(), 3
WineDbg starting on pid 8
Loaded debug information from ELF 'wine' ((nil))
Breakpoint 1 at 0x4000b620 (_end+0x3ff7dc4)
Loaded debug information from ELF '/usr/local/lib/libntdll.dll.so' (0x4001f000)
Loaded debug information from ELF '/usr/local/lib/libwine.so.1' (0x40124000)
Loaded debug information from ELF '/usr/local/lib/libwine_unicode.so.1' (0x4013c000)
No debug information in ELF '/lib/libm.so.6' (0x4021d000)
No debug information in ELF '/lib/libc.so.6' (0x40240000)
No debug information in ELF '/lib/libdl.so.2' (0x40370000)
No debug information in ELF '/lib/ld-linux.so.2' (0x40000000)
No debug information in ELF '/lib/libnss_compat.so.2' (0x40374000)
No debug information in ELF '/lib/libnsl.so.1' (0x40380000)
Loaded debug information from ELF '/usr/local/lib/wine/msvcrt.dll.so' (0x406d3000)
Loaded debug information from ELF '/usr/local/lib/wine/kernel32.dll.so' (0x4071b000)
Loaded debug information from 32bit DLL 'F:\src\ehtest\ehtest2-msvcrt.exe' (0x400000)
No debug information in 32bit DLL 'C:\WINDOWS\SYSTEM\NTDLL.DLL' (0x40050000)
No debug information in 32bit DLL 'C:\WINDOWS\SYSTEM\KERNEL32.DLL' (0x40740000)
No debug information in 32bit DLL 'C:\WINDOWS\SYSTEM\MSVCRT.DLL' (0x406f0000)
Unhandled exception: c0000025 in 32-bit code (0x400caa49).
In 32-bit mode.
0x400caa49 (EXC_RtlRaiseException+0x129 [exception.c:242] in libntdll.dll.so): subl	$4,%esp
245	        frame = frame->Prev;
Wine-dbg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ehtest2-msvcrt.zip
Type: application/x-zip-compressed
Size: 8644 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20030411/000c3491/ehtest2-msvcrt.bin


More information about the wine-devel mailing list