X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "Rod Pemberton" Newsgroups: comp.os.msdos.djgpp Subject: Re: failure of __dpmi_set_segment_limit() problem Date: Wed, 22 Oct 2008 08:07:19 -0400 Organization: Aioe.org NNTP Server Lines: 37 Message-ID: References: NNTP-Posting-Host: mQokHQeKeRC37oD/Mq9UYg.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse AT aioe DOT org NNTP-Posting-Date: Wed, 22 Oct 2008 12:07:59 +0000 (UTC) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1933 X-Newsreader: Microsoft Outlook Express 6.00.2800.1933 X-Priority: 3 X-MSMail-Priority: Normal To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Rod Pemberton" wrote in message news:gdmej0$ije$1 AT aioe DOT org... > "Charles Sandmann" wrote in message > news:t7Wdna5FmpsFEGPVnZ2dnUVZ_oPinZ2d AT earthlink DOT com... > > You are not flagging to sbrk() that you have changed the segment limit; so > > when you call anything which calls sbrk() that requires it resize the > memory > > it resets the limit. Don't set the limit to -1 manually, call > > _djgpp_nearptr_enable instead or look at it's source to see which flags > need > > setting. There are some old FAQ and usenet articles about this if you > > search long enough..., but the easy thing is to call the libc function. > > > > Thanks. Maybe it's just me, but I'd consider that to be bug in sbrk()... > the limit is already maxed. Yes, this program doesn't specifically need > that method and could use _djgpp_nearptr_enable. So, using __djgpp_nearptr_enable() should fix it then? Yes for ds. But, the call fails to set cs. The call does fix ds, but then it fails to set cs. Normally, both limits for cs and ds are set to 0xFFFFFFFF (or -1) by __djgpp_nearptr_enable(). However, with this problem code, cs doesn't get set to -1 by __djgpp_nearptr_enable() or it's being reset... The call does fix ds though, as does enabling _CRT0_FLAG_NEARPTR in _crt0_startup_flags or setting ___djgpp_selector_limit to -1 in assembly. I think something more is going on here. Setting some DOS var's shouldn't have any affect, but does. v2.04 is consistent, while v2.03 isn't. In my mind, the selectors are being corrupted or reset or there is a memory allocation error due to a boundary condition or calculation, etc. Rod Pemberton