New issue
Advanced search Search tips

Issue 766903 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

Supersize does not demangle all symbols

Project Member Reported by agrieve@chromium.org, Sep 20 2017

Issue description

Just noticed that:

>>> Print(size_info.symbols.WhereNameMatches(r'^_Z'))
Showing 3,168 symbols (2,770 unique) with total pss: 172807 bytes
.text=166kb      .data.rel.ro=2.69kb     .data=3 bytes    .bss=332 bytes  total=168kb
Number of unique paths: 1201

Section Legend: t=.text, R=.data.rel.ro, d=.data, b=.bss
Index | Running Total | Section@Address | PSS | Path
------------------------------------------------------------
0)        282 (0.2%)  t@0x2f6498   282            base/strings/utf_string_conversions.cc
             _ZNSt6__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignIPKtEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueERS5_E4typeESA_SA_
1)        304 (0.2%)  t@0x2fc6a8   22             content/app/android/content_main.cc
             _ZN4base10MakeUniqueIN7content33ContentServiceManagerMainDelegateEJNS1_17ContentMainParamsEEEEDTclsr3stdE11make_uniqueIT_Espclsr3stdE7forwardIT0_Efp_EEEDpOS5_
2)        330 (0.2%)  t@0x2fe384   26             chrome/browser/chrome_content_browser_client.cc
             _ZN4base10MakeUniqueIN15service_manager14CallbackBinderIN7metrics5mojom25CallStackProfileCollectorEJEEEJRKNS_17RepeatingCallbackIFvN4mojo16InterfaceRequestIS5_EEEEERK13scoped_refptrINS_19SequencedTaskRunnerEEEEEDTclsr3stdE11make_uniqueIT_Espclsr3stdE7forwardIT0_Efp_EEEDpOSL_
...

Interestingly, c++filt is not able to demangle these:
echo '_ZNSt6__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignIPKtEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueERS5_E4typeESA_SA_' | c++filt
_ZNSt6__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignIPKtEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueERS5_E4typeESA_SA_


demumble is likewise confused by them:
echo '_ZSt5__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignIPKtEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueERS5_E4typeESA_SA_' | demumble
_ZSt5__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignIPKtEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueERS5_E4typeESA_SA_
 
thakis - Does your experience with demangling lead to you know what's wrong with these names? Other non-demanglable names I've come across were just the result of an obvious prefix/suffix added on by the linker. No idea what's wrong with these though.

Comment 2 by thakis@chromium.org, Sep 20 2017

My unverified guess is that this is a new c++14 mangling that demumble's itanium demangler is too old for. You could try cloning it and putting in the most recent demangler from libcxx(abi?) and see if that helps.
demumble isn't confused on my system:

$ ./demumble _ZNSt6__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignIPKtEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueERS5_E4typeESA_SA_
std::__ndk1::enable_if<__is_forward_iterator<unsigned short const*>::value, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >&>::type std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >::assign<unsigned short const*>(unsigned short const*, unsigned short const*)

Maybe your demumble doesn't have 9628c34f00dc25755954ee47383a5a55fed8389d (from may 2016)? That updated cxa_demangle

Comment 5 by hua...@chromium.org, Oct 16 2017

Clang's demangler seems to work for the first string. To build:

  tools/clang/scripts/update.py --force-local-build

or, if warning appears:

  tools/clang/scripts/update.py --force-local-build --without-android

To use:

  third_party/llvm-build/Release+Asserts/bin/llvm-cxxfilt _ZNSt6__ndk112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignIPKtEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueERS5_E4typeESA_SA_

Output:

std::__ndk1::enable_if<__is_forward_iterator<unsigned short const*>::value, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >&>::type std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >::assign<unsigned short const*>(unsigned short const*, unsigned short const*)

However, the '_ZSt5__ndk112..." string does not work.

Comment 6 by huangs@google.com, Dec 17 2017

For the _ZSt5__ndk112... case, it's only difference from the other case is '_ZSt5' vs. '_ZNSt6". It appears to be malformed:

- 'N' stands for nested name, and is terminated by 'E':
<nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
              ::= N [<CV-qualifiers>] <template-prefix> <template-args> E

- 5 vs. 6 is name of token, which in this case is '__ndk1', i.e., length-6.

So this should be a toolchain bug, not SuperSize bug.
Project Member

Comment 7 by sheriffbot@chromium.org, Dec 17

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: estevenson@chromium.org agrieve@chromium.org
Owner: hua...@chromium.org
Status: Assigned (was: Untriaged)
In 918716 estevenson@ found more (new?) examples of demangle failure, e.g., 

   _ZN12_GLOBAL__N_124AAFlatteningConvexPathOp19onCombineIfPossibleEP4GrOpRK6GrCaps$39a714be4038aec63642597f522dad6f

The key feature here is '$' followed by 32 hex digits.

Naively stripping anything after '$' is undesirable because there are symbols that contain '$'!

It seems adequate to just detect and strip trailing '$' followed by 32 hex digits when we demangle.
Project Member

Comment 9 by bugdroid1@chromium.org, Jan 7

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b919b3c6065c47953cf9d0f66f0689dcb7799db8

commit b919b3c6065c47953cf9d0f66f0689dcb7799db8
Author: Samuel Huang <huangs@chromium.org>
Date: Mon Jan 07 19:06:55 2019

[SuperSize] Strip hex hash suffixes of symbol before demangling.

Chrome APK still has ~9100 symbols that start with '_Z' for
which SuperSize fails to demangle. The failure is due to the presence
of a length-33 suffix, consisting of '$' followed by 32 lowercase hex
digits.

This CL updates demangle.py to detect and strip these suffixes, so
symbols can properly demangle.

Bug: 766903
Change-Id: I6a039219624a6cc4ed29742bae417d19e329ca6c
Reviewed-on: https://chromium-review.googlesource.com/c/1396600
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: Samuel Huang <huangs@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#620408}
[modify] https://crrev.com/b919b3c6065c47953cf9d0f66f0689dcb7799db8/tools/binary_size/libsupersize/demangle.py

Comment 10 by hua...@chromium.org, Jan 21 (2 days ago)

 Issue 746993  has been merged into this issue.

Comment 12 by agrieve@chromium.org, Yesterday (46 hours ago)

re #11 - I don't think it's a demangling issue. Just filed bug 923936 to track that one.

Sign in to add a comment