DO NOT REPLY [Bug 47975] New: NegativeArraySizeException in MultipleGradientContextPaint.calculateGradientFractions

View: New views
6 Messages — Rating Filter:   Alert me  

DO NOT REPLY [Bug 47975] New: NegativeArraySizeException in MultipleGradientContextPaint.calculateGradientFractions

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=47975

           Summary: NegativeArraySizeException in
                    MultipleGradientContextPaint.calculateGradientFraction
                    s
           Product: Batik
           Version: 1.8
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: Utilities
        AssignedTo: batik-dev@...
        ReportedBy: kirillcool@...


Line 359 of org.apache.batik.ext.awt.MultipleGradientContextPaint compares the
float value of Imin to 0.0. However, due to float-point limitations, under some
conditions this value can be negative - leading to this exception stack trace:

java.lang.NegativeArraySizeException
    at
org.apache.batik.ext.awt.MultipleGradientPaintContext.calculateSingleArrayGradient(MultipleGradientPaintContext.java:460)
    at
org.apache.batik.ext.awt.MultipleGradientPaintContext.calculateGradientFractions(MultipleGradientPaintContext.java:378)
    at
org.apache.batik.ext.awt.MultipleGradientPaintContext.<init>(MultipleGradientPaintContext.java:297)
    at
org.apache.batik.ext.awt.RadialGradientPaintContext.<init>(RadialGradientPaintContext.java:137)
    at
org.apache.batik.ext.awt.RadialGradientPaint.createContext(RadialGradientPaint.java:464)
    at sun.java2d.pipe.AlphaPaintPipe.startSequence(AlphaPaintPipe.java:65)
    at
sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.java:74)
    at sun.java2d.pipe.DuctusShapeRenderer.fill(DuctusShapeRenderer.java:49)
    at sun.java2d.pipe.ValidatePipe.fill(ValidatePipe.java:142)
    at sun.java2d.SunGraphics2D.fill(SunGraphics2D.java:2261)

The negative value is around 1e-07, and can be addressed by changing the
condition from (Imin == 0) to (Imin <= 0)

Thanks
Kirill

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@...
For additional commands, e-mail: batik-dev-help@...


DO NOT REPLY [Bug 47975] NegativeArraySizeException in MultipleGradientContextPaint.calculateGradientFractions

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=47975

Kirill Grouchnikov <kirillcool@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|1.8                         |1.7

--- Comment #1 from Kirill Grouchnikov <kirillcool@...> 2009-10-09 16:51:17 UTC ---
Changing the version to 1.7 - haven't tested against the head.

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@...
For additional commands, e-mail: batik-dev-help@...


DO NOT REPLY [Bug 47975] NegativeArraySizeException in MultipleGradientContextPaint.calculateGradientFractions

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=47975

--- Comment #2 from Helder Magalhães <helder.magalhaes@...> 2009-10-10 08:43:12 UTC ---
(In reply to comment #0)
> [...] due to float-point limitations, under some
> conditions this value can be negative

Could you be a little bit more specific (i.e., attach a test case or sample
application)? Even if it's just my low knowledge on the matter showing up, I
guess it would be valuable to have such test case available in order to
potentially add it to the Batik regression test infrastructure [1]. ;-)


(In reply to comment #1)
> Changing the version to 1.7 - haven't tested against the head.

If there's actually an issue with this code, then I've just checked that the
trunk (version 1.8) currently also seems to have it [2].


[1] http://xmlgraphics.apache.org/batik/dev/test.html#regard
[2]
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/MultipleGradientPaintContext.java?annotate=501922#l359

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@...
For additional commands, e-mail: batik-dev-help@...


DO NOT REPLY [Bug 47975] NegativeArraySizeException in MultipleGradientContextPaint.calculateGradientFractions

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=47975

--- Comment #3 from Kirill Grouchnikov <kirillcool@...> 2009-10-12 09:14:48 UTC ---
Created an attachment (id=24374)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24374)
Test case that shows the exception

Run the attached test case under JDK 5.0_21 on Windows XP (has not tested on
other environments) and see the stack trace mentioned in the original post.

Thanks
Kirill

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@...
For additional commands, e-mail: batik-dev-help@...


DO NOT REPLY [Bug 47975] NegativeArraySizeException in MultipleGradientContextPaint.calculateGradientFractions

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=47975

--- Comment #4 from Thomas Deweese <deweese@...> 2009-10-13 03:09:31 UTC ---
(In reply to comment #3)
> Created an attachment (id=24374)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24374) [details]
> Test case that shows the exception

From the Test case:

RadialGradientPaint groupFillPaint = new RadialGradientPaint(329, 203,
        114.1f, new float[] { 0.0f, 0.20634921f, 1.0000001f },
        new Color[] { new Color(0, 255, 0), new Color(0, 255, 0),
                  new Color(0, 255, 255) });

From the documentation of RadialGradientPaint:

     * @param fractions numbers ranging from 0.0 to 1.0 specifying the
     * distribution of colors along the gradient

   You will note that your last fractions value is 1.0000001 which is not
in the range 0.0->1.0.  Our code should probably throw an IllegalArgument
exception in this case, but the end result will be similar for you.

> Run the attached test case under JDK 5.0_21 on Windows XP (has not tested on
> other environments) and see the stack trace mentioned in the original post.

   I think it's fair to classify this as a bug in your code, although it
would be good if Batik handled the case more cleanly.

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@...
For additional commands, e-mail: batik-dev-help@...


DO NOT REPLY [Bug 47975] NegativeArraySizeException in MultipleGradientContextPaint.calculateGradientFractions

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=47975

--- Comment #5 from Kirill Grouchnikov <kirillcool@...> 2009-10-26 13:12:09 UTC ---
You're right. After changing my code to make sure that the fractions stay in
0.0-1.0 range (that value was due to floating point arithmetic errors) i no
longer see the exception - in the latest, as well as earlier releases of Batik.

I would prefer having an IllegalArgumentException thrown in the constructor of
RadialGradientPaint to make the lives of users easier.

Thanks
Kirill

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@...
For additional commands, e-mail: batik-dev-help@...