fix(ddtrace/tracer): make SpanAttributes layout assertion architecture-aware (#4984)#5008
fix(ddtrace/tracer): make SpanAttributes layout assertion architecture-aware (#4984)#5008kakkoyun wants to merge 5 commits into
Conversation
…itecture-aware The compile-time layout guard hardcoded the struct size as 56 bytes, which only holds where string is 16 bytes wide (64-bit). On 32-bit first-class Go ports (386, arm) string is 8 bytes, so the struct is 28 bytes and the array-index assertion underflows at compile time, breaking every importer. Derive the expected size from the types themselves (offset of vals + size of the vals array) so the no-trailing-padding invariant holds on every architecture.
Config Audit |
b5de61d to
c04b37d
Compare
|
The test matrix only ran on native 64-bit runners, so no 32-bit port was ever built and #4984 shipped undetected. Add a cross-compile smoke test over every first-class Go port, run on a normal amd64 runner since portability is a compile-time property. Packages importing go-libddwaf are skipped: it does not yet build on 32-bit (fix pending upstream). They stay covered on 64-bit by the native matrix.
c04b37d to
58faef3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c04b37d029
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
BenchmarksBenchmark execution time: 2026-07-10 08:47:49 Comparing candidate commit ea96af2 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 326 metrics, 0 unstable metrics, 1 flaky benchmarks without significant changes.
|
Run go list in a command substitution so a discovery failure aborts under set -e (process substitution swallowed the exit status, letting the build proceed with an empty package list). Guard against an empty result, and document the check in CONTRIBUTING.md.
What
Fix a 32-bit compile failure (#4984) and add a cross-compile CI guard so it cannot regress.
ddtrace/tracer/internal/span_attributes.gohad a compile-time layout guard that hardcoded the struct size as56bytes:56only holds wherestringis 16 bytes (64-bit). On 32-bit first-class ports (386,arm)stringis 8 bytes, the struct is 28 bytes, and the assertion underflows at compile time:Every importer targeting a 32-bit port fails to build.
How
unsafe.Offsetof(vals) + unsafe.Sizeof([numAttrs]string{})). This asserts the real invariant — no trailing padding — and is correct on every architecture.scripts/cross_build.shcross-compiles the library for every first-class Go port, wired intostatic-checks.yml. The existing matrix only ran native 64-bit runners, so no 32-bit port was ever built — which is how this shipped. Cross-compilation needs no native 32-bit machine; portability is a compile-time property.Packages importing
go-libddwafare skipped: it does not yet compile on 32-bit (fix pending upstream, DataDog/go-libddwaf#227). They remain covered on 64-bit by the native test matrix. The exclusion is removed once the upstream fix lands.Test plan
GOOS=windows GOARCH=386 CGO_ENABLED=0 go build ./ddtrace/tracer/internal/fails; after fix it succeeds../scripts/cross_build.sh— 100 packages build across all 8 first-class ports.go test -race ./ddtrace/tracer/internal/passes (64-bit assertion still holds at 56 bytes).gofmt,shellcheck,actionlintclean.Note: runtime AppSec/WAF is unaffected — it is already gated off on unsupported architectures (
internal/appsec/appsec.gocheckslibddwaf.Usable()and degrades gracefully). This change only restores the ability to compile for 32-bit ports.