[lldb-dev] Huge mangled names are causing long delays when loading symbol table symbols
Pavel Labath via lldb-dev
lldb-dev at lists.llvm.org
Thu Jan 25 02:40:05 PST 2018
The mangled name length threshold would be the easiest to implement.
However, I fear we may not be able to find a good cutoff length,
because it's not the length of it that matters, but the number (and
recursiveness) of back-references. For example, I was able to find a
mangled name of 757 characters in lldb:
This demangles string of lenght 2534 and I think it would be good to
handle it. On the other hand, I was able to produce a mangled name of
only 168 characters:
which demanges to a 70MB string. (It takes about 3 seconds to compile
a file with this symbol and 0.8s to demangle it).
So we may need limit the on the output buffer size instead, but this
will require cooperation from the demangling library. Fortunately, all
targets nowadays use either the "fast" demangler or
llvm::itaniumDemangle by default, which we can modify to add a
threshold like this.
On 25 January 2018 at 00:17, Greg Clayton via lldb-dev
<lldb-dev at lists.llvm.org> wrote:
> On Jan 24, 2018, at 4:14 PM, Zachary Turner <zturner at google.com> wrote:
> That's true, but shouldn't it be possible to demangle up until the last
> point you got something meaningful? (I don't know the details of itanium
> mangling, just assuming this is possible)
> anywhere you cut the string many things can go wrong. I think this would
> fall under the "start to demangle the string and if the output buffer goes
> over a certain length, abort the demangling which is solution #4 from my
> original email.
> On Wed, Jan 24, 2018 at 3:54 PM Greg Clayton <clayborg at gmail.com> wrote:
>> If you just cut off the string, then it might not demangle without an
>> error if you truncate the mangled string at a specific point...
>> On Jan 24, 2018, at 3:52 PM, Zachary Turner <zturner at google.com> wrote:
>> What about doing a partial demangle? Take at most 1024 (for example)
>> characters from the mangled name, demangle that, and then display ... at the
>> On Wed, Jan 24, 2018 at 3:48 PM Greg Clayton via lldb-dev
>> <lldb-dev at lists.llvm.org> wrote:
>>> I have an issue where I am debugging a C++ binary that is around 250MB in
>>> size. It contains some mangled names that are crazy:
>>> This de-mangles to something that is 72MB in size and takes 280 seconds
>>> (try running "time c++filt -n" on the above string).
>>> There are probably many symbols likes this in this binary. Currently lldb
>>> will de-mangle all names in the symbol table so that we can chop up the
>>> names so we know function base names and we might be able to classify a base
>>> name as a method or function for breakpoint categorization.
>>> My questions is: how do we work around such issues in LLDB? A few
>>> solutions I can think of:
>>> 1 - time each name demangle and if it takes too long somehow stop
>>> de-mangling similar symbols or symbols over a certain length?
>>> 2 - allow a setting that says "don't de-mangle names that start with..."
>>> and the setting has a list of prefixes.
>>> 3 - have a setting that turns off de-mangling symbols over a certain
>>> length all of the time with a default of something like 256 or 512
>>> 4 - modify our FastDemangler to abort if the de-mangled string goes over
>>> a certain limit to avoid bad cases like this...
>>> #1 would still mean we get a huge delay (like 280 seconds) when starting
>>> to debug this binary, but might prevent multiple symbols from adding to that
>>> #2 would require debugging debugging once and then knowing which symbols
>>> took a while to de-mangle. If we time each de-mangle, we can warn that there
>>> are large mangled names and print the mangled name so the user might know?
>>> #3 would disable de-mangling of long names at the risk of not de-mangling
>>> names that are close to the limit
>>> #4 requires that our FastDemangle code can decode the string mangled
>>> string. The fast de-mangler currently aborts on tricky de-mangling and we
>>> fall back onto cxa_demangle from the C++ library which doesn't not have a
>>> cutoff on length...
>>> Can anyone else think of any other solutions?
>>> Greg Clayton
>>> lldb-dev mailing list
>>> lldb-dev at lists.llvm.org
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
More information about the lldb-dev