Skip to contentSkip to conversation

systemtap: Disable dangling-pointer warning

PATCH In review Khem Raj 2 participants 2 messages Mar 14, 2023 – Mar 24, 2023

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 systemtap: Disable dangling-pointer warning

This is to fix build in RISCV64

| In constructor 'symresolution_info::symresolution_info(systemtap_session&, bool)',
|     inlined from 'int semantic_pass_symbols(systemtap_session&)' at ../git/elaborate.cxx:1884:28:
| ../git/elaborate.cxx:2601:21: error: storing the address of local variable 'sym' in '*s.systemtap_session::symbol_resolver' [-Werror=dangling-pointer=]
|  2601 |   s.symbol_resolver = this; // save resolver for early PR25841 function resolution
|       |   ~~~~~~~~~~~~~~~~~~^~~~~~
| ../git/elaborate.cxx: In function 'int semantic_pass_symbols(systemtap_session&)':
| ../git/elaborate.cxx:1884:22: note: 'sym' declared here
|  1884 |   symresolution_info sym (s);
|       |                      ^~~
| ../git/elaborate.cxx:1884:22: note: 's' declared here
---
 meta/recipes-kernel/systemtap/systemtap_git.bb | 3 +++
 1 file changed, 3 insertions(+)
meta/recipes-kernel/systemtap/systemtap_git.bb +3 -0
index 072fcb310a..d320a8a5e0 100644
@@ -34,6 +34,9 @@ PACKAGECONFIG[python3-probes] = "--with-python3-probes,--without-python3-probes,
 inherit autotools gettext pkgconfig systemd
 inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3-probes', 'setuptools3-base', '', d)}
 
+# | ../git/elaborate.cxx:2601:21: error: storing the address of local variable 'sym' in '*s.systemtap_session::symbol_resolver' [-Werror=dangling-pointer=]
+CXXFLAGS += "-Wno-dangling-pointer"
+
 # exporter comes with python3-probes
 PACKAGES =+ "${PN}-exporter"
 FILES:${PN}-exporter = "${sysconfdir}/stap-exporter/* \
Signature · 1 line
2.40.0
#1 lore raw
Quoted 11 lines · Khem Raj

This is to fix build in RISCV64

| In constructor 'symresolution_info::symresolution_info(systemtap_session&, bool)',
| inlined from 'int semantic_pass_symbols(systemtap_session&)' at
../git/elaborate.cxx:1884:28:
| ../git/elaborate.cxx:2601:21: error: storing the address of local variable 'sym' in '*s.systemtap_session::symbol_resolver' [-Werror=dangling-pointer=]
| 2601 | s.symbol_resolver = this; // save resolver for early PR25841
function resolution

Quoted 8 lines
|       |   ~~~~~~~~~~~~~~~~~~^~~~~~
| ../git/elaborate.cxx: In function 'int
semantic_pass_symbols(systemtap_session&)':
| ../git/elaborate.cxx:1884:22: note: 'sym' declared here
|  1884 |   symresolution_info sym (s);
|       |                      ^~~
| ../git/elaborate.cxx:1884:22: note: 's' declared here

FWIW: this isn't specific to RISCV64, I had the same in my branch for a while and I was seeing it on qemux86:

But it was introduced only in newer gcc-13 snapshots, from my commit message:

* since newer gcc-13 snapshot it detects dangling-pointer and fails due
to Werror
git/elaborate.cxx:2601:21: error: storing the address of local
variable 'sym' in '*s.systemtap_session::symbol_resolver' [-Werror=dangling-pointer=]

* the check was improved recently, probably in one of these:
gcc $ git log --oneline
a1292514f898e3d3f34fd843b967f72b779aaa88..6aa1f40a3263741d964ef4716e85a0df5cec83b6 | grep -i dangling
fdac2bea53b -Wdangling-pointer: don't mark SSA lhs sets as stores 916ce577ad1 libstdc++: Implement P2255R2 dangling checks for
std::pair
d482b20fd34 warn-access: wrong -Wdangling-pointer with labels
[PR106080]