Skip to content

Run libcurl global initialization once per process - #25

Merged
mlin merged 1 commit into
mlin:mainfrom
Wid-L-Hacker:conrad/lazycurl-global-init-guard
Nov 8, 2026
Merged

mlin merged 1 commit into
mlin:mainfrom
Wid-L-Hacker:conrad/lazycurl-global-init-guard

Conversation

@mlin

@mlin mlin commented Nov 8, 2026

Copy link
Copy Markdown
Owner

In the lazy-curl configuration, concurrent first opens raced in libcurl's global initialization (thread-sanitizer reports on every cold start). Run it once per process behind a once-guard, in both the lazy and direct configurations; a failed initialization is reported to later callers instead of being retried on each open.

Verified: thread-sanitizer cold-start launches go from 14 race reports per launch (10 of 10 launches) to zero across the lazy, direct, and warm configurations; the native test suite passes.

@Wid-L-Hacker
Wid-L-Hacker force-pushed the conrad/lazycurl-global-init-guard branch from cf5d16b to 9cc140a Compare November 8, 2026 05:16
Every open called HTTP::global_init(). In the lazy-curl
configuration the loader's shared state (the dlopen handle and
the symbol table) was unsynchronized, so concurrent first opens
raced through it and could invoke curl_global_init()
concurrently, which libcurl does not support.

Keep the per-configuration initialization as an implementation
helper and call it under std::call_once: exactly one call runs
per process, and every caller gets its result. A failed
initialization is now reported to later callers instead of
being retried on each open.
@Wid-L-Hacker
Wid-L-Hacker force-pushed the conrad/lazycurl-global-init-guard branch from 9cc140a to 6f2fd5e Compare November 8, 2026 05:17
@mlin
mlin merged commit dc6e911 into mlin:main Nov 8, 2026
5 checks passed
@mlin
mlin deleted the conrad/lazycurl-global-init-guard branch November 8, 2026 05:53
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