64位架构下的C问题:pthread_kill()
问题很简单:我的应用程序在 32 位架构上完美运行,但在 64 位架构上运行。我遇到分段错误
。我猜原因是执行了 pthread_kill()
调用。有可能吗还是我的假设是错误的?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里有一个关于在
pthread_kill
上引发segfault
问题的链接,该问题是由无效pthread_t
id 引起的:http://udrepper.livejournal.com/16844.htmlHere'a a link about the issue of throwing a
segfault
onpthread_kill
that is caused by invalidpthread_t
ids: http://udrepper.livejournal.com/16844.html您使用什么操作系统和 glibc?
如果您使用 pthread 的主流实现(例如 Linux 上最近的 GNU glibc),我很确定它们没有损坏。
我认为您的崩溃可能是由于代码中的某些问题或者可能是由于 32 位和 64 位二进制代码的错误混合所致。
您能否尝试用尽可能少的代码行重现崩溃并将其粘贴到此处?
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?
几乎可以肯定,分段错误不是
pthread_kill()
的结果,而是应用程序中的一个普通的旧错误(许多错误仅在 64 位编译中出现,或者仅在某些内存布局;您的特定应用程序没有什么特别的)。不要猜测可能的原因是什么,而是在
GDB
或Valgrind
下运行您的应用程序。两者都可能会让你痛苦地清楚你的错误在哪里。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
orValgrind
. Both will likely make it painfully clear where your bug is.