User defined stack for threads in Linux 2.6.11 + glibc 2.3.5

Discussion in 'C Programming' started by mysterious.ashish@gmail.com, Mar 31, 2008.

  1. Guest

    Hi,

    I am currently working with threads using linux 2.6.11 and glibc 2.3.5
    on x86. When i am trying to create thread with user defined stacks
    glibc gives segmentation fault. I have written a wrapper to
    pthread_create () and generated shared object for the same. When i am
    trying to create any thread (for user defined stack) using this shared
    object i am getting segmentation fault. If i don't create shared
    object and try to create thread (with user defined stack) using same
    code, it works fine. I am not able to understand this behavior. Why
    creating a thread using shared object shall result in segfault. And
    how to overcome this situation.

    NOTE: I got same behavior when tried with linux 2.6.12 and glibc-2.3.6
    on arm platform.


    gdb output for the behavior is :

    Loaded symbols for /lib/libgcc_s.so.1
    #0 0x0018a777 in memset () from /lib/libc.so.6
    (gdb) bt'
    #0 0x0018a777 in memset () from /lib/libc.so.6
    No symbol table info available.
    #1 0x003e27ef in pthread_create@@GLIBC_2.1 () from /lib/libpthread.so.
    0
    No symbol table info available.
    #2 0x003e29fd in pthread_create@GLIBC_2.0 () from /lib/libpthread.so.
    0
    No symbol table info available.
    #3 0x00ed9880 in process_create (entry_point=0x8048f4c
    <ThreadEntryPoint>, pArg=0x1, pStack=0x82e08a8, ulStack_Size=16384,
    ulPrio=127)
    at multithreading.c:1916
    stThAttr = {__size = "c\000\000\000\002\000\000\000j
    \000\000\000\000\02 0\000\000¨H.\b\000@", '\0' <repeats 13 times>,
    __align = 99}
    stSchedParam = {__sched_priority = 99}
    pstTd = (ThreadData_t *) 0xedd7d8
    state = 0
    chPriority = 99 'c'
    ulRetVal = 0
    pRetVal = 0x0
    __FUNCTION__ = "process_create"
    #4 0x08049af8 in process_create_test (ulInParam=1) at
    multithreading_test.c:539
    ulIndex = 0
    lRetVal = -1
    ulThreadIndex = 1
    lTestPassFlag = 0
    stack = (void *) 0x82d88a8
    pStack = (void *) 0x82e08a8
    ulPrio = 127
    stackSize = 16384
    __FUNCTION__ = "process_create_test"
    #5 0x0804b14b in main () at multithreading_test.c:1460
    chChoice = "1"
    lChoice = 1
    stack = (void *) 0x0
    stackSize = 0
    ulPrio = 0
    ulLoopIndex = 0
    stTime = 134533384
    stTimeInfo = {tm_sec = 4, tm_min = 53, tm_hour = 7, tm_mday = 7,
    tm_mon = 3, tm_year = 74, tm_wday = 0, tm_yday = 96, tm_isdst = 0,
    tm_gmtoff = 19800, tm_zone = 0x82d81b8 "IST"}
    achTimebuf = "04/07/1974 07:53:w"
    stThAttr = {__size = '\0' <repeats 13 times>, "\020", '\0' <repeats 21
    times>, __align = 0}
    lFlag = 1
    chFlag = 0
    lTestPassFlag = 0
    ulThreadIndex = 0
    ulloopIndex = 1
    ulThreadId = {0, 0, 0, 0}
    __FUNCTION__ = "main"
    (gdb) f 0
    #0 0x0018a777 in memset () from /lib/libc.so.6
    (gdb) f 1
    #1 0x003e27ef in pthread_create@@GLIBC_2.1 () from /lib/libpthread.so.
    0
    (gdb)


    Please let me know if someone can help me.

    Thanks,
    Ashish
    , Mar 31, 2008
    #1
    1. Advertising

  2. Flash Gordon Guest

    wrote, On 31/03/08 06:50:
    > Hi,
    >
    > I am currently working with threads using linux 2.6.11 and glibc 2.3.5
    > on x86. When i am trying to create thread with user defined stacks
    > glibc gives segmentation fault. I have written a wrapper to
    > pthread_create () and generated shared object for the same. When i am


    <snip>

    You need to ask on comp.programming.threads (where the threading experts
    hang out) or possibly comp.unix.programmer (where the POSIX experts hang
    out as you seem to be using Posix threads). Threads are not part of C
    itself but an extension provided by some systems in (sometimes)
    incompatible ways.
    --
    Flash Gordon
    Flash Gordon, Mar 31, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oodini
    Replies:
    1
    Views:
    1,731
    Keith Thompson
    Sep 27, 2005
  2. Louis B. (ldb)

    Need help with bug (glibc, linux, malloc-related)

    Louis B. (ldb), Feb 5, 2007, in forum: C Programming
    Replies:
    7
    Views:
    572
    CBFalconer
    Feb 5, 2007
  3. Surinder Singh
    Replies:
    1
    Views:
    1,171
    Richard Bos
    Dec 20, 2007
  4. Sam Roberts
    Replies:
    1
    Views:
    208
    Yukihiro Matsumoto
    Feb 11, 2005
  5. Alok
    Replies:
    3
    Views:
    233
Loading...

Share This Page