Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fwd: BUGREPORT: ___dpmi_get_raw_mode_switch_addr() modifies SI register and doesn't save it

26 views
Skip to first unread message

Ozkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com]

unread,
Aug 2, 2022, 3:08:01 AM8/2/22
to dj...@delorie.com
The 'djgpp' mailing list is more active - forwarding this to it:

---------- Forwarded message ----------
From: "lostxwind (lost...@163.com) [via djgpp-...@delorie.com]"
<djgpp-...@delorie.com>
Date: Mon, 1 Aug 2022 06:12:26 +0800 (CST)
Subject: Re:BUGREPORT: ___dpmi_get_raw_mode_switch_addr() modifies SI
register and doesn't save it
To: djgpp-...@delorie.com

Hi,

I was trying to issue a bug report on delorie official site
(https://www.delorie.com/djgpp/bugs/create.cgi) but failed as the
database is closed. So I tried to contact you through email.

BUGREPROT:

BACKGROUND:
___dpmi_get_raw_mode_switch_addr() is needed to switch modes for some
reason, instead of the __dpmi_simulate_real_mode_* class.
SYMPTOM:
Random crashes involving switch between real(/v86) mode and protected mode.
REASON:
I found variables or function parameters corrupted after calling
___dpmi_get_raw_mode_switch_addr().
After reading the source code, I believe that the implementation of
___dpmi_get_raw_mode_switch_addr() has missed a single line that saves
the ESI register.
src\libc\dpmi\api\d0306.S, line 2-line 4.

code before fix:
#define USE_EBX
#define USE_EDI
#include "dpmidefs.h"

possible fix:
#define USE_EBX
#define USE_EDI
#define USE_ESI
#include "dpmidefs.h"

Current workaround without bugfix:
Write a alternative implementation;
Or wrap the function call with asm that pushl/popl %esi.

Thanks,
crazii

Stefan Ring

unread,
Aug 6, 2022, 11:52:21 AM8/6/22
to
> src\libc\dpmi\api\d0306.S, line 2-line 4.
>
> code before fix:
> #define USE_EBX
> #define USE_EDI
> #include "dpmidefs.h"
>
> possible fix:
> #define USE_EBX
> #define USE_EDI
> #define USE_ESI
> #include "dpmidefs.h"

Yes, looks very reasonable, given that the DPMI call explicitly changes (e)si.

Ozkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com]

unread,
Aug 7, 2022, 12:17:56 AM8/7/22
to dj...@delorie.com
On 8/6/22, Stefan Ring (stef...@gmail.com) [via dj...@delorie.com]
OK then, is the following patch OK to apply?

___dpmi_get_raw_mode_switch_addr: push/pop esi.

Reference issue:
https://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp/2022/08/02/03:07:56

Index: src/libc/dpmi/api/d0306.S
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dpmi/api/d0306.S,v
retrieving revision 1.1
diff -u -p -r1.1 d0306.S
--- src/libc/dpmi/api/d0306.S 12 Mar 1995 04:52:56 -0000 1.1
+++ src/libc/dpmi/api/d0306.S 7 Aug 2022 04:08:36 -0000
@@ -1,6 +1,7 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#define USE_EBX
#define USE_EDI
+#define USE_ESI
#include "dpmidefs.h"

.text

Eli Zaretskii (eliz@gnu.org) [via djgpp@delorie.com]

unread,
Aug 7, 2022, 1:28:33 AM8/7/22
to dj...@delorie.com
> From: "Ozkan Sezer (sez...@gmail.com) [via dj...@delorie.com]" <dj...@delorie.com>
> Date: Sun, 7 Aug 2022 07:14:22 +0300
>
> On 8/6/22, Stefan Ring (stef...@gmail.com) [via dj...@delorie.com]
> <dj...@delorie.com> wrote:
> >> src\libc\dpmi\api\d0306.S, line 2-line 4.
> >>
> >> code before fix:
> >> #define USE_EBX
> >> #define USE_EDI
> >> #include "dpmidefs.h"
> >>
> >> possible fix:
> >> #define USE_EBX
> >> #define USE_EDI
> >> #define USE_ESI
> >> #include "dpmidefs.h"
> >
> > Yes, looks very reasonable, given that the DPMI call explicitly changes
> > (e)si.
>
> OK then, is the following patch OK to apply?

Yes, thanks.

Ozkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com]

unread,
Aug 7, 2022, 1:42:15 AM8/7/22
to dj...@delorie.com
0 new messages