In file included from /opt/compiler-explorer/gcc-12.4.0/include/c++/12.4.0/bits/shared_ptr_atomic.h:33,
from /opt/compiler-explorer/gcc-12.4.0/include/c++/12.4.0/memory:77,
from /opt/compiler-explorer/libs/boost_1_85_0/boost/asio/detail/memory.hpp:21,
from /opt/compiler-explorer/libs/boost_1_85_0/boost/asio/detail/handler_cont_helpers.hpp:19,
from /opt/compiler-explorer/libs/boost_1_85_0/boost/asio/detail/bind_handler.hpp:20,
from /opt/compiler-explorer/libs/boost_1_85_0/boost/asio/detail/wrapped_handler.hpp:18,
from /opt/compiler-explorer/libs/boost_1_85_0/boost/asio/io_context.hpp:26,
from <source>:1:
In function 'void std::atomic_thread_fence(memory_order)',
inlined from 'boost::asio::detail::std_fenced_block::std_fenced_block(full_t)' at /opt/compiler-explorer/libs/boost_1_85_0/boost/asio/detail/std_fenced_block.hpp:43:29:
/opt/compiler-explorer/gcc-12.4.0/include/c++/12.4.0/bits/atomic_base.h:143:26: warning: 'atomic_thread_fence' is not supported with '-fsanitize=thread' [-Wtsan]
143 | { __atomic_thread_fence(int(__m)); }
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
In function 'void std::atomic_thread_fence(memory_order)',
inlined from 'boost::asio::detail::std_fenced_block::~std_fenced_block()' at /opt/compiler-explorer/libs/boost_1_85_0/boost/asio/detail/std_fenced_block.hpp:49:29:
/opt/compiler-explorer/gcc-12.4.0/include/c++/12.4.0/bits/atomic_base.h:143:26: warning: 'atomic_thread_fence' is not supported with '-fsanitize=thread' [-Wtsan]
143 | { __atomic_thread_fence(int(__m)); }
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
Compiler returned: 0
Would it be possible for boost::asio to side-step this TSan limitation? (assuming it really is one, given that I didn't notice any false-positives with boost under TSan with gcc 11...) Older boost versions <= 1.83 used to have some alternative class fenced_block implementations, maybe one of them can be used when building with TSan?
Hi,
It looks like there is a new warning since gcc 12 when compiling boost::asio with
-fsanitize=thread
. boost::asio usesstd::atomic_thread_fence
, but apparently ThreadSanitizer does not support this (https://github.com/google/sanitizers/issues/1352, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97868).[Example code](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:1,endLineNumber:12,positionColumn:1,positionLineNumber:12,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:'%23include+%3Cboost/asio/io_context.hpp%3E%0A%23include+%3Cboost/asio/ip/udp.hpp%3E%0A%0Aint+main()%0A%7B%0A++boost::asio::io_context+iocontext%3B%0A++boost::asio::ip::udp::socket+socket%7Biocontext%7D%3B%0A%0A++const+boost::asio::ip::udp::endpoint+local_endpoint%7Bboost::asio::ip::address::from_string(%22192.168.9.5%22),+12345%7D%3B%0A++socket.open(local_endpoint.protocol())%3B%0A%7D%0A'),l:'5',n:'1',o:'C%2B%2B+source+%231',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:g124,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!((name:boost,ver:'185')),options:'-fsanitize%3Dthread',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+gcc+12.4+(Editor+%231)',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+gcc+14.1',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+gcc+12.4+(Compiler+%231)',t:'0')),k:33.33333333333333,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4):
Compiler output:
Would it be possible for boost::asio to side-step this TSan limitation? (assuming it really is one, given that I didn't notice any false-positives with boost under TSan with gcc 11...) Older boost versions <= 1.83 used to have some alternative
class fenced_block
implementations, maybe one of them can be used when building with TSan?