Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 16 Feb 2022 22:01:13 +0100
From: Florian Weimer <>
To: Carlos O'Donell <>
Cc:,  Markus Wichmann <>
Subject: Re: Is errno signal-safe?

* Carlos O'Donell:

> On 2/16/22 14:40, Markus Wichmann wrote:
>> Hi all,
>> today I had a flash of inspiration while staring at some code: errno is
>> a global variable, right? OK, it is thread-local, but still a global
>> variable in the context of one thread. And looking at a global variable
>> while it may (or may not) be modified in a signal handler is not safe to
>> do.
> It is required that errno, if changed, must be restored by the signal
> handler before exit (though note that for glibc the underlying lazy
> TLS allocation implementation makes errno AS-unsafe for first use in a
> signal handler because calloc is used to allocate the storage).

glibc uses initial-exec TLS under the hood for storing the int variable,
so the variable access itself async-signal-safe (whether it goes
directly to errno@...BC_PRIVATE or via __errno_location, it doesn't


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.