This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gmtime_r hanging


There is always the possibility of a real bug but seeing a 128 byte buffer on the stack makes me wonder if you have blown the stack. 

What is the stack address range? Check the stack pointer. You can always fill the stack memory with a pattern and see how much is written to.

--joel sherrill
RTEMS

Daniel O'Connor <doconnor@gsoft.com.au> wrote:

>Hi,
>I'm trying to use newlib on an STM32 and I ran across an oddity with gmtime_r
>
><snip>
>    char	buf[128];
>    struct tm	nowtm;
>    time_t	now;
><snip>
>		now = time(NULL);
>		printf("Time is %d\r\n", (int)now);
>		gmtime_r(&now, &nowtm);
>		strftime(buf, sizeof(buf) - 1, "Time is %Y/%m/%d %H:%M:%S\r\rn", &nowtm);
><snip>
>
>Breakpoint 1, gmtime_r (tim_p=0x2000ffdc, res=0x2000ffb8) at ../../../../../../gcc-4.6.1/newlib/libc/time/gmtime_r.c:13
>13	  return (_mktm_r (tim_p, res, 1));
>(gdb) stepi
>0x0800175c	13	  return (_mktm_r (tim_p, res, 1));
>(gdb) 
>_mktm_r (tim_p=<value optimized out>, res=<value optimized out>, is_gmtime=<value optimized out>)
>    at ../../../../../../gcc-4.6.1/newlib/libc/time/mktm_r.c:32
>32	{
>(gdb) 
>0x08001fd2	32	{
>(gdb) 
>0x08001fd4	32	{
>(gdb) 
>0x08001fd6	32	{
>(gdb) 
>0x08001fd8	32	{
>(gdb) 
>0x08001fda	32	{
>(gdb) 
>32	{
>(gdb) 
>0x08001fde	32	{
>(gdb) 
>0x08001fe0	32	{
>(gdb) 
>38	   __tzinfo_type *tz = __gettzinfo ();
>(gdb) 
>__gettzinfo () at /Users/darius/projects/stm32test/syscalls.c:161
>161	}
>(gdb) 
>0x080005c4	161	}
>(gdb) 
>0x08001fe6 in _mktm_r (tim_p=0x2000ffdc, res=0x2000ffb8, is_gmtime=1) at ../../../../../../gcc-4.6.1/newlib/libc/time/mktm_r.c:38
>38	   __tzinfo_type *tz = __gettzinfo ();
>(gdb) 
>41	  lcltime = *tim_p;
>(gdb) 
>0x08001fea	41	  lcltime = *tim_p;
>(gdb) 
>43	  days = ((long)lcltime) / SECSPERDAY;
>(gdb) 
>0x08001fee	43	  days = ((long)lcltime) / SECSPERDAY;
>(gdb) 
>0x08001ff0	43	  days = ((long)lcltime) / SECSPERDAY;
>(gdb) 
>0x00000000 in ?? ()
>(gdb) 
>
>I have no idea why it's jumping to NULL doing a division :(
>
>--
>Daniel O'Connor software and network engineer
>for Genesis Software - http://www.gsoft.com.au
>"The nice thing about standards is that there
>are so many of them to choose from."
>  -- Andrew Tanenbaum
>GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
>
>
>
>
>
>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]