Company
Date Published
Author
Matt Mastracci
Word count
3172
Language
English
Hacker News points
None

Summary

While porting network I/O code in EdgeDB from Python to Rust, developers encountered an unusual crash that only occurred on ARM64 CI runners during testing of a new HTTP fetch feature. Initially suspected to be a deadlock, investigations revealed it was caused by a crash in the libc `getenv` function, linked to a race condition when the `setenv` and `getenv` functions were called simultaneously in a multithreaded environment. The crash was traced back to the `openssl-probe` library setting environment variables, which conflicted with the native TLS backend used in the HTTP client library `reqwest`. The developers decided to migrate from the `rust-native-tls`/OpenSSL backend to `rustls` on Linux to circumvent the issue, acknowledging the complexities of handling environment variables in multithreaded applications. Future plans include addressing this with Rust's 2024 edition marking environment-setter functions as unsafe and recent glibc updates that improve `getenv`'s thread safety.