[Kde-games-devel] Review Request: avoid a crash because of a negative area

Albert Astals Cid tsdgeos at terra.es
Wed Dec 19 18:54:47 UTC 2012



> On Dec. 16, 2012, 2:58 p.m., Albert Astals Cid wrote:
> > Waht do you mean R*R and C*C ?
> > 
> > Also this is quite interesting because box2d is used in lots of projects and looking at their upstream code (don't ask me why we have it embedded) it seems the function is still unchanged
> 
> Jaime Torres Amate wrote:
>     R*R is the mathematical infinite plane where all the (real,real) vectors live. In that space, all the mathematical things with dimension between 1 and 2 (including fractals) have area >=0.
>     C*C is the mathematical infinite plane where all the (complex,complex) vectors live. This space has other properties not found in R*R, including objects with area <0.
>     
>     This is a strange bug because very few people suffer it, and also because the vectors follow clock hands (siguen el sentido de las manecillas del reloj), as required by box2d. But with the data in the bug report, the area becomes negative, and then the crash.
>     
>     Also, I remember to have run it under valgrind with no sign of memory overwriten, and with gcc -ftrapv without any overflow or underflow.
>     
>     Without the patch, I get
>     kolf: /g/kdegit/kdegames/kolf/external/Box2D/Collision/Shapes/b2PolygonShape.cpp:116: b2Vec2 ComputeCentroid(const b2Vec2*, int32): La declaración `area > b2_floatValues<sizeof(qreal)>::epsilon()' no se cumple.
>

Ok, makes sense, do you think you could contact the box2d people and tell them the following code asserts?

int main(int argc, char **argv)
{
b2Vec2 vv[8];
vv[0].Set(0.200000,0);
vv[1].Set(0.141421,-0.159099);
vv[2].Set(0.000000,-0.225000);
vv[3].Set(-0.141421,-0.159099);
vv[4].Set(-0.200000,-0.000000);
vv[5].Set(-0.141421,0.159099);
vv[6].Set(-0.000000,0.225000);
vv[7].Set(0.141421,0.159099);


	b2Vec2 v = ComputeCentroid(vv, 8);
}

It's ok if you don't but it'd be better if we can keep our difference with upstream box2d as small as possible (to be honest i don't like the fact we have our own embedded version)


- Albert


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/107739/#review23537
-----------------------------------------------------------


On Dec. 15, 2012, 6:09 p.m., Jaime Torres Amate wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/107739/
> -----------------------------------------------------------
> 
> (Updated Dec. 15, 2012, 6:09 p.m.)
> 
> 
> Review request for KDE Games.
> 
> 
> Description
> -------
> 
> Avoid a crash starting kolf.
> The crash comes when the calculated area is <0, something impossible in R*R (only in C*C).
> The patch makes the area always >=0.
> 
> The patch is similar to what I proposed then, but I forgot how to use reviewboard for svn.
> 
> 
> This addresses bug 258998.
>     http://bugs.kde.org/show_bug.cgi?id=258998
> 
> 
> Diffs
> -----
> 
>   external/Box2D/Collision/Shapes/b2PolygonShape.cpp c96583b 
> 
> Diff: http://git.reviewboard.kde.org/r/107739/diff/
> 
> 
> Testing
> -------
> 
> before, the crash (yes, I still suffer it).
> after, kolf runs.
> 
> 
> Thanks,
> 
> Jaime Torres Amate
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-games-devel/attachments/20121219/29d005a4/attachment.html>


More information about the kde-games-devel mailing list