Skip to content

fix: use static C strings for cached HTTP methods - #2789

Merged
dunglas merged 1 commit into
mainfrom
fix/lsan-http-method-strings
Oct 30, 2026
Merged

dunglas merged 1 commit into
mainfrom
fix/lsan-http-method-strings

Conversation

@dunglas

@dunglas dunglas commented Oct 29, 2026

Copy link
Copy Markdown
Member

The HTTP method strings cached at package init were allocated with `C.CString` and only referenced from a Go map. LeakSanitizer doesn't scan Go memory in libFuzzer builds, so OSS-Fuzz reports them as a direct leak (53 bytes in 9 objects) in every fuzz target: https://issues.oss-fuzz.com/issues/578554565

This makes them static C literals. They live in a new file because `cgi.go` uses `//export`, which forbids definitions in its preamble.

Reproduced with the OSS-Fuzz build (go-118-fuzz-build + clang `-fsanitize=fuzzer,address`): the leak is reported on `main` and gone with this patch.

C.CString allocations kept only in a Go map are invisible to LeakSanitizer,
which reports them as direct leaks in every fuzz target (OSS-Fuzz issue 578554565).
@dunglas
dunglas merged commit c10c03a into main Oct 30, 2026
45 of 46 checks passed
@dunglas
dunglas deleted the fix/lsan-http-method-strings branch October 30, 2026 10:22
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