www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/01/31/03:33:49

To: djgpp AT sun DOT soe DOT clarkson DOT edu, raju AT xgroup DOT ernet DOT in
Subject: go32 crashes, fstream problems
From: rishab AT dxm DOT ernet DOT in (RISHAB GHOSH)
Date: Tue, 25 Jan 94 01:08:56 IST
Organization: Deus X Machina


I am using DJGPP 1.11 with maint 2, and gcc/gpp 2.5.7.

1. GO32 crash ----------------------------------------

When I compiled and ran a program that's been giving a lot of trouble, this 
is what go32 said:

MM>go32 testprog		// already compiled with no errors
go32 version 1.11.maint2 Copyright (C) 1993 DJ Delorie
General Protection Fault at eip=810e
eax=00000020 ebx=00054004 ecx=0005a974 edx=00006970 esi=5f002e64 edi=00000006
ebp=00051c1c esp=00051bf4 cs=af ds=a7 es=a7 fs=a7 gs=bf ss=b7 cr2=00001fe5
Call frame traceback EIPs:
  0x0000810e
  0x0000227c
  0x00001ff0
  0x0000148a
  0x0000188e
          

This was from a DOS box under Windows 3.1, but when I tried it outside Windows
I got a similar error, though the register values might have been different.
The only memory manager I am using is HIMEM.SYS. No fancy TSR's, no Stacker 
etc.

This is happening with many (simple) programs. The story of this problem:

2. FSTREAM problems ------------------------------------------

This program and a set of other tests did very strange things when using
fstream::tellg(), tellp(), seekg(), seekp().

With DJGPP 1.10 and gcc/gpp 2.4.1, seek after a tell jumped to EOF, skipped
back and forth, and generally behaved madly. As other things (iomanip.h) didn't
work either, I waited for the next release.

After I got gcc 2.5.4 I read in the g++ faq that 2.5.x with x < 5 was bugged
in the c++ implementation. By that time 2.5.7 was out, but needed maint go32.
Now with go32 1.11maint2 and 2.5.7 iomanip.h is complete, but the fstream 
programs crash on run-time.

Since my major task at the moment is evaluating DJGPP for use by some C++
students, I haven't had the time to play around with other types of programs -
I am trying to get this and similar ones to work.


Here is the source code for testprog

-----------------------

#include <fstream.h>

class Drugs
{
private:
	unsigned int batchNo;
	char drugCode[5];
	char category;
	char units[4];
	float qtyProduced;

	void getdata(void)
	{
		cout<<"\n Enter Batch Number : ";
		cin>>batchNo;
		cout<<"\n Enter Drug Code : ";
		cin>>drugCode;
		cout<<"\n Enter Category : ";
		cin>>category;
		cout<<"\n Enter Unit Of Measurement : ";
		cin>>units;
		cout<<"\n Enter Quantity Produced : ";
		cin>>qtyProduced;
	}

	void showdata(void)
	{
		cout<<"\n ****** DISPLAYING RECORD ******";
		cout<<"\n The Batch Number is "<<batchNo
		    <<"\n The Drug Code is "<<drugCode
		    <<"\n The Category is "<<category
		    <<"\n The UOM is "<<units
		    <<"\n The Quantity Produced is "<<qtyProduced;
	}

public:
	void diskOut(void);
	void diskIn(void);
};
//--------------------------------------------------------------
	void Drugs::diskOut(void)
	{
		fstream ofile("DRUGS.DAT", ios::app);
		char reply;
		cout<< "\n" <<ofile.tellg();
		cout<< "\n" <<ofile.tellp();
		do
		{
			getdata();
			ofile.write((char *)this, sizeof(*this));
			cout<< "\n" <<ofile.tellg();
			cout<< "\n" <<ofile.tellp();
			cout<<"\n Any more records (y/n)? ";
			cin>>reply;
		}while(reply=='y');
		cout<< "\n" <<ofile.tellg();
		cout<< "\n" <<ofile.tellp();
	}

	void Drugs::diskIn(void)
	{
		fstream ifile("DRUGS.DAT", ios::in);
		cout<< "\n" <<ifile.tellg();
		cout<< "\n" <<ifile.tellp();
		ifile.read((char *)this, sizeof(*this));
		cout<< "\n" <<ifile.tellg();
		cout<< "\n" <<ifile.tellp();
		while (ifile)
		{
			showdata();
			ifile.read((char *)this, sizeof(*this));
			cout<< "\n" <<ifile.tellg();
			cout<< "\n" <<ifile.tellp();
		}
		cout<< "\n" <<ifile.tellg();
		cout<< "\n" <<ifile.tellp();
	}
//--------------------------------------------------------------------
void main(void)
{
	Drugs drugobj;
	//get data and write to file
	drugobj.diskOut();
	//read file and display records
	drugobj.diskIn();
}

-------------EOF-----------------------------

Hope someone can help me, and sorry for this massive mail.

Rishab


-----------------------------------------------------------------------
Rishab Aiyer Ghosh                            "What is civilisation
rishab AT doe DOT ernet DOT in, rishab AT dxm DOT ernet DOT in        but a ribonucleic
Voicemail +91 11 3760335; Vox/Fax/Data 6853410      hangover?"
H-34C Saket New Delhi 110017 INDIA
-----------------------------------------------------------------------

- Raw text -


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