Mail Archives: djgpp/1997/01/28/12:01:45
Linley Henzell <zel AT olis DOT net DOT au> wrote:
>Ruiter de M wrote:
>>
>> Linley Henzell (zel AT olis DOT net DOT au) wrote:
>> : Well, I'm having some problems with a C program written with Borland C++
>> : 3.1 which refuses to work with DJGPP v2. It compiles fine, but every
>> : time I run it, it aborts with a SIGSEGV GPF. I have no idea why this
[snip]
>> : Borland's compiler has no problems whatsoever with it, and I've rarely
>> : had any problems with BC++. If anybody knows about something which
>> : Borland C++ 3.1 copes with, but which DJGPP just doesn't like, I would
>> : really appreciate them letting me know so that I can remove it from my
>> : program! Any assistance in this problem would be greatly appreciated.
This is a typical symptom of NULL and uninitialized pointers. Real mode
DOS programs (as compiled by Borland) don't care where your pointers are
pointing when you try to use them, but in protected mode you'll generate
a segmentation violation (SIGSEGV) if you try to access memory that you
don't own. This includes memory address 0, commonly called 'NULL' or 'NIL'.
>I eventually found the problem by hacking chunks of code from my source
>until it worked. Because the program crashed at apparently innocuous
>places, the printf debugging method (which I usually use) wasn't much
>help, but I finally managed to isolate my problem to a call to atoi. For
>some reason, djgpp just doesn't seem to like my programs calling this
>function. And I am using v2; is this one of its documented bugs?
Hmm... atoi() takes a pointer. I'll bet a box of 360k diskettes that
the pointer is either NULL or points to memory that you never allocated.
-- Dave Cigna
- Raw text -