Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addr2line.c: fix DW_FORM_ref_addr parsing for DWARF 2 #8146

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Jul 31, 2023

This fixes a crash when retrieving backtrace info with YJIT enabled on macOS with Rust 1.71.0.

Since Rust 1.71.0, the DWARF info generated by the Rust compiler uses DW_FORM_ref_addr instead of DW_FORM_ref4 for pointers to other DIEs. DW_FORM_ref_addr representation in DWARF 2 differs from DWARF 3+, so we need to handle it separately.

This patch fixes the parsing of DW_FORM_ref_addr for DWARF 2, which is the default DWARF version Rustc uses on macOS.

See the DWARF 2.0.0 spec, section 7.5.4 Attribute Encodings https://dwarfstd.org/doc/dwarf-2.0.0.pdf

https://bugs.ruby-lang.org/issues/19789

@maximecb
Copy link
Contributor

Thank you for tackling this @kateinoigakukun 👌

@maximecb maximecb requested a review from XrXr July 31, 2023 16:09
addr2line.c Outdated Show resolved Hide resolved
This fixes a crash when retrieving backtrace info with YJIT enabled on
macOS with Rust 1.71.0. Since Rust 1.71.0, the DWARF info generated by
the Rust compiler uses DW_FORM_ref_addr instead of DW_FORM_ref4 for
pointers to other DIEs.
DW_FORM_ref_addr representation in DWARF 2 is different from DWARF 3+,
so we need to handle it separately.
This patch fixes the parsing of DW_FORM_ref_addr for DWARF 2, which is
the default DWARF version Rustc uses on macOS.

See the DWARF 2.0.0 spec, section 7.5.4 Attribute Encodings
https://dwarfstd.org/doc/dwarf-2.0.0.pdf

https://bugs.ruby-lang.org/issues/19789
@maximecb maximecb merged commit 954b7ac into ruby:master Jul 31, 2023
89 checks passed
@kateinoigakukun kateinoigakukun deleted the katei/fix-addr2line-on-darwin branch August 1, 2023 01:09
matzbot pushed a commit that referenced this pull request Aug 12, 2023
	addr2line.c: fix `DW_FORM_ref_addr` parsing for DWARF 2 (#8146)

	addr2line.c: fix DW_FORM_ref_addr parsing for DWARF 2

	This fixes a crash when retrieving backtrace info with YJIT enabled on
	macOS with Rust 1.71.0. Since Rust 1.71.0, the DWARF info generated by
	the Rust compiler uses DW_FORM_ref_addr instead of DW_FORM_ref4 for
	pointers to other DIEs.
	DW_FORM_ref_addr representation in DWARF 2 is different from DWARF 3+,
	so we need to handle it separately.
	This patch fixes the parsing of DW_FORM_ref_addr for DWARF 2, which is
	the default DWARF version Rustc uses on macOS.

	See the DWARF 2.0.0 spec, section 7.5.4 Attribute Encodings
	https://dwarfstd.org/doc/dwarf-2.0.0.pdf

	https://bugs.ruby-lang.org/issues/19789
	---
	 addr2line.c | 40 ++++++++++++++++++++++++++--------------
	 1 file changed, 26 insertions(+), 14 deletions(-)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants