tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: fopen/fread broken under OSF/1 V3.0?
@ 1995-02-06 17:24 winger
  0 siblings, 0 replies; only message in thread
From: winger @ 1995-02-06 17:24 UTC (permalink / raw)
  To: tru64-unix-managers

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@phy.ucsf.edu>
Stuart Kemp <stuart@reef.cs.jcu.edu.au>
don@gonzo.radiology.arizona.edu (don richards)
"Rick Murphy" <murphy@burfle.dco.dec.com>
"Scooter Morris" <scooter@kansas.gene.com>
Avery Pennarun <apenwarr@tourism.807-city.on.ca>
"Gernot A. Fink" <gernot@TechFak.Uni-Bielefeld.DE>
Dan Riley <dsr@lns598.lns.cornell.edu>
Larry Scott USG <scott@zk3.dec.com>
Dave Newbold <phdmn@siva.bris.ac.uk>
kobig@neora.iso.dec.com
Scotty Logan <scotty.logan@computing-services.oxford.ac.uk>
Helgi Viggosson <helgi@ott.is>
pn@andrea.olivetti.dk
Alexandru PANOIU <alex@mv3130.enet.dec.com>
"Paul E. Rockwell" <rockwell@rch.dec.com>

Dan Winger  __   _     *      )     * NASA-Goddard Space Flight Center
SEWP BOWL (soop bol)   *   _ ( \\   * RMS Technologies Inc.
winger@sewp.nasa.gov   *  (_X__//_  * Code 251.9
301.286.7658           * (        ) * Bldg 18 Room 274
FAX 301.286.1619       *  \______/  * Greenbelt, MD  20771

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-02-06 17:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-02-06 17:24 SUMMARY: fopen/fread broken under OSF/1 V3.0? winger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox