This is an archive of the discontinued LLVM Phabricator instance.

[clang][Lex] Fix a crash on malformed string literals
ClosedPublic

Authored by kadircet on Oct 4 2022, 8:06 AM.

Diff Detail

Event Timeline

kadircet created this revision.Oct 4 2022, 8:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 4 2022, 8:06 AM
kadircet requested review of this revision.Oct 4 2022, 8:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 4 2022, 8:06 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tahonermann added subscribers: cor3ntin, tahonermann.

I think this looks right, but it would be good for @cor3ntin to take a look.

cor3ntin accepted this revision.Oct 4 2022, 8:44 AM

Yes, this looks reasonable. The additional warning is somewhat unfortunate, and we could avoid it, but at the same time i don't expect it would bother anyone given how unlikely the scenario is to begin with.

Thanks for fixing that!

This revision is now accepted and ready to land.Oct 4 2022, 8:44 AM
hokein accepted this revision.Oct 4 2022, 11:21 AM

Thanks! I believe it fixes a long tail crash.

clang/unittests/Lex/LexerTest.cpp
665

nit: I'd probably use a clang lit test

auto nocrash = L"\N";

but up to you.

cor3ntin added inline comments.Oct 4 2022, 11:30 AM
clang/unittests/Lex/LexerTest.cpp
665

Nah, this test is good. It could only crash at at the end of a file, which would be flacky at best with lit.

This revision was landed with ongoing or failed builds.Oct 5 2022, 12:56 AM
This revision was automatically updated to reflect the committed changes.

this is causing some crashes in buildbots, and i can't repro. reverting until i figure this out.

i'll reland the fix without the test case, as it's clearly fixing one of the codepaths that'll lead to a crash. it's only the test case that's crashing, because i don't think there are certain test cases that exposed literal parser to invalid/incomplete input and i am not able to reproduce any of the crashes i've seen in buildbots locally (even under asan/msan) and because the bots don't have stack traces for whatever reason, it's impossible to chase from my side. i've pinged buildbot owners in https://discourse.llvm.org/t/buildbots-missing-stack-traces/65753 to see the issue fixed.

i'll reland the fix without the test case, as it's clearly fixing one of the codepaths that'll lead to a crash. it's only the test case that's crashing, because i don't think there are certain test cases that exposed literal parser to invalid/incomplete input and i am not able to reproduce any of the crashes i've seen in buildbots locally (even under asan/msan) and because the bots don't have stack traces for whatever reason, it's impossible to chase from my side. i've pinged buildbot owners in https://discourse.llvm.org/t/buildbots-missing-stack-traces/65753 to see the issue fixed.

Makes sense. The fix is correct and if it wasn't it would affect all bots equally (I highly doubt that code path is exercised anywhere but the lex test)