Closed
Bug 406251
Opened 17 years ago
Closed 17 years ago
int value conversion problem in NPRuntime, doesn't work with large ints (high bits set)
Categories
(Core Graveyard :: Plug-ins, defect, P2)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: jst, Assigned: jst)
Details
Attachments
(3 files)
831 bytes,
patch
|
peterv
:
review+
peterv
:
superreview+
damons
:
approval1.9+
|
Details | Diff | Splinter Review |
471 bytes,
patch
|
sicking
:
review+
sicking
:
superreview+
|
Details | Diff | Splinter Review |
25.14 KB,
application/zip
|
Details |
As Kenneth Russell pointed out in person to me, the NPRuntime API layer doesn't properly deal when passing large integer values from a plugin to JS. We fail to see that an integer value doesn't fit in an integer jsval... Patch coming up.
Assignee | ||
Comment 1•17 years ago
|
||
This makes us use JS_NewNumberValue() instead of assuming INT_TO_JSVAL will do the right thing with all ints. This code is identical (except for the automatic cast from int to double) to what we do for double NPVariants.
Attachment #290942 -
Flags: superreview?(peterv)
Attachment #290942 -
Flags: review?(peterv)
Updated•17 years ago
|
Attachment #290942 -
Flags: superreview?(peterv)
Attachment #290942 -
Flags: superreview+
Attachment #290942 -
Flags: review?(peterv)
Attachment #290942 -
Flags: review+
Assignee | ||
Updated•17 years ago
|
Attachment #290942 -
Flags: approval1.9?
Updated•17 years ago
|
Attachment #290942 -
Flags: approval1.9? → approval1.9+
Assignee | ||
Comment 2•17 years ago
|
||
Fix checked in. Kenneth, please let me know here if you're still seeing integer conversion problems with NPRuntime. This fix should appear in nightly builds from tomorrow or later.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Comment 3•17 years ago
|
||
I apologize for the long delay in verifying this bug fix, but unfortunately it is not working correctly. At this point, any negative value passed to INT32_TO_NPVARIANT is coming through with the wrong value -- a large positive value instead of a negative value.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Updated•17 years ago
|
Flags: blocking1.9+
Priority: -- → P2
Assignee | ||
Comment 4•17 years ago
|
||
So, um, this is really lame. I don't know how far back this goes, but as far back as I've been able to find so far (i.e. predates the first checkin of this code into the Mozilla CVS tree, pre firefox 1.0). The plugin futures wiki is having problems atm, so I can't see any more history right now, and I'm not sure how much there ever was in the wiki, but my email archives haven't reviled when this was first introduced yet.
The problem is that NPVariant.intValue is an uint32_t, not an int32_t! So the code in this patch simply casts the unsigned int to a double, and even if the int was originally a negative value, by the time we get into here it's an unsigned int, so it'll be a big positive number instead of the negative number it should be :(
I don't know what the best way to solve this at this point is. Seems like the obvious fix would be to fix the broken type in NPVariant, but that'll come at the risk of potentially breaking some plugins out there when they're recompiled, and even during runtime no matter how we fix this.
Anyone have thoughts either way here?
Status: REOPENED → ASSIGNED
Comment 5•17 years ago
|
||
While there's always risk of breakage, since the only difference between uint32_t and int32_t is interpretation of the bit pattern, the impact of changing NPVariant's intValue specification incompatibly would probably be minimal.
Assuming there wasn't a strong reason for making the intValue type unsigned, the fact that nobody saw the error in handling of large integer values (with either of the two high bits set) before the original fix for this bug also implies that there would be very little breakage of existing NPRuntime plugins. Before the original bug fix, certain large integer values placed into NPVariants would be interpreted as negative numbers by Firefox's JavaScript engine.
Assignee | ||
Comment 6•17 years ago
|
||
Yeah, I do agree. Unless I find evidence somewhere showing that this was done for a reason, or someone can think of a reason why changing this now would be bad, I'm inclined to simply change the definition of NPVariant.intValue in npruntime.h.
I tend to agree. It seems really unlikely that someone will be using integers bigger than 2^30.
Comment 8•17 years ago
|
||
I think making that a signed int is perfectly reasonable.
Assignee | ||
Comment 9•17 years ago
|
||
I'm still waiting for feedback on this (or lack there of) on the plugin-futures list, I'll probably hold of a couple of days before requesting reviews etc.
Comment 10•17 years ago
|
||
How do you propose this is tested?
Assignee | ||
Comment 11•17 years ago
|
||
We have no test infrastructure in place for testing anything related to plugins, the best I can do is either check it in and wait for Kenneth to test, or provide builds from our try servers for him to test. Given the nature of the change, I'd rather just land it, once I'm ready to.
Comment 12•17 years ago
|
||
I can test the patch with the new Java Plug-In once it lands.
Assignee | ||
Comment 13•17 years ago
|
||
Thank you Kenneth. In the interest of speeding this up a bit, I did just kick off a try server build. I'll report back once the builds are available and we can hopefully get this closed out even sooner.
Comment 14•17 years ago
|
||
I'm more worried about regressions against existing plugins. I'm not asking about automated tests here, just how we plan to check the cases in which Flash or Java or whatever deal in large-int NPVariants. Manual generation of content would be fine, especially if we file some bugs tracking making them automated.
(I'll stop short of asking for a simple test plugin to be written or automated, because there does not seem to be general agreement that it's important to have such things in place. But we're fixing a bug that's not new at all, so I don't actually know why it would need to be rushed into production, in the end-game, without test support. I'd think that the lack of automated coverage would make it _more_ important to do good manual testing, though, with major plugins providing scriptable access. Am I out to lunch?)
Comment 15•17 years ago
|
||
Please see my comment #5 above. There was a very longstanding bug in Firefox where very large int NPVariants would be treated incorrectly by the Firefox JavaScript engine, which Johnny fixed with his initial fix for this bug. Nobody ever discovered this until I reported it with the new NPRuntime-based Java Plug-In. Therefore I think it is highly unlikely that any Flash user will see any change in behavior because if they had ever tried to send large int values into the Firefox JS engine they would have encountered this bug by now.
Assignee | ||
Comment 16•17 years ago
|
||
Shaver, I'm with you that having tests for this, any kind of tests, would be beneficial, but we don't, and we won't before we release either (unless someone with the interest and cycles to do it shows up out of the blue).
The only reason this bug was even found was because of Sun's work on the new NPRuntime enabled Java plugin, primarily through Kenneth. They're by *far* the heaviest users of the NPRuntime API we've seen so far, and that's why these issues are being found now, rather than earlier in our release cycle. The best we can do is to get it out there as soon as possible for more testing.
Assignee | ||
Comment 17•17 years ago
|
||
Kenneth, builds with the fix are now available here:
https://build.mozilla.org/tryserver-builds/2008-03-11_16:04-jst@mozilla.com-npvariant-int-type/
Comment 18•17 years ago
|
||
OK, that's fair. Kenneth: do you think you could make public an applet and script that pokes at this hard, so that we can stick it in whatever test setup we end up with for Java and plugins?
Comment 19•17 years ago
|
||
Fix verified by taking out the workaround from the new NPRuntime-based Java Plug-In and running the attached test case (simply navigate to index.html). Thanks for the prompt fix.
Note that the failure can not be provoked with our publicly visible bits (http://jdk6.dev.java.net/6uNea.html) -- but as soon as the patch lands, I'll take out our workaround for this bug, at which point it can be used as a regression test. (It's almost completely automated aside from a "Test Passed" / "Test Failed" dialog at the end.)
Assignee | ||
Updated•17 years ago
|
Attachment #308738 -
Flags: superreview?(jonas)
Attachment #308738 -
Flags: review?(jonas)
Assignee | ||
Comment 20•17 years ago
|
||
I've heard only agreement to making this change on the plugin-futures list, so this is ready to go in.
Attachment #308738 -
Flags: superreview?(jonas)
Attachment #308738 -
Flags: superreview+
Attachment #308738 -
Flags: review?(jonas)
Attachment #308738 -
Flags: review+
Assignee | ||
Comment 21•17 years ago
|
||
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago → 17 years ago
Resolution: --- → FIXED
Updated•3 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•