Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - gmtime() bug (or deeper?): (8 Items)
   
gmtime() bug (or deeper?)  
I am debugging an app, and data is being corrupted during a call to gmtime(). I looked through the source and traced the
 app via gdb, and the culprit appears to be the _Getrules() function in /lib/c/time/xgetrules.c. I have yet to prove 
this, but at the very beginning of that function, I see the following:

#ifdef __QNX__
	static const char *olddst;
	static Dstrule *rules;
#else
	static const char *olddst = 0;
	static Dstrule *rules = NULL;
#endif

followed by code that references both olddst and rules before they are initialized. Does that make any sense?

(p.s. is this a good forum to post this sort of thing, or should I use one of the forums under the OS project?)
Post Deleted
Re: gmtime() bug (or deeper?)  
I deleted my previous post; I was too quick to reply... they are static, so they should get initialized to 0

Could  you give more detail on the problem you are having?
Re: gmtime() bug (or deeper?)  
Still it's an odd construct, since it implies that the initialization is not performed under QNX, but I agree it should 
make no difference. The problem I am having is an unrelated variable is getting clobbered during a call to gmtime(), and
 apparently somewhere in _Getrules(). I will dig deeper. Obviously it could be my own fault.
Post Deleted
Re: gmtime() bug (or deeper?)  
There's nothing (I know of) wrong with gmtime. Turned out to be a memory 
allocation problem in my code resulting from a strange compiler 
optimization and linking issue. Sorry for the noise.

Aleksandar Ristovski wrote:
> Could you post the line where you call gmtime? (and definition of the time_t variable you are passing in).
>
>   
Re: gmtime() bug (or deeper?)  
Unfortunately that doesn't appear to be the whole problem. I will keep looking.
Re: gmtime() bug (or deeper?)  
Norton Allen wrote:

> (p.s. is this a good forum to post this sort of thing, or should I use one of the forums under the OS project?)

libc is part of the OS project so any issues with it should be discussed 
in the OS forums.

Regards,

Ryan Mansfield