From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96075317506401.tru64-unix-managers.marc@archive.invalid> From: winger () sewp ! nasa ! gov (Dan Winger) Date: Mon, 06 Feb 1995 17:24:28 +0000 To: tru64-unix-managers Subject: SUMMARY: fopen/fread broken under OSF/1 V3.0? X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96075317506401 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 Stuart Kemp don@gonzo.radiology.arizona.edu (don richards) "Rick Murphy" "Scooter Morris" Avery Pennarun "Gernot A. Fink" Dan Riley Larry Scott USG Dave Newbold kobig@neora.iso.dec.com Scotty Logan Helgi Viggosson pn@andrea.olivetti.dk Alexandru PANOIU "Paul E. Rockwell" 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