Compiler bug? 
Author Message
 Compiler bug?

I've got a really weird problem. I've got a class that's derived from CEdit.
This class was taken from an old 16-bit project where it worked fine.

When the OnSetFocus function is called, the code generated by the compiler
for the function entry is as follows:

void QCMaskedEdit::OnSetFocus(CWnd* pOldWnd)
{
   push ebp
   mov  ebp,esp
   push ecx
   mov dword ptr[ebp-4],ecx
...

The problem appears to be that there's no sub esp, xxx following the mov
ebp,esp. Or am I wrong about that?

My stack frame gets completely screwed up in this function call and it
crashes shortly after the return from the function call (it returns to a
place far from where it was called from). Inside the function call, if I try
to add 'this' to the watch window, it tells me: 'this' requires a stack
frame

In my header file, OnSetFocus is defined:

afx_msg void OnSetFocus(CWnd* pOldWnd)

Does anyone have any idea what the problem is?

Thanks.

Pete



Fri, 02 May 2003 03:00:00 GMT  
 Compiler bug?

It's hard to tell whether that code is wrong or not. The 'push ecx'
instruction implicitly subtracts 4 from esp, so that should make
the 'mov [ebp-4],ecx' quite legal - if a bit pointless.

Is this an optimized build? If so the problems displaying 'this'
are, unfortunately, quite common. If it's a debug build, make sure
you've stepped far enough into the routine for the stack
frame to be setup - then the de{*filter*} will start displaying
locals, and this.

Good luck.

Quote:

> I've got a really weird problem. I've got a class that's derived from CEdit.
> This class was taken from an old 16-bit project where it worked fine.

> When the OnSetFocus function is called, the code generated by the compiler
> for the function entry is as follows:

> void QCMaskedEdit::OnSetFocus(CWnd* pOldWnd)
> {
>    push ebp
>    mov  ebp,esp
>    push ecx
>    mov dword ptr[ebp-4],ecx
> ...

> The problem appears to be that there's no sub esp, xxx following the mov
> ebp,esp. Or am I wrong about that?

> My stack frame gets completely screwed up in this function call and it
> crashes shortly after the return from the function call (it returns to a
> place far from where it was called from). Inside the function call, if I try
> to add 'this' to the watch window, it tells me: 'this' requires a stack
> frame

> In my header file, OnSetFocus is defined:

> afx_msg void OnSetFocus(CWnd* pOldWnd)

> Does anyone have any idea what the problem is?

> Thanks.

> Pete

--
.Bruce Dawson, Humongous Entertainment (we're hiring).
http://www.*-*-*.com/
Send job applications by e-mail, post technical questions
to the newsgroups please. Thanks.


Fri, 02 May 2003 03:00:00 GMT  
 Compiler bug?
It's a release build with debug info, as the problem only shows up here in
release builds.

In debug builds, it shows up in a different part of the code. I'm thought
maybe the class was corruping memory somehow, but I put a breakpoint in the
beginning of every public function to see see what was getting called prior
to this, and nothing is getting called. The test app is a very basic MFC
dialog app and there's no way it's causing the problem.

I'm pulling my hair out on this.

Pete


Quote:

> It's hard to tell whether that code is wrong or not. The 'push ecx'
> instruction implicitly subtracts 4 from esp, so that should make
> the 'mov [ebp-4],ecx' quite legal - if a bit pointless.

> Is this an optimized build? If so the problems displaying 'this'
> are, unfortunately, quite common. If it's a debug build, make sure
> you've stepped far enough into the routine for the stack
> frame to be setup - then the de{*filter*} will start displaying
> locals, and this.

> Good luck.


> > I've got a really weird problem. I've got a class that's derived from
CEdit.
> > This class was taken from an old 16-bit project where it worked fine.

> > When the OnSetFocus function is called, the code generated by the
compiler
> > for the function entry is as follows:

> > void QCMaskedEdit::OnSetFocus(CWnd* pOldWnd)
> > {
> >    push ebp
> >    mov  ebp,esp
> >    push ecx
> >    mov dword ptr[ebp-4],ecx
> > ...

> > The problem appears to be that there's no sub esp, xxx following the mov
> > ebp,esp. Or am I wrong about that?

> > My stack frame gets completely screwed up in this function call and it
> > crashes shortly after the return from the function call (it returns to a
> > place far from where it was called from). Inside the function call, if I
try
> > to add 'this' to the watch window, it tells me: 'this' requires a stack
> > frame

> > In my header file, OnSetFocus is defined:

> > afx_msg void OnSetFocus(CWnd* pOldWnd)

> > Does anyone have any idea what the problem is?

> > Thanks.

> > Pete

> --
> .Bruce Dawson, Humongous Entertainment (we're hiring).
> http://www.*-*-*.com/
> Send job applications by e-mail, post technical questions
> to the newsgroups please. Thanks.



Sat, 03 May 2003 03:00:00 GMT  
 Compiler bug?

Have you tried reducing the level of optimisation in your release build?
Try disabling "Frame-Pointer Omission" with /Oy-.
Use the #pragma directive to disable global optimisation in the file which
is giving you problems.
Put
#pragma optimize( "g", off )
somewhere near the top of the file.
Also in your debug builds add /GZ (Catch release-build errors in debug
build) it is very powerful.

Nick

--
Nick Kotarski


Quote:
> It's a release build with debug info, as the problem only shows up here in
> release builds.

> In debug builds, it shows up in a different part of the code. I'm thought
> maybe the class was corruping memory somehow, but I put a breakpoint in
the
> beginning of every public function to see see what was getting called
prior
> to this, and nothing is getting called. The test app is a very basic mfc
> dialog app and there's no way it's causing the problem.

> I'm pulling my hair out on this.

> Pete



> > It's hard to tell whether that code is wrong or not. The 'push ecx'
> > instruction implicitly subtracts 4 from esp, so that should make
> > the 'mov [ebp-4],ecx' quite legal - if a bit pointless.

> > Is this an optimized build? If so the problems displaying 'this'
> > are, unfortunately, quite common. If it's a debug build, make sure
> > you've stepped far enough into the routine for the stack
> > frame to be setup - then the de{*filter*} will start displaying
> > locals, and this.

> > Good luck.


> > > I've got a really weird problem. I've got a class that's derived from
> CEdit.
> > > This class was taken from an old 16-bit project where it worked fine.

> > > When the OnSetFocus function is called, the code generated by the
> compiler
> > > for the function entry is as follows:

> > > void QCMaskedEdit::OnSetFocus(CWnd* pOldWnd)
> > > {
> > >    push ebp
> > >    mov  ebp,esp
> > >    push ecx
> > >    mov dword ptr[ebp-4],ecx
> > > ...

> > > The problem appears to be that there's no sub esp, xxx following the
mov
> > > ebp,esp. Or am I wrong about that?

> > > My stack frame gets completely screwed up in this function call and it
> > > crashes shortly after the return from the function call (it returns to
a
> > > place far from where it was called from). Inside the function call, if
I
> try
> > > to add 'this' to the watch window, it tells me: 'this' requires a
stack
> > > frame

> > > In my header file, OnSetFocus is defined:

> > > afx_msg void OnSetFocus(CWnd* pOldWnd)

> > > Does anyone have any idea what the problem is?

> > > Thanks.

> > > Pete

> > --
> > .Bruce Dawson, Humongous Entertainment (we're hiring).
> > http://www.*-*-*.com/
> > Send job applications by e-mail, post technical questions
> > to the newsgroups please. Thanks.



Sat, 03 May 2003 03:00:00 GMT  
 Compiler bug?
Nick,
   no dice... I had the /GZ in there already. The /Oy- didn't help in debug
or release mode. I get exactly the same errors in exactly the same places...
Thanks for the ideas, though.

Pete


Quote:

> Have you tried reducing the level of optimisation in your release build?
> Try disabling "Frame-Pointer Omission" with /Oy-.
> Use the #pragma directive to disable global optimisation in the file which
> is giving you problems.
> Put
> #pragma optimize( "g", off )
> somewhere near the top of the file.
> Also in your debug builds add /GZ (Catch release-build errors in debug
> build) it is very powerful.

> Nick

> --
> Nick Kotarski



> > It's a release build with debug info, as the problem only shows up here
in
> > release builds.

> > In debug builds, it shows up in a different part of the code. I'm
thought
> > maybe the class was corruping memory somehow, but I put a breakpoint in
> the
> > beginning of every public function to see see what was getting called
> prior
> > to this, and nothing is getting called. The test app is a very basic mfc
> > dialog app and there's no way it's causing the problem.

> > I'm pulling my hair out on this.

> > Pete



> > > It's hard to tell whether that code is wrong or not. The 'push ecx'
> > > instruction implicitly subtracts 4 from esp, so that should make
> > > the 'mov [ebp-4],ecx' quite legal - if a bit pointless.

> > > Is this an optimized build? If so the problems displaying 'this'
> > > are, unfortunately, quite common. If it's a debug build, make sure
> > > you've stepped far enough into the routine for the stack
> > > frame to be setup - then the de{*filter*} will start displaying
> > > locals, and this.

> > > Good luck.


> > > > I've got a really weird problem. I've got a class that's derived
from
> > CEdit.
> > > > This class was taken from an old 16-bit project where it worked
fine.

> > > > When the OnSetFocus function is called, the code generated by the
> > compiler
> > > > for the function entry is as follows:

> > > > void QCMaskedEdit::OnSetFocus(CWnd* pOldWnd)
> > > > {
> > > >    push ebp
> > > >    mov  ebp,esp
> > > >    push ecx
> > > >    mov dword ptr[ebp-4],ecx
> > > > ...

> > > > The problem appears to be that there's no sub esp, xxx following the
> mov
> > > > ebp,esp. Or am I wrong about that?

> > > > My stack frame gets completely screwed up in this function call and
it
> > > > crashes shortly after the return from the function call (it returns
to
> a
> > > > place far from where it was called from). Inside the function call,
if
> I
> > try
> > > > to add 'this' to the watch window, it tells me: 'this' requires a
> stack
> > > > frame

> > > > In my header file, OnSetFocus is defined:

> > > > afx_msg void OnSetFocus(CWnd* pOldWnd)

> > > > Does anyone have any idea what the problem is?

> > > > Thanks.

> > > > Pete

> > > --
> > > .Bruce Dawson, Humongous Entertainment (we're hiring).
> > > http://www.*-*-*.com/
> > > Send job applications by e-mail, post technical questions
> > > to the newsgroups please. Thanks.



Sat, 03 May 2003 03:00:00 GMT  
 Compiler bug?

To get full value from /GZ in MFC builds you need to rebuild
MFC itself with /GZ. I did this and it tracked down some incredibly
subtle type mismatches. It's unfortunate that MS doesn't ship
MFC24D.dll already compiled with /GZ.

Quote:

> Have you tried reducing the level of optimisation in your release build?
> Try disabling "Frame-Pointer Omission" with /Oy-.
> Use the #pragma directive to disable global optimisation in the file which
> is giving you problems.
> Put
> #pragma optimize( "g", off )
> somewhere near the top of the file.
> Also in your debug builds add /GZ (Catch release-build errors in debug
> build) it is very powerful.

> Nick

> --
> Nick Kotarski



> > It's a release build with debug info, as the problem only shows up here in
> > release builds.

> > In debug builds, it shows up in a different part of the code. I'm thought
> > maybe the class was corruping memory somehow, but I put a breakpoint in
> the
> > beginning of every public function to see see what was getting called
> prior
> > to this, and nothing is getting called. The test app is a very basic mfc
> > dialog app and there's no way it's causing the problem.

> > I'm pulling my hair out on this.

> > Pete



> > > It's hard to tell whether that code is wrong or not. The 'push ecx'
> > > instruction implicitly subtracts 4 from esp, so that should make
> > > the 'mov [ebp-4],ecx' quite legal - if a bit pointless.

> > > Is this an optimized build? If so the problems displaying 'this'
> > > are, unfortunately, quite common. If it's a debug build, make sure
> > > you've stepped far enough into the routine for the stack
> > > frame to be setup - then the de{*filter*} will start displaying
> > > locals, and this.

> > > Good luck.


> > > > I've got a really weird problem. I've got a class that's derived from
> > CEdit.
> > > > This class was taken from an old 16-bit project where it worked fine.

> > > > When the OnSetFocus function is called, the code generated by the
> > compiler
> > > > for the function entry is as follows:

> > > > void QCMaskedEdit::OnSetFocus(CWnd* pOldWnd)
> > > > {
> > > >    push ebp
> > > >    mov  ebp,esp
> > > >    push ecx
> > > >    mov dword ptr[ebp-4],ecx
> > > > ...

> > > > The problem appears to be that there's no sub esp, xxx following the
> mov
> > > > ebp,esp. Or am I wrong about that?

> > > > My stack frame gets completely screwed up in this function call and it
> > > > crashes shortly after the return from the function call (it returns to
> a
> > > > place far from where it was called from). Inside the function call, if
> I
> > try
> > > > to add 'this' to the watch window, it tells me: 'this' requires a
> stack
> > > > frame

> > > > In my header file, OnSetFocus is defined:

> > > > afx_msg void OnSetFocus(CWnd* pOldWnd)

> > > > Does anyone have any idea what the problem is?

> > > > Thanks.

> > > > Pete

> > > --
> > > .Bruce Dawson, Humongous Entertainment (we're hiring).
> > > http://www.*-*-*.com/
> > > Send job applications by e-mail, post technical questions
> > > to the newsgroups please. Thanks.

--
.Bruce Dawson, Humongous Entertainment (we're hiring).
http://www.*-*-*.com/
Send job applications by e-mail, post technical questions
to the newsgroups please. Thanks.


Sat, 03 May 2003 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. please help: code bug or compiler bug?

2. midl compiler bug - msado15.idl

3. c# compiler bug (a real one this time)

4. compiler bug

5. VC++ 2003 compiler bug

6. MSVC compiler bug [?] - private constructor called illegaly

7. Compiler bug?

8. C++ compiler bug?

9. Compiler bug when mixing managed and unmanaged code

10. VC7 adds a new twist to an old C++ compiler bug

11. compiler bug: destructor for temporary in constructor initializer never called

12. Compiler bug: pointer conversions from relational operator

 

 
Powered by phpBB® Forum Software