Check whether the string (db.names.back().first) is longer than 7 characters before inserting another string at index 8.
Details
Diff Detail
Event Timeline
src/cxa_demangle.cpp | ||
---|---|---|
3078–3079 | Should this be >= 7? |
src/cxa_demangle.cpp | ||
---|---|---|
3078–3079 | You are right. Thanks for spotting this. Updating the patch. |
Fixing off-by-one. Passes make check-cxxabi for LLVM in trunk on my machine (x86-64, Ubuntu 16.04).
Could you please add more context lines in any future patches? Makes it easier to review!
I think we fixed the same problem at the same time, I have https://reviews.llvm.org/D33368 that also fixes this! The reason that inserting into db.names.back() sometimes results in a insertion out of bounds is that parse_type() can sometimes append multiple names into db.names (ie for a reference to a pack expansion). This results in db.names.back() no longer being the text 'lambda, which makes inserting at +7 dangerous. I think we should handle this case by appending them one by one into the lambda's parameters, which is what my patch does. Do you agree that this is the right approach here?
src/cxa_demangle.cpp | ||
---|---|---|
3080 | We shouldn't make progress here if something invalid happened, if the names.back().size() is less than 7 then we should just bail out and return first. |
Sure. As long as it fixes PR32890.
You could append my test case as a quick-check.
So, I'll go ahead and abandon this revision?
You could append my test case as a quick-check.
Sure, I added the test case here to my patch and it works.
So, I'll go ahead and abandon this revision?
Guess so, sorry for the confusion here.
I don't know this code and can't properly comment, but having a constant like this ("7") sounds wrong.
Why not 6, or 8, or 42?
but having a constant like this ("7") sounds wrong. Why not 6, or 8, or 42?
7 is correct here because we inserting into a specific point into a string that was inserted into db.names just above this (but out of context from the diff). The only problem is that more stuff was inserted in the meantime.
This is horrible, but the demangler is littered with random offsets. My personal favorite is that const, volatile, and restrict aren't represented with an enum, but just with the literals 1, 2, and 4.
Closed. Patch https://reviews.llvm.org/D33368 addresses PR32890 more comprehensively.
Should this be >= 7?