www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2008/10/07/00:01:41

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
NNTP-Posting-Date: Mon, 06 Oct 2008 22:53:03 -0500
From: "Charles Sandmann" <cwsdpmi AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
References: <gcbnih$6pq$1 AT aioe DOT org>
Subject: Re: failure of __dpmi_set_segment_limit() problem
Date: Mon, 6 Oct 2008 22:52:55 -0500
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
X-RFC2646: Format=Flowed; Original
Message-ID: <MOadnT7eV5OCQHfVnZ2dnUVZ_g6dnZ2d@earthlink.com>
Lines: 45
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 64.91.192.48
X-Trace: sv3-OoRifM8sHZ+WS5vNnJC6/bo0DEw0pxBW0XGcz7CVXpXsY6exAsYQ/D7V4mZBgW/djt1wKOrqooPJ5Ws!FtWhmrp5zYo6E0yqjw/ZFNe0tKdXrlopAS1D4UsgQH7VjFori2eCq5tS0cvfpBseIKAdoYsgVCvm!bsJoNwDaMMFwZPjaROWGUTCAOHpYotg=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.39
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Rod Pemberton" <do_not_have AT nohavenot DOT cmm> wrote in message 
news:gcbnih$6pq$1 AT aioe DOT org...
>
> I added some *inactive* code to a routine in a program I was working on 
> when
> it began faulting in main().  I traced the problem to
> __dpmi_set_segment_limit() from the fault info.  The limit hadn't been
> changed.  __dpmi_set_segment_limit wasn't returning an error code either.
> The problem appears as __dpmi_set_segment_limit() working at first, but 
> then
> the selector limit is being reset to its pre-call value.  I.e., two
> back-to-back calls to __dpmi_get_segment_limit return two different 
> values,
> sometimes.  The following C code represents the issue, but won't run as is
> since it doesn't align main() properly.  The assembly code below has been
> adjusted (.space 0x7167) for the missing code and will need to be compiled
> as "gcc -o test.exe test.s".  I've tested this under RM MS-DOS v7.10 
> w/DJGPP
> v2.03 (GCC 3.4.1), DJGPP v2.04 (GCC 4.1.0), CWSDPMI v5 old and new, 
> CWSDPMI
> three 6b versions, PMODETSR, etc.  All combinations I've tried fail.  I'm
> not sure why this only happens under these circumstances.  Am I doing
> something wrong?  Any help?

Under my old toolkit (v2.03) I can't reproduce the problem, compiling the .s 
file.  I
suppose it's possible your toolchain makes a slightly different .exe ?

There is some code in crt0.S IIRC that messes with limits when dealing with 
sbrk() expansion,
it's possible that a malloc() call in the first printf() reset the limit. 
It's been a long time, and
I have a hard time remembering details this obscure, but it's possible that 
since the normal
startup code calls malloc(), if you bypass the normal startup you might need 
to reset the
limit after the first call to sbrk(), or to use the crt0 flag to 
automatically make it big-wrap.
At least it's someplace to start looking.

Have you tried stepping through it at an assembly instruction level with a 
debugger, looking
for the DPMI segment limit change call?


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019