Skip to content

Comments

Remove DwarfReader::DetectSourceLanguage API to address issues with multi language binaries#2228

Merged
ddelnano merged 4 commits intopixie-io:mainfrom
ddelnano:ddelnano/handle-multi-language-debug_info
Jul 16, 2025
Merged

Remove DwarfReader::DetectSourceLanguage API to address issues with multi language binaries#2228
ddelnano merged 4 commits intopixie-io:mainfrom
ddelnano:ddelnano/handle-multi-language-debug_info

Conversation

@ddelnano
Copy link
Member

@ddelnano ddelnano commented Jul 10, 2025

Summary: Remove DwarfReader::DetectSourceLanguage API to address issues with multi language binaries

Our previous DwarfReader::DetectSourceLanguage API assumes that a binary contains a single type of DW_AT_language attribute -- meaning a Go binary would include only DIEs with DW_AT_language=DW_LANG_Go. With our upgrade to Go 1.24, this assumption is no longer true. For example, Go binaries built under ASAN contain a variety of DW_AT_language attribute values depending on the DIE compile unit (see Test plan output).

This PR removes this API and updates all callers to determine their use case's language from the relevant compile unit DIE.

Relevant Issues: N/A

Type of change: /kind bugfix

Test Plan: Verified that the tests introduced in commit 1 fail w/ ASAN enabled. New APIs fix the build

verification steps
# Tests fail under ASAN since C/C++ ABI is incorrectly assumed
(17a0121d7...)$ bazel test --config asan  src/stirling/source_connectors/socket_tracer:uprobe_symaddrs_test --test_output=all --nocache_test_results

[==========] Running 4 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 3 tests from UprobeSymaddrsTest
[ RUN      ] UprobeSymaddrsTest.GoCommonSymAddrs
[       OK ] UprobeSymaddrsTest.GoCommonSymAddrs (1768 ms)
[ RUN      ] UprobeSymaddrsTest.GoHTTP2SymAddrs
src/stirling/source_connectors/socket_tracer/uprobe_symaddrs_test.cc:83: Failure
Expected equality of these values:
  symaddrs.writeHeader_hf_ptr_loc
    Which is: type=kLocationTypeStack offset=8
  (location_t{.type = kLocationTypeRegisters, .offset = 24})
    Which is: type=kLocationTypeRegisters offset=24
[  FAILED  ] UprobeSymaddrsTest.GoHTTP2SymAddrs (1728 ms)
[ RUN      ] UprobeSymaddrsTest.GoTLSSymAddrs
src/stirling/source_connectors/socket_tracer/uprobe_symaddrs_test.cc:94: Failure
Expected equality of these values:
  symaddrs.Write_b_loc
    Which is: type=kLocationTypeStack offset=8
  (location_t{.type = kLocationTypeRegisters, .offset = 8})
    Which is: type=kLocationTypeRegisters offset=8
src/stirling/source_connectors/socket_tracer/uprobe_symaddrs_test.cc:96: Failure
Expected equality of these values:
  symaddrs.Read_b_loc
    Which is: type=kLocationTypeStack offset=8
  (location_t{.type = kLocationTypeRegisters, .offset = 8})
    Which is: type=kLocationTypeRegisters offset=8
[  FAILED  ] UprobeSymaddrsTest.GoTLSSymAddrs (1613 ms)
[----------] 3 tests from UprobeSymaddrsTest (5110 ms total)

[----------] 1 test from UprobeSymaddrsNodeTest
[ RUN      ] UprobeSymaddrsNodeTest.TLSWrapSymAddrsFromDwarfInfo
[       OK ] UprobeSymaddrsNodeTest.TLSWrapSymAddrsFromDwarfInfo (1 ms)
[----------] 1 test from UprobeSymaddrsNodeTest (1 ms total)

[----------] Global test environment tear-down
[==========] 4 tests from 2 test suites ran. (5111 ms total)
[  PASSED  ] 2 tests.
[  FAILED  ] 2 tests, listed below:
[  FAILED  ] UprobeSymaddrsTest.GoHTTP2SymAddrs
[  FAILED  ] UprobeSymaddrsTest.GoTLSSymAddrs

 2 FAILED TESTS
I20250710 06:18:14.281155    12 env.cc:51] Shutting down
================================================================================
Target //src/stirling/source_connectors/socket_tracer:uprobe_symaddrs_test up-to-date:
  bazel-bin/src/stirling/source_connectors/socket_tracer/uprobe_symaddrs_test
INFO: Elapsed time: 5.657s, Critical Path: 5.38s
INFO: 2 processes: 1 internal, 1 linux-sandbox.
INFO: Build completed, 1 test FAILED, 2 total actions
//src/stirling/source_connectors/socket_tracer:uprobe_symaddrs_test      FAILED in 5.4s
  /home/ddelnano/.cache/bazel/_bazel_ddelnano/fa8604ca46879b9b1ffd44d337c531f3/execroot/px/bazel-out/k8-fastbuild/testlogs/src/stirling/source_connectors/socket_tracer/uprobe_symaddrs_test/test.log

Executed 1 out of 1 test: 1 fails locally.

# Verify ASAN build has DIEs with different DW_AT_language attributes

(17a0121d7...) $ bazel build --config asan src/stirling/testing/demo_apps/go_grpc_tls_pl/server:golang_1_24_grpc_tls_server_binary
(17a0121d7...) $ llvm-dwarfdump bazel-bin/src/stirling/testing/demo_apps/go_grpc_tls_pl/server/golang_1_24_grpc_tls_server_binary | grep DW_AT_lang | uniq -c
      1               DW_AT_language    (DW_LANG_C_plus_plus_14)
      1               DW_AT_language    (DW_LANG_Mips_Assembler)
     22               DW_AT_language    (DW_LANG_C_plus_plus_14)
      1               DW_AT_language    (DW_LANG_Mips_Assembler)
     48               DW_AT_language    (DW_LANG_C_plus_plus_14)
    280               DW_AT_language    (DW_LANG_Go)

# Verify non ASAN builds have only one DW_AT_language attribute
(17a0121d7...) $ bazel build  src/stirling/testing/demo_apps/go_grpc_tls_pl/server:golang_1_24_grpc_tls_server_binary
(17a0121d7...) $ llvm-dwarfdump bazel-bin/src/stirling/testing/demo_apps/go_grpc_tls_pl/server/golang_1_24_grpc_tls_server_binary | grep DW_AT_lang | uniq -c
    281               DW_AT_language    (DW_LANG_Go)

ddelnano added 2 commits July 10, 2025 06:17
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
@ddelnano ddelnano requested a review from a team as a code owner July 10, 2025 13:56
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
@ddelnano ddelnano merged commit 1ad28c4 into pixie-io:main Jul 16, 2025
27 checks passed
@ddelnano ddelnano deleted the ddelnano/handle-multi-language-debug_info branch July 16, 2025 17:26
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