

pthread_key_create() is dangerous
source link: https://0pointer.net/blog/projects/pthread-key-create.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

If you use pthread_key_create() with a non-NULL destructor parameter (or an equivalent TLS construct) in a library/shared object then you MUST link your library wth -z nodelete (or an equivalent construct).
If you don't, then you'll have a lot of fun (like I just had) debugging segfaults in the TLS destruction logic where functions are called that might not even exist anymore in memory.
Now don't tell me I hadn't told you.
(Oh, and I hope I don't need to mention that all GObject-based libraries should link with -z nodelete anyway, for making sure the type system doesn't break.)
Recommend
-
165
Files Permalink Latest commit message Commit...
-
55
本文用来介绍 iOS 多线程中,pthread、NSThread 的使用方法及实现。第一部分:pthread 的使用、其他相关方法。第二部分:NSThread 的使用、线程相关用法、线程状态控制方法、线程之间的通信、线程安全和线程同步,以及线程的状态转换相关知识。
-
51
I have come into at least 2 times that one project was built well on Linux , while can’t find pthread related definitions on OpenBSD , like this:
-
51
本文首发于我的个人博客: 『不羁阁』 文章链接:
-
50
本文用来介绍 iOS 多线程中,pthread、NSThread 的使用方法及实现。
-
12
linux使用pthread库多线程编程,即使设置pthread_detach,资源也残留部分,不完全释放问题 发表于...
-
20
Copy link Member Smjert co...
-
4
Linux 系统编程 -(pthread) 线程创建与使用前面文章介绍了 Linux 下进程的创建、管理、使用、通信,了解了多进程并发;这篇文章介绍 Linux 下线程的基本使用。线程与进程的区别(1)进程: 是操作系统调度最小单位。Linux 下可...
-
10
pthread_mutex_t & pthread_cond_t 总结 一、多线程并发 1.1 多线程并发引起的问题 我们先来看如下代码: #in...
-
7
Pthread 并发编程(一)——深入剖析线程基本元素和状态 在本篇文章当中讲主要给大家介绍 pthread 并发编程当中关于线程的基础概念,并且深入剖析进程的相关属性和设置,以及线程在内存当中...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK