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

Some g++ symbols aren't demangled (.localalias & .cold) #869

Closed
blackgnezdo opened this issue Nov 4, 2022 · 5 comments
Closed

Some g++ symbols aren't demangled (.localalias & .cold) #869

blackgnezdo opened this issue Nov 4, 2022 · 5 comments

Comments

@blackgnezdo
Copy link

I linked glog 0.6.0 using this NixOS recipe (with gflags dependency removed) into my c++ application. I see a stack trace with some C++ symbols properly demangled while a few remain mangled (and good enough for c++filt to decode). E.g.


    @     0x7f051d8a618a _ZN4mlir6detail17OpToOpPassAdaptor3runEPNS_4PassEPNS_9OperationENS_15AnalysisManagerEbj.localalias
    @     0x7f051d8a6599 _ZN4mlir6detail17OpToOpPassAdaptor11runPipelineERNS_13OpPassManagerEPNS_9OperationENS_15AnalysisManagerEbjPNS_16PassInstrumentorEPKNS_19PassInstrumentation18PipelineParentInfoE.localalias
    @     0x7f051d8a54ef _ZN4mlir6detail17OpToOpPassAdaptor23runOnOperationAsyncImplEb.localalias
    @     0x7f051d8a5fd4 _ZN4mlir6detail17OpToOpPassAdaptor3runEPNS_4PassEPNS_9OperationENS_15AnalysisManagerEbj.localalias
    @     0x7f051d8a6599 _ZN4mlir6detail17OpToOpPassAdaptor11runPipelineERNS_13OpPassManagerEPNS_9OperationENS_15AnalysisManagerEbjPNS_16PassInstrumentorEPKNS_19PassInstrumentation18PipelineParentInfoE.localalias
    @     0x7f051d8a7420 mlir::PassManager::run()
    @           0x525cf8 main
    @     0x7f05088e2790 __libc_start_main
    @           0x5c3e7a _start

which after c++filt become a pleasant to read

    @     0x7f051d8a618a mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) [clone .localalias]
    @     0x7f051d8a6599 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) [clone .localalias]
    @     0x7f051d8a54ef mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) [clone .localalias]
    @     0x7f051d8a5fd4 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) [clone .localalias]
    @     0x7f051d8a6599 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) [clone .localalias]
    @     0x7f051d8a7420 mlir::PassManager::run()
    @           0x525cf8 main
    @     0x7f05088e2790 __libc_start_main
    @           0x5c3e7a _start

I activate the stack trace with google::InstallFailureSignalHandler(); no further flags or configuration.

Is there some kind of limit on the length of mangled identifiers or some other option I'm missing?

@blackgnezdo
Copy link
Author

I played a bit with demangle unit test and looks like the failure is due to the missing .localalias support. This test shows the missing functionality:

diff --git a/src/demangle_unittest.cc b/src/demangle_unittest.cc
index ddc90b0..d3d8b52 100644
--- a/src/demangle_unittest.cc
+++ b/src/demangle_unittest.cc
@@ -121,6 +121,8 @@ TEST(Demangle, Clones) {
   EXPECT_FALSE(Demangle("_ZL3Foov.clone.foo", tmp, sizeof(tmp)));
   // Invalid (.constprop. not followed by number), should not demangle.
   EXPECT_FALSE(Demangle("_ZL3Foov.isra.2.constprop.", tmp, sizeof(tmp)));
+  char large[256];
+  EXPECT_TRUE(Demangle("_ZN4mlir6detail17OpToOpPassAdaptor3runEPNS_4PassEPNS_9OperationENS_15AnalysisManagerEbj.localalias", large, sizeof(large)));
 }
 
 TEST(Demangle, FromFile) {

The test passes if I e.g. remove .localalias suffix.

@blackgnezdo blackgnezdo changed the title Some c++ symbols aren't demangled .localalias c++ symbols aren't demangled Nov 4, 2022
@blackgnezdo
Copy link
Author

A very naive way to make the test pass would be to add

diff --git a/src/demangle.cc b/src/demangle.cc
index 9276c5b..528a4ee 100644
--- a/src/demangle.cc
+++ b/src/demangle.cc
@@ -303,6 +303,7 @@ static bool IsDigit(char c) {
 // a function clone suffix.
 static bool IsFunctionCloneSuffix(const char *str) {
   size_t i = 0;
+  if (strcmp(str, ".localalias") == 0) return true;
   while (str[i] != '\0') {
     // Consume a single .<alpha>+.<digit>+ sequence.
     if (str[i] != '.' || !IsAlpha(str[i + 1])) {

@blackgnezdo
Copy link
Author

I noticed another similar case, this time it's a different suffix: _ZN9__gnu_cxx27__verbose_terminate_handlerEv.cold. Looks like a more complete fix would be to allow mostly arbitrary alpha+ suffixes without requiring they are followed by number+.

@blackgnezdo blackgnezdo changed the title .localalias c++ symbols aren't demangled Some g++ symbols aren't demangled (.localalias & .cold) Nov 4, 2022
@sergiud
Copy link
Collaborator

sergiud commented Jan 3, 2024

The glog native demangler is pretty much incomplete and should be regarded as obsolete.

glog 0.7.0 will introduce the use of GCC/LLVM provided ABI demangler which will solve als these issues.

@sergiud
Copy link
Collaborator

sergiud commented Jan 3, 2024

#1023 has landed in master. Please give it a try.

@sergiud sergiud closed this as completed Jan 3, 2024
martonka added a commit to martonka/kudu_wd that referenced this issue Aug 28, 2024
Glog 0.6.0 can't resolve .localalias & .cold symbols.
google/glog#869
It causes the stack trace to contain raw symbols.
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

No branches or pull requests

2 participants