Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream leaks in quicer 0.0.401 #279

Closed
qzhuyan opened this issue May 17, 2024 · 1 comment
Closed

stream leaks in quicer 0.0.401 #279

qzhuyan opened this issue May 17, 2024 · 1 comment

Comments

@qzhuyan
Copy link
Collaborator

qzhuyan commented May 17, 2024

Indirect leak of 36864 byte(s) in 9 object(s) allocated from:
    #0 0xffff82dfa2f4 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0xffff4d36b74c in CxPlatAlloc /home/ubuntu/repo/quic/msquic/src/platform/platform_posix.c:288
    #2 0xffff4d212ab0 in CxPlatPoolAlloc /home/ubuntu/repo/quic/msquic/src/inc/quic_platform_posix.h:543
    #3 0xffff4d212ab0 in QuicStreamInitialize /home/ubuntu/repo/quic/msquic/src/core/stream.c:110
    #4 0xffff4d24f8bc in MsQuicStreamOpen /home/ubuntu/repo/quic/msquic/src/core/api.c:661
    #5 0xffff4d1cc498 in async_start_stream2 /home/ubuntu/repo/quic/c_src/quicer_stream.c:335
    #6 0xaaaac68007b4 in beam_jit_call_nif(process*, void const*, unsigned long*, unsigned long (*)(enif_environment_t*, int, unsigned long*), erl_module_nif*) beam/jit/beam_jit_common.cpp:646
    #7 0xffff77df0b98  (/memfd:vmem (deleted)+0xb98)
    #8 0xffff788679e8  (/memfd:vmem (deleted)+0xa779e8)
@qzhuyan
Copy link
Collaborator Author

qzhuyan commented May 21, 2024

This is detected by proper tests, the test calls STREAM API randomly without checking the callback events that the stream actually failed to start (async task). With default flags, failed to start the stream will not trigger stream_closed thus cause the stream leaks.

The solution in application are either
a. wait for {quic, start_completed, stream_handle(), #{is_peer_accepted := boolean()} } (QUIC_STREAM_EVENT_START_COMPLETE in msquic) to check if it is accepted or not.
b. set ?QUIC_STREAM_START_FLAG_SHUTDOWN_ON_FAIL when start the stream, so that you get event for stream shutdown

{quic, stream_closed, _, _}

and

{quic, send_shutdown_complete, _, _}

c. In NIF callback funs, we deref the stream handle so I will trigger stream close from application.

reference: microsoft/msquic#4311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant