flat assembler
Message board for the users of flat assembler.

Index > Windows > Error on a perfectly valid FLD

Author
Thread Post new topic Reply to topic
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
This error occured on Windows, dunno whether it is specific to it.

I am recieving a "FPU stack error" on an FLD of a doubleword 100.0. I checked OllyDbg, and the stack has 6 empty spots. What is wrong?


Description: olly screenshot
[value 100.0 in data dump is selected]
Filesize: 29.24 KB
Viewed: 1041 Time(s)

huh.png



_________________
This calls for... Ultra CRUNCHY Man!
Ta da!! *crunch*
Post 14 Oct 2006, 01:33
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
The problem is not a because of a stack overflow during that instruction you highlight. Note that you enable all exception. What can happen is that there is a stack overflow previously before all exceptions are enabled, then exceptions are enabled and you subsequently get another fault (precision or operation error). Ollydbg cannot determine what the exact reason for the fault is because the SF bit is still set.
IA-32 Intel® Architecture
Software Developer’s Manual, Volume 1: Basic Architecture: 8.5.1 Invalid Operation Exception wrote:
The flag for this exception (IE) is bit 0 of the x87 FPU status word, and the mask bit (IM) is bit 0 of the x87 FPU control word. The stack fault flag (SF) of the x87 FPU status word indicates the type of operation that caused the exception. When the SF flag is set to 1, a stack operation has resulted in stack overflow or underflow; when the flag is cleared to 0, an arithmetic instruction has encountered an invalid operand. Note that the x87 FPU explicitly sets the SF flag when it detects a stack overflow or underflow condition, but it does not explicitly clear the flag when it detects an invalid-arithmetic-operand condition. As a result, the state of the SF flag can be 1 following an invalid-arithmetic-operation exception, if it was not cleared from the last time a stack overflow or underflow condition occurred. See Section 8.1.3.4, “Stack Fault Flag,” for more information about the SF flag.
Clear all pre-existing exceptions before disabling the masks, else pre-existing SF faults will confuse Ollydbg (and other debuggers).
Post 14 Oct 2006, 03:19
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
I forgot to mention that previous faults are not detected until the attempted execution of the next FPU instruction. You can see this happening here:
Code:
finit
fstp    st0     ;<-- stack overflow here
fstcw   [var]
and     [var],0xffc0
fldcw   [var]
fld1            ;<-- exception generated here    
Post 14 Oct 2006, 03:28
View user's profile Send private message Visit poster's website Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
imho, it's problems in ollydbg
Post 14 Oct 2006, 12:52
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
Thanks for the help, I have tracked down the problem now (a few FXCH's with non-existent values.)
Post 15 Oct 2006, 00:11
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.