Closed Bug 383685 Opened 17 years ago Closed 17 years ago

"ASSERTION: unknown enumeration value" during shutdown after reloading this testcase

Categories

(Core :: SVG, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Assigned: longsonr)

References

Details

(Keywords: assertion, memory-leak, testcase)

Attachments

(2 files)

Attached image testcase (deleted) —
Steps to reproduce:
1. Load the testcase.
2. Reload it a few times (Cmd+R).
3. Quit (Cmd+Q).

Result:

###!!! ASSERTION: unknown enumeration value: 'Error', file /Users/jruderman/trunk/mozilla/content/svg/content/src/nsSVGEnum.cpp, line 193

Tested with Mac trunk debug.
Assignee: nobody → longsonr
Status: NEW → ASSIGNED
Attachment #282006 - Flags: review?(tor)
Comment on attachment 282006 [details] [diff] [review]
refuse to accept invalid enumerations

>-void
>+nsresult
> nsSVGEnum::SetBaseValue(PRUint16 aValue,
>                         nsSVGElement *aSVGElement,
>                         PRBool aDoSetAttr)
> {
>-  mAnimVal = mBaseVal = static_cast<PRUint8>(aValue);
>-  aSVGElement->DidChangeEnum(mAttrEnum, aDoSetAttr);
>+  nsSVGEnumMapping *tmp = GetMapping(aSVGElement);
>+
>+  while (tmp && tmp->mKey) {
>+    if (tmp->mVal == aValue) {
>+      mAnimVal = mBaseVal = static_cast<PRUint8>(aValue);
>+      aSVGElement->DidChangeEnum(mAttrEnum, aDoSetAttr);
>+      return NS_OK;
>+    }
>+    tmp++;
>+  }
>+  return NS_ERROR_FAILURE;
> }

This doesn't make any sense to me.  What you might want to do is change GetMapping to return nsnull if mAttrEnum is out of range, then:

if (tmp && mBaseVal != aValue) {
  mAnimVal = mBaseVal = static_cast<PRUint8>(aValue);
  aSVGElement->DidChangeEnum(mAttrEnum, aDoSetAttr);
  return NS_OK;
}
Attachment #282006 - Flags: review?(tor) → review-
Actually, the mBaseVal != aValue test should probably come before anything else in the method.
(In reply to comment #2)
> This doesn't make any sense to me.  What you might want to do is change
> GetMapping to return nsnull if mAttrEnum is out of range, then:

mAttrEnum is OK. It's a valid attribute being given an invalid value that is the problem. 

gradient.spreadMethod.baseVal = undefined;
Manages to set the enumeration to an invalid value.

The code I wrote goes through the enumeration mappings and ensures that the value being set matches one of them.

> 
> if (tmp && mBaseVal != aValue) {
>   mAnimVal = mBaseVal = static_cast<PRUint8>(aValue);
>   aSVGElement->DidChangeEnum(mAttrEnum, aDoSetAttr);
>   return NS_OK;
> }
> 

That won't fix this problem, although I agree it is a sensible thing to do throughout the implementations of SetBaseValue.


Attachment #282006 - Flags: review- → review+
Comment on attachment 282006 [details] [diff] [review]
refuse to accept invalid enumerations

I'll raise a follow up for only calling DidChangeEnum if the base value has changed as that applies to all types.
Attachment #282006 - Flags: superreview?(roc)
Attachment #282006 - Flags: superreview?(roc)
Attachment #282006 - Flags: superreview+
Attachment #282006 - Flags: approval1.9+
chekced in.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Depends on: 397704
Depends on: 398903
Crashtest checked in.
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: