Menu

#237 Segfault in gen_uuid.c (e2fsprogs-libs-1.41.4)

open
nobody
None
5
2012-11-28
2009-05-18
Anonymous
No

when Emesene call uuid4 in uuid module in python, which call get_random_fd in gen_uuid.c.
After this, the program got signal SIGSEGV.

When use gdb attach to the python process, I got these:
##########################
(gdb) c
Continuing.
[New Thread 0xb1c09b90 (LWP 6445)]
[Thread 0xb1c09b90 (LWP 6445) exited]
[New Thread 0xb1c09b90 (LWP 6446)]
[New Thread 0xb118cb90 (LWP 6447)]
[New Thread 0xb098bb90 (LWP 6448)]
[New Thread 0xb018ab90 (LWP 6449)]
[Thread 0xb018ab90 (LWP 6449) exited]
[Thread 0xb098bb90 (LWP 6448) exited]
[Thread 0xb1c09b90 (LWP 6446) exited]
[Thread 0xb118cb90 (LWP 6447) exited]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7d126c0 (LWP 6423)]
0xb6f0745e in get_random_fd () at gen_uuid.c:153
153 gen_uuid.c: No such file or directory.
in gen_uuid.c
################

(gdb) bt
#0 0xb6f0745e in get_random_fd () at gen_uuid.c:153
#1 0xb6f07509 in get_random_bytes (buf=0xbfe3fc70, nbytes=16)
at gen_uuid.c:172
#2 0xb6f086ee in uuid__generate_random (out=0x9f62fc8 "", num=0xbfe3fcb4)
at gen_uuid.c:591
#3 0xb6f08780 in uuid_generate_random (out=0x9f62fc8 "") at gen_uuid.c:607
#4 0xb666e3db in ffi_call_SYSV ()
from /usr/lib/python2.6/lib-dynload/_ctypes.so
#5 0xb666e159 in ffi_call () from /usr/lib/python2.6/lib-dynload/_ctypes.so
#6 0xb6668ebb in _CallProc () from /usr/lib/python2.6/lib-dynload/_ctypes.so
#7 0xb66620eb in ?? () from /usr/lib/python2.6/lib-dynload/_ctypes.so
#8 0xb6f08755 in uuid__generate_random (out=0x9f4950c "\005", num=0xa7fdb2c)
at gen_uuid.c:600
#9 0xb7ed0dba in PyObject_Call () from /usr/lib/libpython2.6.so.1.0
#10 0xb7f679b0 in PyEval_EvalFrameEx () from /usr/lib/libpython2.6.so.1.0
#11 0xb7f6ae49 in PyEval_EvalFrameEx () from /usr/lib/libpython2.6.so.1.0
#12 0xb7f6ae49 in PyEval_EvalFrameEx () from /usr/lib/libpython2.6.so.1.0
#13 0xb7f6b72e in PyEval_EvalCodeEx () from /usr/lib/libpython2.6.so.1.0
#14 0xb7efb774 in ?? () from /usr/lib/libpython2.6.so.1.0
#15 0x0a23ce30 in ?? ()
#16 0x0a14d02c in ?? ()
#17 0x00000000 in ?? ()
###########

the line 153 in get_uuid.c is
" jrand_seed[0] = getpid() ^ (tv.tv_sec & 0xFFFF);"
so in gdb I type:
(gdb) p jrand_seed[0]
Cannot access memory at address 0x30
#######

So this cause the segfault. But I don't know why.
May be related to the THREAD_LOCAL keywords :

#if defined(__linux__) && defined(__NR_gettid) && defined(HAVE_JRAND48)
#define DO_JRAND_MIX
THREAD_LOCAL unsigned short jrand_seed[3];
#endif

Discussion

  • Theodore Ts'o

    Theodore Ts'o - 2009-05-18

    What operating system and libc/glibc version are you using? Sounds like your OS/glibc combination isn't handling thread local storage correctly. If so you can workaround this shortcoming/bug in your toolchain via the configure option --disable-tls.

     
  • Nobody/Anonymous

    Gentoo Linux with glibc-2.9_p20081201-r2, e2fsprogs-libs-1.41.4

    I discovered that this problem is come with python-2.6, when emesene under python-2.5 the uuid module of python works fine.

    So may be it is the bug in python sides :)

     
  • Theodore Ts'o

    Theodore Ts'o - 2009-05-29

    What OS are you running? Sounds like your GCC and/or C library doesn't support thread local variables.