NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: lib/60215: ld.elf_so dlerror() state is not thread-local
The following reply was made to PR lib/60215; it has been noted by GNATS.
From: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: tsutsui%ceres.dti.ne.jp@localhost
Subject: Re: lib/60215: ld.elf_so dlerror() state is not thread-local
Date: Wed, 29 Apr 2026 08:18:16 +0900
> ld.elf_so doesn't itself have any notion of threads, which makes it
> quite hard to make error messages thread-safe.
>From the application's point of view, this is not only about making
error messages thread-safe. If dlerror() state is process-global,
the usual dlerror()/dlsym()/dlerror() sequence can report an
unrelated error from another LWP and make the application take
the wrong error path.
For comparison, glibc does not use a single process-global dlerror
state. Its current implementation stores dlfcn failure state in
thread-local storage:
https://sourceware.org/git/?p=glibc.git;a=blob;f=dlfcn/dlerror.h;hb=66f3e9219d8f86b977d9be04ad469b5d72af0da2#l88
```
86 /* Thread-local variable for storing dlfcn failures for subsequent
87 reporting via dlerror. */
88 extern __thread struct dl_action_result *__libc_dlerror_result
89 attribute_tls_model_ie;
```
---
Izumi Tsutsui
Home |
Main Index |
Thread Index |
Old Index