Find the answer to your Linux question:
Results 1 to 6 of 6
I am crosscompiling a library for ARM processor running Linux. My host is Intel x86 / Ubuntu. When I compile and run on my host machine, everything works well. However, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2009
    Posts
    5

    pthread_mutex_lock segmentation FAULT


    I am crosscompiling a library for ARM processor running Linux. My host is
    Intel x86 / Ubuntu. When I compile and run on my host machine,
    everything works well. However, when I compile, link and run an example
    program on the target, it results in Segmentation Fault. In particular,

    The library creates a FEW mutexes and has numerous operations to create, lock, release those mutexes. For a while, it works ok. Mutexes are created, locked and released on the traget. But after a point, suddely, it crashes with Segmentation Fault in the lock step :

    pthread_mutex_lock(this=0x20005,hMutex=0x7500) //random numbers
    Program Recd signal SIGSEGV


    I am unable to reason out under what conditions this error may happen. Since the system is able to lock mutexes in many instances before. Plus, this error does not happen on Ubuntu but happens on the target device.

    What can I do to debug this problem and find a solution, Please advice, VERY URGENT

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,639
    Well, I don't know about your implementation of pthreads, but on my CentOS/RHEL system, the signature for pthread_mutex_lock is:
    Code:
    int pthread_mutex_lock(pthread_mutex_t *mutex);
    This isn't how you are apparently calling the function.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Aug 2009
    Posts
    5
    Thanks. the signature i used is correct. I was able to solve the problem. I tried a few cases and it worked. There was some problem in the function which was creating the mutex.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,639
    So, why the difference in function signatures? Is this a "custom" pthread implementation? Posix thread libraries at the same major version level at least should all have the same API's. What version are you running?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Just Joined!
    Join Date
    Sep 2010
    Posts
    1
    Hi

    I currently face the same problem. What did you do to solve it exactly?

    I use the following code to create the mutex:

    pthread_mutex_init(&semaphore_ptr->tx_mutex, NULL);

    and the following to lock:

    pthread_mutex_lock(&semaphore_ptr->tx_mutex);

    where semaphore_ptr is a pointer to a struct.

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,639
    This is a very old thread. Please post your own and provide more details and code examples, especially where you are declaring and using your semaphore/mutex structures, etc.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •