vquic: silence -Wmissing-field-initializers for nghttp3/ngtcp2 callback tables - #22400
vquic: silence -Wmissing-field-initializers for nghttp3/ngtcp2 callback tables#22400vszakats wants to merge 1 commit into
-Wmissing-field-initializers for nghttp3/ngtcp2 callback tables#22400Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces build noise in the HTTP/3 (QUIC) implementation by locally suppressing -Wmissing-field-initializers warnings triggered by nghttp3/ngtcp2 callback table initializers, using the existing CURL_HAVE_DIAG-guarded diagnostic pragmas.
Changes:
- Wrap
nghttp3_callbacksinitializer incf-ngtcp2.cwith#pragma GCC diagnostic push/popand ignore-Wmissing-field-initializerswhen supported. - Apply the same suppression to the nghttp3 proxy callback table in
cf-ngtcp2-proxy.c. - Apply the same suppression to the ngtcp2 callback table in
cf-ngtcp2-cmn.c.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/vquic/cf-ngtcp2.c | Silences -Wmissing-field-initializers around the nghttp3 callback table initialization (guarded by CURL_HAVE_DIAG). |
| lib/vquic/cf-ngtcp2-proxy.c | Silences -Wmissing-field-initializers around the nghttp3 proxy callback table initialization (guarded by CURL_HAVE_DIAG). |
| lib/vquic/cf-ngtcp2-cmn.c | Silences -Wmissing-field-initializers around the ngtcp2 callback table initialization (guarded by CURL_HAVE_DIAG). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Trying a different approach. |
This comment was marked as outdated.
This comment was marked as outdated.
-Wmissing-field-initializers for nghttp3/ngtcp2 callback tables-Wmissing-field-initializers when setting up callback tables
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
lib/vquic/cf-ngtcp2.c:397
cbis a function-scopestaticcallbacks struct that is written to on every call. If multiple nghttp3 connections are initialized concurrently from different threads, these writes race on shared state (undefined behavior), even though the assigned function pointers are constant.
Consider keeping the callbacks immutable (initialized once and never modified) or storing the callbacks struct in the per-connection ctx so each connection has its own instance and there are no shared writes.
static nghttp3_callbacks cb = { 0 };
int rc;
if(ngtcp2_conn_get_streams_uni_left(ctx->qconn) < 3) {
failf(data, "QUIC connection lacks 3 uni streams to run HTTP/3");
lib/vquic/cf-ngtcp2-proxy.c:612
cbis a function-scopestaticcallbacks struct that is written to on every call. If multiple nghttp3 connections are initialized concurrently from different threads, these writes race on shared state (undefined behavior), even though the assigned function pointers are constant.
Consider keeping the callbacks immutable (initialized once and never modified) or storing the callbacks struct in the per-connection ctx so each connection has its own instance and there are no shared writes.
static nghttp3_callbacks cb = { 0 };
int rc;
if(ngtcp2_conn_get_streams_uni_left(ctx->qconn) < 3) {
failf(data, "QUIC connection lacks 3 uni streams to run HTTP/3");
lib/vquic/cf-ngtcp2-cmn.c:891
cbis a function-scopestaticcallbacks struct that is written to on every call. If multiple QUIC connections are created concurrently from different threads, these writes race on shared state (undefined behavior), even though the assigned function pointers are constant.
Consider making the callbacks table immutable (initialized once and never modified) or storing it per-connection (in ctx) to avoid shared mutable state.
static ngtcp2_callbacks cb = { 0 };
static const struct alpn_spec ALPN_SPEC_H3 = { { "h3", "h3-29" }, 2 };
DEBUGASSERT(ctx->initialized);
ctx->dcid.datalen = NGTCP2_MAX_CIDLEN;
-Wmissing-field-initializers when setting up callback tables-Wmissing-field-initializers on callback table init
-Wmissing-field-initializers on callback table init-Wmissing-field-initializers for callback tables
-Wmissing-field-initializers for callback tables-Wmissing-field-initializers for nghttp3/ngtcp2 callback tables
To avoid a breakage in CI and curl-for-win builds on upstream updates
extending the callback lists. Each such breakage needed patching curl,
rolling these patches into curl-for-win, and doing it in near real-time,
to keep CI and builds working (and still causing some red CI jobs).
Bring calmness here by suppressing the warnings and allowing time to
extend the callback tables as/if needed and at a convenient moment.
Also explored the option to dynamically setup the the callbacks, but
the libraries need a static callback table before nghttp3 v1.11.0+ and
ngctp2 v1.14.0+ which made this unnecessarily complex.
nghttp3 1.18.0 causing two pytests to fail.
Possibly due to ngtcp2/nghttp3#539. → PR #22402