SUMMARY: fopen/fread broken under OSF/1 V3.0?

From: Dan Winger <winger_at_sewp.nasa.gov>
Date: Mon, 06 Feb 95 12:24:28 -0500

Original Posting:
-----------------
> I have an Alpha 3000 / Model 600 running OSF/1 V3.0.
> I am trying to read the file "/var/adm/utmp" with a program I am
> writing. I am following all of the necessary rules, that I am aware
> of, to compile and run this program. The program works fine when
> it is compiled and executed under Solaris 2.3 on a Sun SparcServer 10,
> but not here.
>
> Running the broken program using "dbx":
>
> # dbx
> enter object file name (default is `a.out'):
> dbx version 3.11.6
> Type 'help' for help.
>
> main: 26 int i=0;
> (dbx) run
> readut: Error 0
> DATE/TIME USER INIT PID STATUS HOST
> ---------------------------- ------------ ---------------- ------ -------------------- -------------------------
> sizeof(struct utmp) = 156
> About to read
> signal Segmentation fault at [memcpy:78 ,0x3ff8083b2e4] Source not available
> (dbx) where
> > 0 memcpy(0x3ff80862a78, 0x3ffc0800678, 0x2, 0x9c, 0x3ff00000000) ["../../../../../src/usr/ccs/lib/libc/alpha/memcpy.s":78, 0x3ff8083b2e4]
> 1 fread(0x140000188, 0x9c, 0x1, 0x0, 0x0) ["../../../../../src/usr/ccs/lib/libc/fread.c":154, 0x3ff80862b04]
> 2 main() ["readut.c":54, 0x1200015e8]
> (dbx)

To ease everyone's mind, the compiler is NOT broken.

My program was not allocating space in memory for the data to enter the
registers of the variable defined.

Instead of:

        struct utmp *ut;

Used:

        struct utmp ut;

Instead of:

        j=fread(ut,sizeof(struct utmp),1,fd);

Used:

        j=fread(&ut,sizeof(struct utmp),1,fd);

All references to items within the structure were modified.

Instead of:

        ut->ut_user

Used:

        ut.ut_user

Thank you for the replies from:
-------------------------------
Jim Wright <jwright_at_phy.ucsf.edu>
Stuart Kemp <stuart_at_reef.cs.jcu.edu.au>
don_at_gonzo.radiology.arizona.edu (don richards)
"Rick Murphy" <murphy_at_burfle.dco.dec.com>
"Scooter Morris" <scooter_at_kansas.gene.com>
Avery Pennarun <apenwarr_at_tourism.807-city.on.ca>
"Gernot A. Fink" <gernot_at_TechFak.Uni-Bielefeld.DE>
Dan Riley <dsr_at_lns598.lns.cornell.edu>
Larry Scott USG <scott_at_zk3.dec.com>
Dave Newbold <phdmn_at_siva.bris.ac.uk>
kobig_at_neora.iso.dec.com
Scotty Logan <scotty.logan_at_computing-services.oxford.ac.uk>
Helgi Viggosson <helgi_at_ott.is>
pn_at_andrea.olivetti.dk
Alexandru PANOIU <alex_at_mv3130.enet.dec.com>
"Paul E. Rockwell" <rockwell_at_rch.dec.com>

Dan Winger __ _ * ) * NASA-Goddard Space Flight Center
SEWP BOWL (soop bol) * _ ( \\ * RMS Technologies Inc.
winger_at_sewp.nasa.gov * (_X__//_ * Code 251.9
301.286.7658 * ( ) * Bldg 18 Room 274
FAX 301.286.1619 * \______/ * Greenbelt, MD 20771
Received on Mon Feb 06 1995 - 12:25:37 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:45 NZDT