uNetworking / uNetworking/uSockets
us_listen_socket_close crashes with memory error
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 307
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I followed the suggestion from ReadMe in order for the loop to exit gracefully.
However, after calling us_listen_socket_close(), the application exited the Exception thrown: read access violation. ls->s.context->**loop** was 0xFFFFFFFFFFFFFFB7.
This happens the next line after the call to the bsd_close_socket(us_poll_fd((struct us_poll_t *) &ls->s)) inside context.c.
I am using v0.8.8 with uWebSockets v20.71.0.
Visual studio 2022 Debug Mode with Vcpkg and Windows 11.
Thank you,
The code:
` us_listen_socket_t* socket;
std::thread t([&]()
{
std::this_thread::sleep_for(std::chrono::seconds(15));
us_listen_socket_close(0, socket);
});
uWS::App().get("/*", fileHandler)
.listen(80, [&](auto* listen_socket) {
if (listen_socket) {
std::cout << "Listening on port " << 80 << '\n';
socket = listen_socket;
}
else
{
std::cout << "server failed to launch";
}
}).run();`
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in context.c at us_listen_socket_close(), especially the bsd_close_socket(us_poll_fd((struct us_poll_t *) &ls->s)) call and the subsequent access to ls->context->loop. Reproduce the supplied uWS App().listen().run() flow with the delayed thread on Windows 11 using Visual Studio 2022, then verify that closing the listen socket exits gracefully without the reported read access violation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100