[fpc-devel] Re: Exception handler under Go32V2 and NT-system

borsa77 at libero.it borsa77 at libero.it
Thu Apr 24 15:17:40 CEST 2008

On 23 Apr 2008 at 3:15, Tomas Hajny wrote:

> I'm sorry, but I'm not clear about the conclusion of all of this. If you
> aim to have something changed in the GO32v2 code, I'd need a clear
> reproducible scenario of what doesn't work before the proposed change and
> gets fixed by the proposed change,

It's not easy to search for a smoking gun exploit, either as I start from the 
source and as a bug that arises from a real mode exception instead of 
protected mode is dependant by the around conditions. However I tried an 
attempt to compile the symify.pp and the ide with the debug bind (which 
work massively with the signals), but both the cases fail the final link 
because of a lot of missing variable or function references in the gdblib 
(does you know what is the correct version? I downloaded the v6.1.1 from 
the fpc ftp site). Despite of this, I withdraw on focuses to the calculator of 
the ide (which uses the floating point unit exception) and in occurring the 
zero division error. Does anyone have experienced an hang or crash in 
such way on a NT-machine? To me it behaves good.

> or comprehensible clarification why the
> current code is wrong and your proposed version is not (taking into
> account that the person who wrote the code probably won't be able to
> comment on this, so your clarification must be comprehensible even to
> somebody who doesn't know the particular code at all).

Then I respawn from principle. In the dpmiexcp.pp file the
djgpp_exception_toggle procedure sets the handler for a range of
execptions. At a first glance it try to use a protected mode one by taking the
address of the interrupt via 0x210 service (get_pm_exception_handler
function) and checking the result of the operation via carryflag (test_int31
procedure). If that fails, it fallbacks into real mode. In the test_int31 the flag
is not passed explicity as a parameter but pushed on the stack:

            call test_int31

In the djgpp_exception_toggle there's a comment:

     { Windows 2000 seems to not set carryflag on func 0x210 :( PM }

and a line that make the trick:

     if (_os_trueversion <> $532) and get_pm_exception_handler(i,_except) then

but I have the strong suspect that in this case Windows is blamed for
nothing. Indeed, as you can see in the r152, where it is added the stdcall
declaration to the  test_int31 to deal proper with the flag parameter, the
above workaround was previous present. So I removed the chunk:

(_os_trueversion <> $532)

that prevents NT-system to use protected mode handler even if it can, and
as a result all the call to the signal(arg1,arg2) procedure in the compiler
code requires a more strictly compliance in the 2nd argument: the
declaration of the funtion or procedure whose address is there passed must
includes the correct statement, i.e. cdecl.


More information about the fpc-devel mailing list