spurious memory access error using localtime(), SunStudio 12, Solaris 10 x8

The following code:

#include <stdio.h>

#include <sys/types.h>

#include <time.h>

int

main()

{

time_t t = time(NULL);

struct tm *ptm = localtime(&t);

printf("hours = %d\n", ptm->tm_hour);

}

produces the following error:

(dbx) check -access

access checking - ON

(dbx) run

Running: testtime

(process id 8489)

Reading rtcapihook.so

Reading libdl.so.1

Reading rtcaudit.so

Reading libmapmalloc.so.1

Reading libgen.so.1

Reading libm.so.2

Reading rtcboot.so

Reading librtc.so

RTC: Enabling Error Checking...

RTC: Running program...

Reading disasm.so

Read from unallocated (rua):

Attempting to read 4 bytes at address 0xfefc0208

stopped in main at line 11 in file "testtime.c"

11printf("hours = %d\n", ptm->tm_hour);

(dbx)

I *think* my code is valid and this is a bug in the memory checking tool. I am using Solaris 10 x86 on an Ultra 20 and Sun Studio 12 FCS. A related (old) thread is:

http://forum.java.sun.com/thread.jspa?threadID=5072458

Thanks!

Jordan

[1201 byte] By [jslotta] at [2007-11-27 9:58:09]
# 1

There are two possible reasons:

- bug in dbx,

- peculiarity of run-time memory checking on x86 platform.

If you're curious, you can read more on this subject in this thread:

http://forum.java.sun.com/thread.jspa?threadID=5188256&messageID=9735867#97 35867

Meanwhile, I'll try to investigate whether we have a bug here or not.

MaximKartasheva at 2007-7-13 0:28:36 > top of Java-index,Development Tools,Solaris and Linux Development Tools...