[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#417815: libc6: localtime dies with : tzfile.c:544: __tzfile_compute: Assertion `num_types == 1' failed



On Wed, Apr 04, 2007 at 07:50:02PM +0100, Stephen Gran wrote:
> This one time, at band camp, Sven Luther said:
> > 
> >   The code yielding to this was of the kind of :
> > 
> >   struct tm tm;
> >   time_t t;
> >   t = time(NULL);
> >   localtime (&t, &tm);
> > 
> > This is in a fr_FR.utf8 locale, on a powerpc box. The same code on an x86 box
> > just segfaults without error message.
> 
> That doesn't even compile here:

yeah, it's localtime_r i used.

> #include <time.h>
> #include <stdlib.h>
> 
> int main (void) {
>   struct tm tm;
>   time_t t;
>   t = time(NULL);
>   localtime (&t, &tm);
>   exit(0);
> }
> 
> steve@gashuffer:~$ gcc -Wall t.c
> t.c: In function ‘main’:
> t.c:8: error: too many arguments to function ‘localtime’
> steve@gashuffer:~$ 
> 
> This code works fine, though:
> 
> #include <time.h>
> #include <stdlib.h>
> 
> int main (void) {
>   struct tm *tm;
>   time_t t;
>   t = time(NULL);
>   tm = localtime (&t);
>   exit(0);
> }
> 
> steve@gashuffer:~$ gcc -Wall t.c
> steve@gashuffer:~$ LC_ALL=fr_FR.utf8 ./a.out
> steve@gashuffer:~$ 

And indeed, like i said, it worked fine 100s of times, and then died. Try :

int main (void) {
  struct tm tm;
  time_t t;
  while (1) {
    t = time(NULL);
    localtime_r (&t, &tm);
  }
  exit(0);
}
> 




Reply to: