#578273 libc6-dev: Please provide thread-safe dlerror() replacement

Package:
libc6-dev
Source:
glibc
Description:
GNU C Library: Development Libraries and Header Files
Submitter:
Remi Denis-Courmont
Date:
2021-02-03 16:09:02 UTC
Severity:
wishlist
Tags:
#578273#5
Date:
2010-04-18 14:26:56 UTC
From:
To:
	Hello,

The current glibc implementation of dlerror() calls strerror(). The
current implementation of strerror() is not thread-safe. While this
is allowed by POSIX, this is quite inconvenient for thread-safe programs
or library using dlopen() and dlsym().

With dlsym(), checking dlerror() is in fact the "recommended" way to
detect errors. In theory anyway - NULL can be a correct succesful return
value for dlsym().

I would not hold my breath for POSIX to resolve this issue, so can glibc
please provide a proprietary replacement? We need this to fix the libvlc
package (currently "wrongly" calling dlerror()). It could either write
the error message to a provided buffer à la strerror_r() or allocate it
on the heap - whatever.

Best regards,

#578273#8
Date:
2021-02-03 16:05:20 UTC
From:
To:
Actually it's not allowed by POSIX and this is non-conforming behavior—it's
guaranteed that other library functions shouldn't call strerror "behind your
back," although dlerror() continues to do so.

Although the Bugzilla bug doesn't seem to reflect this [1], the glibc 2.32
release notes indicate that strerror has been made thread-safe [2] [3]:

So it would appear that this is fixed in glibc 2.32, although dlerror() will
still clobber prior calls to strerror or strerror_l.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=1890
[2] https://sourceware.org/pipermail/libc-announce/2020/000029.html
[3] https://sourceware.org/git/?p=glibc.git;a=commit;h=28aff047