Configure with thread sanitizer fails the thread test - Mailing list pgsql-hackers

From Mikhail Matrosov
Subject Configure with thread sanitizer fails the thread test
Date
Msg-id CADhDkKzPSiNvA3Hyq+wSR_icuPmazG0cFe=YnC3U-CFcYLc8Xw@mail.gmail.com
Whole thread Raw
List pgsql-hackers
This is a reply to an old thread with the same name: https://www.postgresql.org/message-id/1513971675.5870501.1439797066345.JavaMail.yahoo@mail.yahoo.com
I was not able to do a proper reply since I cannot download the raw message: https://postgrespro.com/list/thread-id/2483942

Anyway, the problem with thread sanitizer is still present. If I try to build libpq v13.3 with thread sanitizer, I get a configuration error like this:

configure:18852: checking thread safety of required library functions
configure:18875: /usr/bin/clang-12 -o conftest -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -m64 -O3 -fsanitize=thread -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -DIN_CONFIGURE -I/home/mmatrosov/.conan/data/zlib/1.2.11/_/_/package/98c3afaf7dd035538c92258b227714d9d4a19852/include -DNDEBUG -D_GNU_SOURCE  -m64 -L/home/mmatrosov/.conan/data/zlib/1.2.11/_/_/package/98c3afaf7dd035538c92258b227714d9d4a19852/lib  conftest.c -lz -lm -lz  >&5
configure:18875: $? = 0
configure:18875: ./conftest
==================
WARNING: ThreadSanitizer: data race (pid=3413987)
  Write of size 4 at 0x000000f1744c by thread T2:
    #0 func_call_2 <null> (conftest+0x4b5e51)

  Previous read of size 4 at 0x000000f1744c by thread T1:
    #0 func_call_1 <null> (conftest+0x4b5d12)

  Location is global 'errno2_set' of size 4 at 0x000000f1744c (conftest+0x000000f1744c)

  Thread T2 (tid=3413990, running) created by main thread at:
    #0 pthread_create <null> (conftest+0x424b3b)
    #1 main <null> (conftest+0x4b5b49)

  Thread T1 (tid=3413989, running) created by main thread at:
    #0 pthread_create <null> (conftest+0x424b3b)
    #1 main <null> (conftest+0x4b5b2e)

...

configure:18879: result: no
configure:18881: error: thread test program failed
This platform is not thread-safe.  Check the file 'config.log' or compile
and run src/test/thread/thread_test for the exact reason.
Use --disable-thread-safety to disable thread safety.


I am not sure what is the proper fix for the issue, but I at least suggest to disable this test when building with thread sanitizer: https://github.com/conan-io/conan-center-index/pull/6472/files#diff-b8639f81e30f36c8ba29a0878f1ef4d9f1552293bc9098ebb9b429ddb1f0935f

-----
Best regards, Mikhail Matrosov

pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Fix memory leak when output postgres_fdw's "Relations"
Next
From: Tom Lane
Date:
Subject: Re: Fix memory leak when output postgres_fdw's "Relations"