www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/06/24/18:02:24

Xref: news-dnh.mv.net comp.os.msdos.djgpp:564
Newsgroups: comp.os.msdos.djgpp
Path: news-dnh.mv.net!mv!news.sprintlink.net!cam.news.pipex.net!pipex!edi.news.pipex.net!pipex!sunsite.doc.ic.ac.uk!cs.city.ac.uk!city!sl323
From: sl323 AT city DOT ac DOT uk (Mark Lewis)
Subject: Bug: read( in 1.12m4 (?)
Sender: news AT city DOT ac DOT uk (Unix Network News)
Nntp-Posting-Host: exeter
Reply-To: M DOT Lewis AT city DOT ac DOT uk
Organization: The City University
Date: Sat, 24 Jun 95 18:58:35 GMT
Lines: 84
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

HELP !  I've managed to get this go32 error from a simple bit of code.

Apologies for the ridiculously stupid nature of the code; I've been using it
to test low-level I/O stuff since I've been having problems with some real
code crashing and burning badly for no apparent reason.  Looks like read()
could be the problem, but fixing this is beyond me.

I've appended the error message and the test code that produced it.  Compile
with 'gcc $(CFLAGS) test.c test2.c'.  I'd be happy to send the real code
that's causing me problems to anyone who's interested, but it's considerably
bigger!  It doesn't give a nice error like this either -- just crashes out
during a read() call with segmentation faults or GPF's.

Please reply via email as well as posting so I don't miss anything.  Thanks
in advance,

	Mark.

--
..--------------------------{ From:  Mark Lewis }--------------------------.
|   Computing Services     |     http://www.city.ac.uk/~sl323/home.html   |
|   City University        |     PGP public key available by WWW, or by   |
|   London,  England       |     fingering sl323 AT finger DOT city DOT ac DOT uk        |
`--------{ M DOT Lewis AT city DOT ac DOT uk (MIME) | nostra AT city DOT ac DOT uk (MIME) }---------'


----{ err.out }----

go32 version 1.12.maint3 Copyright (C) 1994 DJ Delorie
This image has a buggy read.s module.  Run DPMIFIX on it and try again.
Unsupported DOS request at eip=1967
eax=00003f08 ebx=00000008 ecx=00004000 edx=00000000 esi=00000000 edi=00000000
ebp=7ffffd90 esp=7ffffd68 cs=d8 ds=48 es=48 fs=48 gs=38 ss=48 cr2=00009000
Call frame traceback EIPs:
  0x00001967
  0x0000128d


----{ test.h }----

#define FNAME		"c:/tmp/test.c"
#define BUF_SIZE	(2*8192)

void do_read(void);

----{ test.c }----

#include <stdio.h>
#include <fcntl.h>

#include "test.h"

extern char *buf;
/* char buf[BUF_SIZE]; */

void do_read() {
    FILE *fp;
    int fd, len;
    
    if ((fp = fopen(FNAME, "rb")) == NULL) {
	fprintf(stderr, "Couldn't open file.\n");
	exit(1);
    }
    fseek(fp, 0, SEEK_SET);
    fd = fileno(fp);
    lseek(fd, 0L, SEEK_END);
    lseek(fd, 0L, SEEK_SET);
    while((len = read(fd, buf, BUF_SIZE)) > 0)
	write(1, buf, len);
}


----{ test2.c }----

#include "test.h"

char buf[BUF_SIZE];

int main() {
    do_read();
    exit(0);
}

----{ EOF }----

- Raw text -


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