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

Build a custom version of libcurl that is statically linked #157

Closed
DemiMarie opened this issue Apr 10, 2017 · 5 comments
Closed

Build a custom version of libcurl that is statically linked #157

DemiMarie opened this issue Apr 10, 2017 · 5 comments

Comments

@DemiMarie
Copy link

Libcurl (very annoyingly!) has a thread-unsafe startup function, curl_global_init.

Currently, this library recommends that curl be initialized very early in the program. But that still isn’t safe. A user could fail to initialize this library and then experience a data race (= undefined behavior) later on.

Rust has no way to ensure that a function is called before any threads are launched. Initializing libcurl from a static initializer can cause deadlocks on Windows. Is there a solution?

@alexcrichton
Copy link
Owner

Could you clarify the unsafety here? Invocations of the initialization function should be synchronized.

@alexcrichton
Copy link
Owner

AFAIK there's no known unsafety here, so I'm going to close this, but please let me know if I'm wrong!

@DemiMarie
Copy link
Author

@alexcrichton The unsafety appears if another thread is already using one of the libraries that libcurl uses, and which has a thread-unsafe initialization, such that both threads try to initialize libcurl (or a dependency thereof) simultaneously.

@alexcrichton
Copy link
Owner

Indeed! Other crates I've worked in solve this by exposing a shared init function in the sys crate to call into, and I could add that to curl as well if needed!

@DemiMarie
Copy link
Author

DemiMarie commented May 10, 2017 via email

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

2 participants