Closed Bug 276061 Opened 20 years ago Closed 20 years ago

bogus js_ValueToInt32 calls in jsexn.c, plus recent regressions

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8alpha6

People

(Reporter: brendan, Assigned: brendan)

References

()

Details

(Keywords: js1.5)

Attachments

(1 file, 1 obsolete file)

The js_ValueToInt32 calls were old, but cloning one into the fix for bug 243869
made the test URL worse.  Fixing these to use js_ValueToECMAUint32 reveals other
problems:

1. bytes is reassigned badly in the new code in js_ReportUncaughtException,
clobbering the original bytes value that comes from converting the exception to
a string.

2. The recovery of message, filename, and lineno from exnObject in that function
should be predicated on the exnObject being an instance of *Error.  If it's just
a plain object (throw {}), there's no point groveling around in it for
properties that weren't set, and losing the useful "uncaught exception" error.

/be
Attached patch proposed fix (obsolete) — Splinter Review
More work required to fix bug 119719, but that will happen in a patch in that
bug.

This fix does not regress bug 243869.

/be
Attachment #169606 - Flags: review?(shaver)
hm...
        report.lineno = (lineno >= 0) ? (uintN) lineno : 0;

gcc tells me:
/home/chb/mozilla/js/src/jsexn.c: In function `js_ReportUncaughtException':
/home/chb/mozilla/js/src/jsexn.c:1097: warning: comparison of unsigned
expression >= 0 is always true
cool.
js> throw new Error("foo")
:5: foo
(presumably this is as intended. I'd have expected something like <stdin> as
filename, guess that's not this bug though. hmm, in xpcshell I get:
js> throw new Error("foo")
typein:1: foo
)

anyway, this does seem to fix the problem reported in
<news://news.mozilla.org/cqkq2q$k751@ripley.netscape.com>, both in xpcshell and
jsshell. thanks.
The right thing for jsexn.c, not done when errors-as-exceptions and the
filename and lineNumber extensions to ECMA-262 Edition 3 were first
implemented, is to have a callback for UTF-16 to UTF-8, and vice versa, that
embeddings can configure to share their converters.

I would like to deal with that in a separate bug.

/be
Attachment #169606 - Attachment is obsolete: true
Attachment #169644 - Flags: review?(shaver)
Oh, and SpiderMonkey is used all over the place, has been for 6+ years, so we
should be careful to avoid requiring that a script's filename be UTF-8.  It's a
C string, so it could use a locale-specific (multi-byte, e.g.) character set
form.  Definitely want callbacks for transcoding, with generic names.

/be
Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → mozilla1.8alpha6
Attachment #169644 - Flags: approval1.8a6?
Attachment #169606 - Flags: review?(shaver)
Comment on attachment 169644 [details] [diff] [review]
fix js.c to use "typein" as the stdin filename, abstract lack of UTF-8 a bit

Yeah, wow, what a mess this code is.  r=shaver
Attachment #169644 - Flags: review?(shaver) → review+
Comment on attachment 169644 [details] [diff] [review]
fix js.c to use "typein" as the stdin filename, abstract lack of UTF-8 a bit

a=asa for checkin to 1.8a6.
Attachment #169644 - Flags: approval1.8a6? → approval1.8a6+
Fixed.  I'll fix the remaining problems over in bug 232182.

/be
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: