On Wed, Dec 23, 2020 at 11:58:30PM -0700, Theo de Raadt wrote:

> Brad Smith <[email protected]> wrote:
> 
> > On 12/23/2020 10:35 PM, Alexey Sokolov wrote:
> > >> Synopsis:        getaddrinfo() is not thread-safe in 6.8
> > >> Category:        system
> > >> Environment:
> > >   System      : OpenBSD 6.8
> > >   Details     : OpenBSD 6.8 (GENERIC.MP) #1: Tue Nov  3 09:06:04 MST 2020
> > >                   
> > > [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> > >
> > >   Architecture: OpenBSD.amd64
> > >   Machine     : amd64
> > >> Description:
> > > Hi, getaddrinfo() crashes when multiple threads run getaddrinfo()
> > > concurrently. This didn't happen in 6.7.
> > > It looks like asr_ctx which is supposed to be thread-local according to
> > > _asr_use_resolver(), is actually static / shared between threads.
> > >> How-To-Repeat:
> > > Compile this code (gcc a.c -pthread), and run. It will segfault in
> > > several seconds. Happens with both gcc (4.2.1) and egcc (8.4.0).
> > 
> > Before going any further. Use the system compiler. That is Clang (cc).
> 
> I disagree.   As the test appears fairly idiomatic threading code, I
> find it unlikely a compiler change should matter.
> 

I can reprorduce on arm64 (with clang). If I change do_things() to run
forever and move the main thread call to do_things down to after the
creation loop the crash does not seem to happen. So I suppose the bug
is related to to the creation and destruction of threads and their
local data.

        -Otto

Reply via email to