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

[Staging #CCK-208620]: ut_parse time string segfault



Reto,

> I'm getting a segfault when using ut_parse() of udunits2 2.1.23 and a
> time string e.g. "days since 2002-01-01 00:00:00" on OSX using either
> the system gcc-4.2 or gcc-4.5.3. ut_parse() works fine with e.g.
> "meters". Everything works fine on Linux. The time string decoding used
> to work in earlier versions of ut_parse on OSX as well.
> 
> Can you reproduce this error on one of your Macs? (OSX 10.6)

I can't reproduce the error on the only Mac OS/X system to which I have access: 

    $ uname -a
    Darwin mort.unidata.ucar.edu 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  
7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
    $ /usr/local/bin/gcc -v
    Using built-in specs.
    Target: x86_64-apple-darwin10
    Configured with: ../gcc-4.5-20090910/configure 
--enable-languages=fortran,c++ --host=x86_64-apple-darwin10 
--build=x86_64-apple-darwin10
    Thread model: posix
    gcc version 4.5.0 20090910 (experimental) (GCC) 

I did this to try to duplicate the problem:

    $ ./configure --prefix=`cd .. && pwd` CC=/usr/local/bin/gcc &>configure.log 
&& make install &>install.log && echo Installed
    Installed
    $ ../bin/udunits2
    udunits2: Character encoding not specified and not settable from 
environment variables LC_ALL, LC_CTYPE, or LANG.  Assuming ASCII encoding.
    udunits2: Using default XML database
    You have: days since 2002-01-01 00:00:00
    You want: 
        (86400 s) @ 20020101T000000.000000000 UTC
    You have: ^D

As you can see, the string "days since 2002-01-01 00:00:00" was successfully 
decoded.

> I've attached a small test code: test_udu.tar.gz
> 
> tar -zxvf test_udu.tar.gz
> cd test_udu
> edit the Makefile to point to your udunits2 installation
> make
> ./test_udu.sh
> 
> It should call ut_parse() with "meters" and return success
> It should then call ut_parse() with a time string and segfault (at least on 
> my machine).
> 
> segfault happens in:
> 
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: 13 at address: 0x0000000000000000
> 0x00007fff84e3ffc1 in dyld_stub_binder ()
> (gdb) where
> #0  0x00007fff84e3ffc1 in dyld_stub_binder ()
> #1  0x0000000100022050 in  stub helpers ()
> #2  0x000000010001057c in utlex () at scanner.l:174
> #3  0x000000010000ebcd in utparse () at parser.c:1407
> #4  0x0000000100012418 in ut_parse (system=0x100100080, string=0x7fff5fbff0c1 
> "days since 2002-01-01", encoding=UT_ASCII) at parser.y:574
> #5  0x0000000100000b9e in test_functionality ()
> #6  0x0000000100000b72 in main ()
> 
> Any way for you to think what goes wrong here?

I didn't see anything untoward in your example code, but I didn't look deeply.

Does the segmentation violation occur if you use the "udunits2" example above?

> Sincerely,
> Reto
> 
> 
> 
> 
> Dear Udunits user support
> 
> I'd like to add to my ticket the following information that is of
> importance:
> 
> if udunits2 is compiled with gcc 4.2 (OSX default) then everything works
> fine (all units are parsed correctly) if udunits2 is compiled with the
> gcc 4.5.3 (fink) then the segfault with the time string occurs (other
> units are parsed correctly).

The problem might be with the compiler.

> Reto

Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: CCK-208620
Department: Support UDUNITS
Priority: Normal
Status: Closed