delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/02/05:43:37

From: "Damian Yerrick" <die DOT spammers AT pineight DOT 8m DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Solved! (Re: Pentium "General Protection Fault")
Date: Thu, 2 Sep 1999 00:07:46 -0500
Organization: Rose-Hulman Institute of Technology
Lines: 53
Message-ID: <7ql0qv$55i$1@solomon.cs.rose-hulman.edu>
References: <7qhbnp$3rp$1 AT samba DOT rahul DOT net> <7qja6k$gi4$1 AT samba DOT rahul DOT net> <7qjgcl$hmt$1 AT samba DOT rahul DOT net>
NNTP-Posting-Host: yerricde.laptop.rose-hulman.edu
X-Trace: solomon.cs.rose-hulman.edu 936248991 5298 137.112.205.154 (2 Sep 1999 05:09:51 GMT)
X-Complaints-To: news AT cs DOT rose-hulman DOT edu
NNTP-Posting-Date: 2 Sep 1999 05:09:51 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

to comp.os.msdos.djgpp <axlq AT unicorn DOT us DOT com> wrote in message
news:7qjgcl$hmt$1 AT samba DOT rahul DOT net...
> Problem solved!  Thanks Eli, who told me about symify, and thanks
> Michael, who shared his identical experience, and the solution:
>
> From: Michael Bukin <M DOT A DOT Bukin AT inp DOT nsk DOT su>
> Date: 01 Sep 1999 21:13:35 +0700
>
> I recall that I had similar problem while porting one application.
> Implementation of malloc in djgpp-2.02 defines global array "freelist"
> which keeps some internal state of malloc.  If you have the same
> global symbol in your code, your program may crash when malloc
> dereference this array.

DJ, another solution is for the next DJGPP release's malloc()
to keep its freelist in some global upon which the average
programmer is not likely to stumble:

FooRec *_malloc_freelist;

> One solution is to replace all references to global symbol "freelist"
> in your code with something else, or make "freelist" static.  If you
> don't have global symbol "freelist", then, IIRC, there are other
> global symbols defined in malloc.

A way to avoid global variable conflicts, borrowed from Macintosh
programming books, is to name all your globals starting with a g:

int gFoo;
int gFreelist;

Another technique, which I used in DOSArena, is to
place all your global data in a structure:

typedef struct Globals
{
  int foo;
} Globals;

Globals g;

int bar(void)
{
  g.foo = 1;
}

A C++ variation on this technique also allows multiple instances.

Damian Yerrick
http://come.to/yerrick


- Raw text -


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