www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/12/20/22:34:58

Date: Wed, 20 Dec 1995 22:25:32 -0500 (EST)
From: Denis P Dersarkisian <denis AT oitunix DOT oit DOT umass DOT edu>
Subject: problem running C++ program
To: djgpp AT sun DOT soe DOT clarkson DOT edu

Hi everyone.  I've been having a problem running a C++ program that I've
written. It compiles and links with no real problems. When I run it, though,
I get this...

go32 test2
go32 version 1.12.maint3 Copyright (C) 1994 DJ Delorie
About to init vars
done, returning...
Segmentation violation in pointer 0x00000000 at d8:2298
eax=00000000 ebx=00007024 ecx=7fffe710 edx=7fffe753 esi=7ffffc68 edi=00000008
ebp=7fffe6ac esp=7fffe6a4 cs=d8 ds=48 es=48 fs=48 gs=38 ss=48 cr2=00000000
Call frame traceback EIPs:
  0x00002298
  0x00001694
  0x000024e6

The "about to init vars" and "done, returning" messages are made by printf's
I stuck in the program to help me find where the crash was occuring.  And
I have found approximately where the program's crashing.  My problem is I
still have absolutely no idea WHY it's crashing here.

My program's main module starts out like so:

void main()
{    /* line 417 */
  Int9 NewKBHandler;
  printf("NewKBHandler successfully created\n");
  ...etc.

As you can see from the sample run I've included above, "NewKBHandler
successfully created" is never printed, so the crash occurs somewhere in
the constructor for the Int9 class.  Here's that constructor...

Int9::Int9()
{
  int counter;
  IRQnumber = 9;
  for (counter=0; counter++; counter<sizeof(keypressed))
    keypressed[counter] = 0;     /* line 54 */
  printf("About to init vars\n");
  e0flag = e1counter = 0;
  printf("done, returning...\n");
}

Here's the class definition for Int9:

class Int9: public IntHandler {
  public:
    Int9();
    Buffer<unsigned> KBbuffer;
    unsigned getkp();
  protected:
    virtual void handler();
    volatile unsigned char keypressed[256];
  private:
    volatile unsigned KBcode;
    volatile unsigned char e0flag, e1counter;
};

And here's the class definition for Int9's base class:

class IntHandler {
  public:
    void install();
    void remove();
  protected:
    virtual void handler() = 0;
    int IRQnumber;    //must be set by derived classes' constructors
  private:
    _go32_dpmi_seginfo oldRMint, newRMint, oldPMint, newPMint;
    _go32_dpmi_registers RMregs;
    unsigned char installed;        //true if handler()'s installed
};

It might seem from the above that the crash occurs during the return from
Int9's constructor.  However, at one point there were another couple of printf
statements in the constructor, and it crashed before reaching the
printf("done, returning...\n"); line.

When the program was compiled without any switches, there were no warnings or
errors shown.  However, when I compiled it with -Wall, I got a few warnings.

#1:
test2.cpp: At top level:
test2.cpp:417: warning: return type for `main' changed to integer type

Line 417 is marked in the main() code fragment above.

#2:
keyboard.cpp: In method `Int9::Int9()':
keyboard.cpp:54: warning: statement with no effect

Line 54 is marked in the Int9() code fragment.

I got a couple of other statement with no effect warnings, but they were in
completely different parts of the program and were all for lines with nothing
but {'s on them.

This crash has completely stumped me, so I certainly hope that someone on the
mailing list can help me.  I'm not sure if any of the warnings I got are related
to the crash (I've got no idea on how fix the program so the warnings don't
appear, anyway.)  I'm also not sure if you need to know my system configuration
to give me advice, but just in case I've included it below.  I couldn't for
the life of me see what was on go32's topline at the moment of crash because
the topline vanishes as soon as the crash occurs (is there any way to pipe the
topline to a file or something?)
Well anyway, my e-mail address is denis AT twain DOT oit DOT umass DOT edu.  Thanks for any
help that you all can give me.


This is my environ.lst:

CONFIG=X
COMSPEC=C:\NU\NDOS.COM
CMDLINE=faq
PATH=C:\DOS;C:\NU;C:\DJGPP\BIN;C:\WINDOWS;C:\NDW;C:\ZM;C:\ZM\ZIP;C:\QEDIT;C:\W;C:\DOS\2M30
TEMP=c:\windows\temp
DJGPP=c:\djgpp\djgpp.env
TMPDIR=c:\tmp
GO32=driver c:\djgpp\drivers\genoa.grd gw 1024 gh 768 topline
PROMPT=$e[0;37;1m$P$g$e[0;34;1m

This is what was printed when I ran go32 with no parameters:

Script V1.1 session started Wed Dec 20 21:13:46 1995
go32 version 1.12.maint3 Copyright (C) 1994 DJ Delorie
Lowest version I can run is 1.08
go32.exe usage: go32 [-d {debugger}] [{program} [{options} . . . ]]
go32.exe build time was Sun Dec 18 16:36:42 1994
XMS memory available: 3156 Kb
Swap space available: 10464 Kb
Script completed Wed Dec 20 21:13:46 1995

This is my autoexec.bat:

@echo off
path c:\dos;c:\nu;c:\djgpp\bin;c:\windows;c:\ndw;c:\zm;c:\zm\zip;c:\qedit;c:\w;c:\dos\2m30
nav c:\
set temp=c:\windows\temp
set djgpp=c:\djgpp\djgpp.env
set tmpdir=c:\tmp
set go32=driver c:\djgpp\drivers\genoa.grd gw 1024 gh 768 topline
prompt $e[0;37;1m$P$g$e[0;34;1m
alias /r alias.lst
c:\nu\image c: /noback
c:\nu\smartcan /on /skiphigh

This is my config.sys:

device=c:\dos\himem.sys
dos=high,umb
devicehigh=c:\ndw\nav&.sys /b
devicehigh=c:\dos\ansi.sys
files=30
buffers=40
stacks=9,256
shell=c:\nu\ndos.com @c:\nu\ndos.ini /e:1024 /p
devicehigh=c:\dos\ppr.sys

This is what gcc printed when I compiled the program's various parts and
linked them:

gcc -g -v -Wall -c test2.cpp
Reading specs from c:/djgpp/lib\specs
gcc version 2.6.3
 c:/djgpp/bin\cpp.exe -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=6 -Dunix -Di386 -DGO32 -DMSDOS -D__unix__ -D__i386__ -D__GO32__ -D__MSDOS__ -D__unix -D__i386 -D__GO32 -D__MSDOS -g -Wall test2.cpp c:\tmp\cc000089
GNU CPP version 2.6.3 (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
 c:/djgpp/cplusinc
 c:/djgpp/include
 /usr/local/lib/g++-include
 /usr/local/include
 /usr/local/go32/include
 /usr/local/lib/gcc-lib/go32/2.6.1/include
 /usr/include
End of search list.
 c:/djgpp/bin\cc1plus.exe c:\tmp\cc000089 -quiet -dumpbase test2.cc -g -Wall -version -o c:\tmp\cca00089
GNU C++ version 2.6.3 (80386, BSD syntax) compiled by GNU C version 2.6.3.
test2.h: In method `void Window::ClearWindow()':
In file included from test2.cpp:9:
test2.h:65: warning: statement with no effect
test2.cpp: At top level:
test2.cpp:417: warning: return type for `main' changed to integer type
 c:/djgpp/bin\as.exe -o test2.o c:\tmp\cca00089

gcc -g -v -Wall -c keyboard.cpp
Reading specs from c:/djgpp/lib\specs
gcc version 2.6.3
 c:/djgpp/bin\cpp.exe -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=6 -Dunix -Di386 -DGO32 -DMSDOS -D__unix__ -D__i386__ -D__GO32__ -D__MSDOS__ -D__unix -D__i386 -D__GO32 -D__MSDOS -g -Wall keyboard.cpp c:\tmp\cc000089
GNU CPP version 2.6.3 (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
 c:/djgpp/cplusinc
 c:/djgpp/include
 /usr/local/lib/g++-include
 /usr/local/include
 /usr/local/go32/include
 /usr/local/lib/gcc-lib/go32/2.6.1/include
 /usr/include
End of search list.
 c:/djgpp/bin\cc1plus.exe c:\tmp\cc000089 -quiet -dumpbase keyboard.cc -g -Wall -version -o c:\tmp\cca00089
GNU C++ version 2.6.3 (80386, BSD syntax) compiled by GNU C version 2.6.3.
keyboard.cpp: In method `Int9::Int9()':
keyboard.cpp:54: warning: statement with no effect
 c:/djgpp/bin\as.exe -o keyboard.o c:\tmp\cca00089

gcc -g -v -Wall -o test2 test2.o keyboard.o -lpc
Reading specs from c:/djgpp/lib\specs
gcc version 2.6.3
 c:/djgpp/bin\ld.exe -o test2 c:/djgpp/lib\crt0.o -Lc:/djgpp/lib test2.o keyboard.o -lpc -lgcc -lg -lc -lgcc

- Raw text -


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