Closed Bug 361362 Opened 18 years ago Closed 18 years ago

js/src/jsemit.c assumes sizeof(int) == sizeof(ptrdiff_t)

Categories

(Core :: JavaScript Engine, defect)

Sun
NetBSD
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: martin, Unassigned)

References

Details

(Keywords: verified1.8.0.9, verified1.8.1.1)

Attachments

(1 file)

Obviously this does not work on plattforms where sizeof(int) != sizeof(ptrdiff_t):

int noteIndex;
EmitVariables(cx, cg, pn, JS_FALSE, &noteIndex);

For example on NetBSD/sparc64 this makes firefox (and regchrome during installation) dump core due to a bus error - int has four byte alignement, while ptrdiff_t requires eight byte alignment.
This is how I patched it locally (in NetBSD's pkgsrc), which made it work for me.
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → Trunk
Fixed on trunk, thanks:

$ cvs ci -m"Fix from Martin Husemann <martin@NetBSD.ORG> for int-instead-of-ptrdiff_t abusage (361362, r=me)." jsemit.c
Checking in jsemit.c;
/cvsroot/mozilla/js/src/jsemit.c,v  <--  jsemit.c
new revision: 3.229; previous revision: 3.228
done

/be
Blocks: js1.7src
Status: NEW → RESOLVED
Closed: 18 years ago
Flags: blocking1.8.1.1?
Flags: blocking1.8.0.9?
Resolution: --- → FIXED
Comment on attachment 246128 [details] [diff] [review]
Change a variable from int to ptrdiff_t to assure proper alignment

Safe portability fix.

/be
Attachment #246128 - Flags: review+
Attachment #246128 - Flags: approval1.8.1.1?
Attachment #246128 - Flags: approval1.8.0.9?
Flags: blocking1.8.1.1?
Flags: blocking1.8.1.1-
Flags: blocking1.8.0.9?
Flags: blocking1.8.0.9-
Comment on attachment 246128 [details] [diff] [review]
Change a variable from int to ptrdiff_t to assure proper alignment

Approved for landing on both 1.8.0 and 1.8.1 branches, a=jay for drivers.
Attachment #246128 - Flags: approval1.8.1.1?
Attachment #246128 - Flags: approval1.8.1.1+
Attachment #246128 - Flags: approval1.8.0.9?
Attachment #246128 - Flags: approval1.8.0.9+
Fixed on the 1.8 branch:

Checking in jsemit.c;
/cvsroot/mozilla/js/src/jsemit.c,v  <--  jsemit.c
new revision: 3.128.2.60; previous revision: 3.128.2.59
done

and on the 1.8.0 branch:

Checking in jsemit.c;
/cvsroot/mozilla/js/src/jsemit.c,v  <--  jsemit.c
new revision: 3.128.2.3.2.13; previous revision: 3.128.2.3.2.12
done

/be
Flags: in-testsuite-
Verified fixed on trunk, 1.8.1 branch and 1.8.0.x branch by code inspection.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: