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

Fix segfault trying to lock/unlock the master lock from unregistered … #125

Merged
merged 1 commit into from
Jan 26, 2025

Conversation

carlonluca
Copy link
Contributor

…thread

A thread that was never registered should not call enter_blocking_section or leave_blocking_section, as it cannot hold the master lock. This can cause segfaults in some cases.

…red thread

A thread that was never registered should not call enter_blocking_section or
leave_blocking_section, as it cannot hold the master lock. This can cause
segfaults in some cases.
@ygrek
Copy link
Owner

ygrek commented Jan 26, 2025

did you check that these functions are never called directly from ocaml thread? also, curious, how did this work until now then?

@carlonluca
Copy link
Contributor Author

The only call to ml_gethostbyname I could find is here: https://github.com/ygrek/mldonkey/blob/master/src/utils/lib/stubs_c.c#L835. The dns_thread calls it when there is a request.
It does not probably crashes until the threads module is linked. To know more I should read ocaml code, but I won't invest the time to do it unless you have doubts about this patch.

@ygrek
Copy link
Owner

ygrek commented Jan 26, 2025

this is curious
it is probably related somehow to 079eec6 but I thought it was dead code 🤔
anw the fix looks good

@ygrek ygrek merged commit 62985c7 into ygrek:master Jan 26, 2025
13 of 15 checks passed
@ygrek
Copy link
Owner

ygrek commented Jan 26, 2025

thanks!

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

Successfully merging this pull request may close these issues.

2 participants