Closed Bug 1009289 Opened 12 years ago Closed 12 years ago

nsGlobalWindow cycle collection instrumentation has a printf type error

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: jld, Assigned: jld)

References

Details

Attachments

(1 file)

On 2012-08-03, this was added to dom/base/nsGlobalWindow.cpp + PR_snprintf(name, sizeof(name), "nsGlobalWindow #%ld", tmp->mWindowID); This is bad, because mWindowID is a uint64_t, and %ld means int32_t (in NSPR's nonstandard printf dialect, but long int is also not uint64_t). On 2014-05-09, it got worse: + PR_snprintf(name, sizeof(name), "nsGlobalWindow #%ld %s %s", + tmp->mWindowID, tmp->IsInnerWindow() ? "inner" : "outer", + uri.get()); On Linux on i386, this breaks silently, as long as tmp->mWindowID < 0x100000000, because uint64_t is 4-byte-aligned: the less significant half of mWindowID is printed, the most significant is 0 and thus prints as "(null)", the "inner" or "outer" gets printed as the second string, and the URI never shows up. On Linux on ARM, this is a crash if tmp->mWindowID != 0, because uint64_t is 8-byte-aligned and it's passed after three 4-byte arguments: the alignment padding gets printed as the window ID, and then both halves of the actual window ID are treated as pointers.
Comment on attachment 8421445 [details] [diff] [review] bug1009289-printf-oops-hg0.diff Review of attachment 8421445 [details] [diff] [review]: ----------------------------------------------------------------- Oops indeed...
Attachment #8421445 - Flags: review?(continuation) → review+
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: