Issue parsing Latin1 String with number and `_` delimiter in the js shell
Categories
(Core :: JavaScript Engine, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox-esr68 | --- | unaffected |
firefox-esr78 | --- | wontfix |
firefox78 | --- | wontfix |
firefox79 | --- | wontfix |
firefox80 | --- | fixed |
People
(Reporter: cffsmith, Assigned: arai)
References
(Regression)
Details
(Keywords: regression)
Attachments
(1 file)
The following sample triggers an assertion failure:
function main() {
str = String.fromCharCode(0xff);
console.log(parse("1_" + str.toLocaleString()))
}
main();
Assertion failure: cp.isSome(), at /home/builder/firefox/js/src/util/Text.cpp:420
This is caused by the parse
builtin in the jsshell, which reads the string with the Latin1 charset, then casts it to UTF-8 and then parses it (https://searchfox.org/mozilla-central/source/js/src/shell/js.cpp#5274). It then encounters the 1
and starts to parse a number, where _
can be used as a delimiter to make the number more readable and expects another number after the _
. This fails which causes it to report an error in https://searchfox.org/mozilla-central/source/js/src/frontend/TokenStream.cpp#2420, which then tries to parse it as an UTF-8 string. This causes an infinite loop or an assertion failure in the DecodeOneUtf8CodePointInline
function while trying to print an error message.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 2•5 years ago
|
||
Thank you, Carl.
Shorter test case: parse("1_\xff")
What was I thinking when I reviewed this?
const Latin1Char* chars_ = stableChars.latin1Range().begin().get();
auto chars = reinterpret_cast<const mozilla::Utf8Unit*>(chars_);
Comment 3•5 years ago
|
||
Arai, would you mind taking this? We shouldn't leave it like that.
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 4•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Comment 6•5 years ago
|
||
bugherder |
Updated•5 years ago
|
Description
•