Skip to content

Conversation

cjen1-msft
Copy link
Contributor

Fixing an ASAN failure.
The specific issue is that the node can accept a connection (and a couple of other uv callbacks) while the handle is being closed.
The error below is caused by the on_accept incrementing the connection id when the ConnIdGenerator has already gone out of scope.

There are a couple of other spots in the tcp.h file where we should probably have similar checks, but these are two that I am sure are correct to do.
(on_write, on_resolved, on_alloc and on_read, seem like good candidates, on_reconnect seems suspicious generally)

76: =================================================================                                                                                                                                                         
76: ==19831==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fa999a05dc0 at pc 0x562224fb43a7 bp 0x7ffc90b9af00 sp 0x7ffc90b9aef8                                                                                
76: WRITE of size 8 at 0x7fa999a05dc0 thread T0                                                                
76:     #0 0x562224fb43a6 in std::__atomic_base<long>::fetch_add(long, std::memory_order) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.0/../../../../include/c++/13.2.0/bits/atomic_base.h:635:16                           
76:     #1 0x562224fb43a6 in std::__atomic_base<long>::operator++(int) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.0/../../../../include/c++/13.2.0/bits/atomic_base.h:386:16                                              
76:     #2 0x562224fb3e59 in long asynchost::ConnIDGenerator::get_next_id<std::unordered_map<long, asynchost::proxy_ptr<asynchost::TCPImpl>, std::hash<long>, std::equal_to<long>, std::allocator<std::pair<long const, asynch
ost::proxy_ptr<asynchost::TCPImpl>>>>>(std::unordered_map<long, asynchost::proxy_ptr<asynchost::TCPImpl>, std::hash<long>, std::equal_to<long>, std::allocator<std::pair<long const, asynchost::proxy_ptr<asynchost::TCPImpl>>
>>&) CCF/build/CCF/src/host/rpc_connections.h:63:17                                                            
76:     #3 0x562224fb3749 in asynchost::RPCConnectionsImpl<asynchost::proxy_ptr<asynchost::TCPImpl>>::get_next_id() CCF/build/CCF/src/host/rpc_connections.h:477:20
76:     #4 0x56222500b491 in asynchost::RPCConnectionsImpl<asynchost::proxy_ptr<asynchost::TCPImpl>>::RPCServerBehaviour::on_accept(asynchost::proxy_ptr<asynchost::TCPImpl>&) CCF/build/CCF/src/host/rpc_connections.h:171:33
76:     #5 0x562224e55844 in asynchost::TCPImpl::on_accept(int) CCF/build/CCF/src/host/tcp.h:676:18
76:     #6 0x562224e53e23 in asynchost::TCPImpl::on_accept(uv_stream_s*, int) CCF/build/CCF/src/host/tcp.h:650:44
76:     #7 0x7fa99b78bc81  (/usr/lib/libuv.so.1+0x1ec81) (BuildId: 89410ca0b8401d55965003994b04e3171b4f89be)
76:     #8 0x7fa99b792a21  (/usr/lib/libuv.so.1+0x25a21) (BuildId: 89410ca0b8401d55965003994b04e3171b4f89be)
76:     #9 0x7fa99b77fc87 in uv_run (/usr/lib/libuv.so.1+0x12c87) (BuildId: 89410ca0b8401d55965003994b04e3171b4f89be)
76:     #10 0x562224a63b1d in ccf::run(int, char**) CCF/build/CCF/src/host/run.cpp:1040:7
76:     #11 0x5622237f7321 in main CCF/build/CCF/samples/apps/main.cpp:8:10
76:     #12 0x7fa99b0dfefa  (/usr/lib/libc.so.6+0x27efa) (BuildId: 68c6dbe2dee4ba7f901cfd31e4ee46e6fbe16e5b)
76:     #13 0x7fa99b0dffba in __libc_start_main (/usr/lib/libc.so.6+0x27fba) (BuildId: 68c6dbe2dee4ba7f901cfd31e4ee46e6fbe16e5b)
76:     #14 0x562223269824 in _start (/ccf/build/samples/apps/logging/logging+0x2711824)
76: 
76: Address 0x7fa999a05dc0 is located in stack of thread T0 at offset 24000 in frame
76:     #0 0x562224a368cf in ccf::run(int, char**) CCF/build/CCF/src/host/run.cpp:107

@cjen1-msft cjen1-msft requested a review from a team as a code owner October 1, 2025 13:26
@achamayou achamayou added the run-long-test Run Long Test job label Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-long-test Run Long Test job
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants