UTF8 incompatibility: JS::CompileOptions::setFileAndLine + JSErrorReport::filename
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox115 | --- | fixed |
People
(Reporter: qwertiest, Assigned: anba)
References
(Depends on 1 open bug)
Details
Attachments
(16 files, 1 obsolete file)
|
14.00 KB,
patch
|
jorendorff
:
review+
Waldo
:
review+
|
Details | Diff | Splinter Review |
|
8.92 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
|
27.08 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
|
12.95 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
|
8.39 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
|
74.73 KB,
patch
|
arai
:
review+
|
Details | Diff | Splinter Review |
|
10.71 KB,
patch
|
arai
:
review+
|
Details | Diff | Splinter Review |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
| Reporter | ||
Comment 1•7 years ago
|
||
| Assignee | ||
Comment 2•7 years ago
|
||
| Assignee | ||
Comment 3•7 years ago
|
||
| Assignee | ||
Comment 4•7 years ago
|
||
| Assignee | ||
Comment 5•7 years ago
|
||
| Assignee | ||
Comment 6•7 years ago
|
||
| Assignee | ||
Comment 7•7 years ago
|
||
| Assignee | ||
Comment 8•7 years ago
|
||
Comment 9•7 years ago
|
||
| Assignee | ||
Comment 10•7 years ago
|
||
| Assignee | ||
Comment 11•7 years ago
|
||
| Reporter | ||
Comment 12•7 years ago
|
||
| Assignee | ||
Comment 13•7 years ago
|
||
| Assignee | ||
Comment 14•7 years ago
|
||
| Assignee | ||
Comment 16•7 years ago
|
||
Comment 17•7 years ago
|
||
Updated•7 years ago
|
Comment 18•7 years ago
|
||
Comment 19•7 years ago
|
||
Updated•7 years ago
|
| Assignee | ||
Comment 20•7 years ago
|
||
| Assignee | ||
Comment 21•7 years ago
|
||
Updated•6 years ago
|
Comment 22•6 years ago
|
||
Comment 23•6 years ago
|
||
(In reply to André Bargull [:anba] from comment #21)
Wouldn't this be cleaner as
StringBuffer buf(cx);
if (!buf.append(path.get(), strlen(path.get())))
return false;
if (!buf.append('/'))
return false;
if (!buf.append(filename.get(), strlen(filename.get())))
return false;
return buf.finishString();?
Part 5 changes the JS_NewStringCopyZ call to JS_NewStringCopyUTF8N and
because StringBuffer doesn't support UTF-8, I'll leave this as is.
I have no recollection at all of what any of this was/is at this point -- but in going through old bugmail for this, I see that maybe StringBuffer::append(const mozilla::Utf8Unit* units, size_t len) might be useful here. Figure out whether it makes any sense to use that?
Updated•6 years ago
|
| Reporter | ||
Comment 25•5 years ago
|
||
Note: this bug is present in ESR68 as well.
Updated•5 years ago
|
Comment 26•5 years ago
•
|
||
I'd like to work on bug 1505129 and ultimately bug 1506323, so I'd appreciate these patches being landed since this is a blocker for it.
| Comment hidden (metoo) |
Comment 28•3 years ago
|
||
Waldo isn't working for Mozilla anymore. Steven, any chance you can help find someone to review these? Though they'll probably need rebasing at this point too :-(
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Comment 29•3 years ago
|
||
Updated•3 years ago
|
Updated•3 years ago
|
Comment 31•3 years ago
|
||
Comment 32•3 years ago
|
||
Depends on D151445
Comment 33•3 years ago
|
||
Depends on D151446
Comment 34•3 years ago
|
||
Depends on D151447
Comment 35•3 years ago
|
||
Depends on D151448
Comment 36•3 years ago
|
||
Depends on D151449
Comment 37•3 years ago
|
||
Depends on D151450
Comment 38•3 years ago
|
||
Depends on D151451
Comment 39•3 years ago
|
||
Depends on D151452
| Assignee | ||
Comment 40•3 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #29)
Shall I rebase, or do you want to rebase?
Thanks for taking care of the rebase!
Updated•3 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Comment 41•2 years ago
|
||
Comment 42•2 years ago
|
||
Backed out for causing multiple xpcshell failures.
- Push with failures
- Failure Log
- Failure line: TEST-UNEXPECTED-PASS | netwerk/test/unit/test_socks.js | xpcshell return code: 0
- Push with failures
- Failure Log
- Failure line: TEST-UNEXPECTED-PASS | testing/xpcshell/example/unit/test_check_nsIException_failing.js | xpcshell return code: 0
- Push with failures
- Failure Log
- Failure line: TEST-UNEXPECTED-PASS | xpcom/tests/unit/test_bug476919.js | xpcshell return code: 0
Updated•2 years ago
|
Comment 43•2 years ago
|
||
the failure on windows is fixed.
the failure on android seems to be caused by std::mbsrtowcs call.
calling std::mbsrtowcs inside JS::EncodeNarrowToUtf8 caused the test to unconditionally pass (the test is expected to fail). even if the result is unused.
https://treeherder.mozilla.org/jobs?repo=try&revision=b58e3a8061c53c97f7bd8eb8fd338782965ad098&selectedTaskRun=IJ4Wuxe-SnOGBZ41hiW2-w.0
commenting out the call makes the test green:
https://treeherder.mozilla.org/jobs?repo=try&revision=401b906975067a8959176427e93d50d4af0bdb96&selectedTaskRun=UAvQnvTCQL2s0WSLKZ7GtA.0
some kind of memory corruption or something would be happening there
Comment 44•2 years ago
|
||
looks like there's also an issue in the test harness.
I put MOZ_RELEASE_ASSERT(false); and all test passes.
so, if the shell crashes, it's treated as test pass?
Updated•2 years ago
|
Comment 45•2 years ago
|
||
The crash is most likely caused by an unexpected behavior in std::mbsrtowcs implementation on Android.
According to the document, calling std::mbsrtowcs(dst, &src, len, ps) with dst==nullptr doesn't move src:
https://en.cppreference.com/w/cpp/string/multibyte/mbsrtowcs
The conversion stops if:
- The multibyte null character was converted and stored.
src is set to a null pointer and *ps represents the initial shift state.- An invalid multibyte character (according to the current C locale) was encountered.
src is set to point at the beginning of the first unconverted multibyte character.- the next wide character to be stored would exceed len.
src is set to point at the beginning of the first unconverted multibyte character. This condition is not checked if dst is a null pointer.
...
Notes
This function moves thesrcpointer to the end of the converted multibyte string.
This doesn't happen ifdstis a null pointer.
but on Android, calling std::mbsrtowcs with dst==nullptr moves src to point nullptr.
std::mbsrtowcs is supposed to be called twice, and we do so in JS::EncodeNarrowToUtf8, but chars pointer is overwritten in the first call and the 2nd call hits null-pointer-deref.
size_t wideLen = std::mbsrtowcs(nullptr, &chars, 0, &mb);
...
mozilla::DebugOnly<size_t> actualLen =
std::mbsrtowcs(wideChars.get(), &chars, bufLen, &mb);
I've looked into the Android source, but I don't find any issue in the source there...
anyway, using temporary variable solves the issue.
| Assignee | ||
Comment 46•2 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #45)
I've looked into the Android source, but I don't find any issue in the source there...
It seems this was fixed in https://android.googlesource.com/platform/bionic/+/89e29ee485253ad39b8bfd514f1c3b5c3e52f98d%5E%21/, which also points to this bug report. So I guess the test environment just uses an old Android version.
Comment 47•2 years ago
|
||
(In reply to André Bargull [:anba] from comment #46)
(In reply to Tooru Fujisawa [:arai] from comment #45)
I've looked into the Android source, but I don't find any issue in the source there...
It seems this was fixed in https://android.googlesource.com/platform/bionic/+/89e29ee485253ad39b8bfd514f1c3b5c3e52f98d%5E%21/, which also points to this bug report. So I guess the test environment just uses an old Android version.
Thanks!
I've added a workaround to JS::EncodeNarrowToUtf8 and also added comment.
Comment 48•2 years ago
|
||
Comment 49•2 years ago
•
|
||
Backed out for causing xpcshell failures at test_async_response_sending.js.
There's also this xpcshell failure too.
Updated•2 years ago
|
Comment 50•2 years ago
|
||
Comment 51•2 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/062102d66345
https://hg.mozilla.org/mozilla-central/rev/70831a15254d
https://hg.mozilla.org/mozilla-central/rev/519aee0147a0
https://hg.mozilla.org/mozilla-central/rev/68328f314a79
https://hg.mozilla.org/mozilla-central/rev/416af93c3205
https://hg.mozilla.org/mozilla-central/rev/0a5fa01b9714
https://hg.mozilla.org/mozilla-central/rev/0b7b5cf30557
https://hg.mozilla.org/mozilla-central/rev/51d9f8a4331e
https://hg.mozilla.org/mozilla-central/rev/feb9591113b7
Updated•2 years ago
|
Description
•