Title: An issue of C in 64 bit architecture: pthread_kill()
Tags: c;64-bit;pthreads;segmentation-fault;32bit-64bit
Question: The question is quite simple: my application runs perfectly on a 32 bit architecture, but on a 64 bit arch. I got segmentation fault. I guess that the cause is the execution of a pthread_kill() call. Is it possible or my supposition is just wrong?
Comment: This is just a wild guess of yours. If you are porting a program to another processor architecture, all kind of things can happen. Run your program in a debugger and look where the segfault comes from.


Here is another answer: Here'a a link about the issue of throwing a segfault on pthread_kill that is caused by invalid pthread_t ids: http://udrepper.livejournal.com/16844.html

Here is another answer: What operating system and what glibc are you using?
If you're using a mainstream implementation of pthread (say a recent GNU glibc on Linux) I'm quite sure they're not broken.
I think that your crash is likely due to some problem in your code or maybe to an incorrect mixing of 32bit and 64bit binary code.
Could you try to reproduce your crash with as little code lines as possible and paste it here?
Comment for this answer: It is physically impossible to "mix" 32-bit and 64-bit code in the same user-level application on Linux.
Comment for this answer: I'm on a Debian GNU/Linux 2.6.26-2-686 kernel version and 2.7 glibc version.

Here is another answer: Segmentation fault is almost certainly not a result of pthread_kill(), but a plain old bug in the application (many bugs show up only in 64-bit compiles, or only with certain memory layouts; nothing special about your particular application here).
Instead of guessing what the cause might be, run your application under GDB or Valgrind. Both will likely make it painfully clear where your bug is.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2011:00:01/19/11', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c><64-bit><pthreads><segmentation-fault><32bit-64bit>', 'Title': 'An issue of C in 64 bit architecture: pthread_kill()', 'ViewCount': 805, 'id': 4734256, 'user_AboutMe': '', 'user_AccountId': 271674.0, 'user_DisplayName': 'Luigi', 'user_Reputation': 31.0, 'user_Views': 4.0, 'user_id': 562336.0}}