Home / Companies / Gel Data / Blog / Post Details
Content Deep Dive

C stdlib isn't threadsafe and even safe Rust didn't save us

Blog post from Gel Data

Post Details
Company
Date Published
Author
Matt Mastracci
Word Count
3,172
Company Posts That Month
2
Language
English
Hacker News Points
-
Post removed?
No
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.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.