delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/28/01:48:16

From: "Charles Sandmann" <sandmann AT clio DOT rice DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Segments vs Selectors
Date: Fri, 26 Sep 1997 23:34:16
Organization: Aspen Technology, Inc.
Lines: 12
Message-ID: <342c4678.sandmann@clio.rice.edu>
References: <Pine DOT LNX DOT 3 DOT 91 DOT 970926044706 DOT 578A-100000 AT aditya DOT unigoa DOT ernet DOT in>
Reply-To: sandmann AT clio DOT rice DOT edu
NNTP-Posting-Host: dmcap2.dmccorp.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> my program as soon as I dereference a byte above segment limit
> (obtained from ___dpmi_get_segment_limit(...)). But this does 
> not happen! It is only when I dereference 64K *above* the stated
> segment limit that my program trashes. What is happening here?

You get the limit.
You call printf, which internally allocates memory, which calls sbrk,
  which increases the memory from DPMI and increases the limit 64K.
You try to touch the memory, which is now valid after the print.

Change the order of your calls.  Put a print statement first, then
get the limit AFTER the print statement, and try it.

- Raw text -


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