integ-tests/go/orchestrion-repro/README.md
This directory contains a minimal reproduction case for issue #2575: SIGSEGV when using BAML with Datadog Orchestrion.
When building a Go application with BAML and Datadog's Orchestrion APM instrumentation, a segmentation violation occurs during initialization when BAML attempts to download its native library.
Error: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0xf992ec]
This test program:
cd /path/to/baml/integ-tests/go
make build-docker
make run-docker
Or with debug logging:
make debug-docker
cd /path/to/baml/integ-tests/go
make test
# First install orchestrion
go install github.com/DataDog/[email protected]
# Then build
cd /path/to/baml/integ-tests/go
make build
./app
✅ Successfully reproduced the SIGSEGV!
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0xdccbcc]
goroutine 1 [running]:
github.com/DataDog/dd-trace-go/v2/instrumentation.(*Instrumentation).AnalyticsRate(...)
/go/pkg/mod/github.com/!data!dog/dd-trace-go/[email protected]/instrumentation/instrumentation.go:97
init()) runs when the package is first importedlibbaml_cffi-aarch64-unknown-linux-gnu.so.sha256ObserveRoundTrip()Instrumentation.AnalyticsRate() with a nil pointerinstrumentation.go:97The crash occurs in Orchestrion's HTTP instrumentation layer before BAML can complete its first network request. The issue is in dd-trace-go/contrib/net/http/v2/internal/orchestrion/roundtrip.go:38 where it attempts to configure HTTP tracing but the instrumentation object is not properly initialized.
This happens during package initialization (in an init() function), which may be too early for Orchestrion's instrumentation to be fully set up.
The Dockerfile already builds with -work flag. To inspect the transformed code:
# Build the image targeting only the build stage
cd /path/to/baml
docker build --target build -t baml-orchestrion-build \
-f integ-tests/go/orchestrion-repro/Dockerfile .
# List all orchestrion transformation directories
docker run --rm baml-orchestrion-build \
find /build/orchestrion-work -type d -name "orchestrion"
# View the modified main.go
docker run --rm baml-orchestrion-build \
cat /build/orchestrion-work/b001/orchestrion/src/main/main.go
# View the modified HTTP roundtrip code
docker run --rm baml-orchestrion-build \
cat /build/orchestrion-work/b103/orchestrion/src/net/http/roundtrip.go
# Find all HTTP-related modifications
docker run --rm baml-orchestrion-build \
find /build/orchestrion-work -path "*/orchestrion/src/*" -name "*.go" | \
grep -E "(http|transport)"
Run the container with debug logging:
docker run --rm \
-e ORCHESTRION_LOG_LEVEL=DEBUG \
-e BAML_LOG=DEBUG \
baml-orchestrion-repro
If testing locally with orchestrion installed:
cd /path/to/baml/integ-tests/go
orchestrion go build -work -o app ./orchestrion-repro
# The WORK= directory will be printed
# Inspect: ls $WORK_DIR/*/orchestrion/src/
./app
To investigate further or work around this issue:
BAML_LIBRARY_PATH to a pre-downloaded library file to skip the download during initBAML_LIBRARY_DISABLE_DOWNLOAD=true and provide the library via other meansorchestrion go build -work to inspect the instrumented codemain.go - Minimal BAML test program that triggers the crashDockerfile - Multi-stage build with Orchestrion (based on issue #2575)Makefile - Build and test helpersREADME.md - This file.dockerignore - Excludes large build artifacts from Docker context