Closed Bug 679975 Opened 13 years ago Closed 13 years ago

sizeof(JSRuntime) != sizeof(JSRuntime)

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 677079

People

(Reporter: n.nethercote, Unassigned)

Details

sizeof(JSRuntime) is larger in the JS engine than it is in XPConnect, for debug builds at least. The difference is that the JS engine includes the |gcData| field. So XPConnect isn't seeing MOZ_GCTIMER and/or JSGC_TESTPILOT defined. It's not causing a problem in practice because |gcData| is the last field in JSRuntime. We should fix this particular case, but it would be even better if this was impossible.
Assignee: nnethercote → general
W.r.t. making this impossible: I can see how to do it just for JSRuntime -- have a member in JSRuntime like this: static const size_t sizeOfMe = sizeof(JSRuntime); and then assert at XPConnect that sizeOfMe == sizeof(JSRuntime) when the JSRuntime is created. But it would be better to have something that is a full guarantee for all types. That would require a guarantee that the JS engine and XPConnect are being compiled with the same #defines, so I guess that would have to be done at the level of the build system.
(In reply to Nicholas Nethercote [:njn] from comment #1) > W.r.t. making this impossible: I can see how to do it just for JSRuntime -- > have a member in JSRuntime like this: > > static const size_t sizeOfMe = sizeof(JSRuntime); > > and then assert at XPConnect that sizeOfMe == sizeof(JSRuntime) when the > JSRuntime is created. That's ... tricky. And even a size comparison won't catch everything. > But it would be better to have something that is a full guarantee for all > types. That would require a guarantee that the JS engine and XPConnect are > being compiled with the same #defines, so I guess that would have to be done > at the level of the build system. I'm not sure that there's any good solution to struct definitions being different in different translation units. I think it's just one of those hazards of C/C++. That said, if this particular case is important enough, we can rig up something that at least gets the size checked.
Fixing the immediate problem is good. I think the real fix is bug 677079. I'm sure waldo wouldn't mind if you stole it from him :)
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.