Git Product home page Git Product logo

Comments (6)

Twinside avatar Twinside commented on July 18, 2024

Without a test case it's gonna be hard. Is it show that crash or the XML serialization? Either way you should be able to get the value by catching the exception and dumping the document using the other method.

from svg-tree.

gaa-cifasis avatar gaa-cifasis commented on July 18, 2024

Without a test case it's gonna be hard.

I'm sorry, i know this is a terrible bug report :(

Is it show that crash or the XML serialization?

Both. I know that that only happens if you generate random svg with size more than 1, so i will try to restrict constructors and types in the generation to try to understand how these values are formed.. Anyway, do you have any idea where this messages is printed?

from svg-tree.

gaa-cifasis avatar gaa-cifasis commented on July 18, 2024

Apparently, the exception is happining in the middle of the operations (print/serializatoin), so it is possible to see part of the xml value. For instance:

Document {_viewBox = Just (-12.817702861142546,0.6106777247176463,1.632889429603818,2.529646794391686), _width = Just (Inches 0.10989379289932048), _height = Just (Point (-1.1278574333421651)), _elements = [RectangleTree (Rectangle {_rectDrawAttributes = DrawAttributes {_strokeWidth = Last {getLast = Just (Pc 9.32827546720599e-2)}, _strokeColor = Last {getLast = Just (ColorRef (PixelRGBA8 0 1 1 0))}, _strokeOpacity = Nothing, _strokeLineCap = Last {getLast = Just CapSquare}, _strokeLineJoin = Last {getLast = Just JoinRound}, _strokeMiterLimit = Last {getLast = Just (-0.9628156349757261)}, _fillColor = Last {getLast = Just (TextureRef "a")}, _fillOpacity = Just 6.461293, _groupOpacity = Just (-0.9966646), _transform = Just [SkewX (-0.4624675754992729)], _fillRule = Last {getLast = Just FillNonZero}, _maskRef = Last {getLast = Just (Ref "a")}, _clipPathRef = Last {getLast = Just RefNone}, _clipRule = Last {getLast = Just FillEvenOdd}, _attrClass = [], _attrId = Nothing, _strokeOffset = Last {getLast = Just (Num 1.4174564141181207)}, _strokeDashArray = Last {getLast = Just []}, _fontSize = Last {getLast = Just (Cm 12.65813731364388)}, _fontFamily = Last {getLast = Just ["c"]}, _fontStyle = Last {getLast = Just FontStyleNormal}, _textAnchor = Last {getLast = Just TextAnchorMiddle}, _markerStart = Last {getLast = Just RefNone}, _markerMid = Last {getLast = Just (Ref "b")}, _markerEnd = Last {getLast = Just (Ref "d")}}, _rectUpperLeftCorner = (Point (-0.7989372529400689),Percent (-1.502925963328229)), _rectWidth = Percent 0.15214465896078544, _rectHeight = Cm (-2.2293480224450515), _rectCornerRadius = (Em (-3.2855643644812554e-2),Mm 1.8917642378490103)})], _definitions = fromList [("e",ElementLinearGradient (LinearGradient {_linearGradientUnits = CoordBoundingBox, _linearGradientStart = (Pc (-0.8301063717291707),Mm 0.2011979099629858), _linearGradientStop = (Em (-0.8227021529489579),Inches (-0.834732795388501)), _linearGradientSpread = SpreadRepeat, _linearGradientTransform = [], _linearGradientStops = []}))], _descri*** Failed! Exception: '<<loop>>'

and the xml serialized:

 <?xml version='1.0' ?><svg viewBox="-12.817702861142546 0.6106777247176463 1.632889429603818 2.529646794391686" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="0.1098937928

from svg-tree.

Twinside avatar Twinside commented on July 18, 2024

Could you dump the generated Template Haskell Arbitrary instance using the -ddump-splices GHC option?

I'm smelling a weird interaction with the $(deriveArbitraryRec ''CssRule)

from svg-tree.

gaa-cifasis avatar gaa-cifasis commented on July 18, 2024

I just deleted the automatic derivation of CssRule and forced the arbitrary instance of Documents to have a empty list of css rules:

instance Arbitrary Document where
   arbitrary = do
     a1 <- arbitrary
     a2 <- arbitrary
     a3 <- arbitrary
     a4 <- arbitrary
     a5 <- arbitrary
     a6 <- arbitrary
     a7 <- arbitrary
     return $ Document { _viewBox = a1 , _width = a2, _height = a3,  _elements = a4 , _definitions = a5, _description = a6,  _styleRules = [], _documentLocation = a7 }

Still, i'm getting the same error. For instance:

Document {_viewBox = Just (6.650834454599194e-2,-9.815238327325185,16.594527379846635,0.9207249292811087), _width = Just (Inches (-2.1308695752140974)), _height = Just (Mm 3.9602027602401577), _elements = [CircleTree (Circle {_circleDrawAttributes = DrawAttributes {_strokeWidth = Last {getLast = Just (Em (-1.5131522355252054))}, _strokeColor = Last {getLast = Just (ColorRef (PixelRGBA8 0 1 1 1))}, _strokeOpacity = Just 2.511894, _strokeLineCap = Last {getLast = Just CapButt}, _strokeLineJoin = Last {getLast = Just JoinBevel}, _strokeMiterLimit = Last {getLast = Just 3.294290732506142}, _fillColor = Last {getLast = Just FillNone}, _fillOpacity = Just 6.018786, _groupOpacity = Nothing, _transform = Nothing, _fillRule = Last {getLast = Just FillNonZero}, _maskRef = Last {getLast = Just (Ref "d")}, _clipPathRef = Last {getLast = Just (Ref "e")}, _clipRule = Last {getLast = Just FillNonZero}, _attrClass = [], _attrId = Just "a", _strokeOffset = Last {getLast = Just (Inches (-1.3400914537233446))}, _strokeDashArray = Last {getLast = Just [Inches 17.311253786703816]}, _fontSize = Last {getLast = Just (Pc 2.2283541555493525)}, _fontFamily = Last {getLast = Just []}, _fontStyle = Last {getLast = Just FontStyleItalic}, _textAnchor = Last {getLast = Just TextAnchorMiddle}, _markerStart = Last {getLast = Just RefNone}, _markerMid = Last {getLast = Just RefNone}, _markerEnd = Last {getLast = Just (Ref "d")}}, _circleCenter = (Num (-0.5840715572769118),Mm (-3.8927464646400103)), _circleRadius = Point 2.939335362782923}),EllipseTree (Ellipse {_ellipseDrawAttributes = DrawAttributes {_strokeWidth = Last {getLast = Just (Percent 20.9886100146324)}, _strokeColor = Last {getLast = Just (TextureRef "c")}, _strokeOpacity = Just 2.8474033, _strokeLineCap = Last {getLast = Just CapSquare}, _strokeLineJoin = Last {getLast = Just JoinRound}, _strokeMiterLimit = Last {getLast = Just 3.677872484633794}, _fillColor = Last {getLast = Just FillNone}, _fillOpacity = Just (-2.1821353), _groupOpacity = Just 9.708448, _transform = Nothing, _fill*** Failed! Exception: '<<loop>>'

from svg-tree.

Twinside avatar Twinside commented on July 18, 2024

It really looks like the problem is on your side

 ~/coding/QuickFuzz> ./dist/build/QuickFuzz/QuickFuzz +RTS -xc
Document {_viewBox = Just (0,0,0,0), _width = Just (Pc 0.0), _height = Nothing, _elements = [], _definitions = fromList [("d",ElementLinearGradient (LinearGradient {_linearGradientUnits = CoordBoundingBox, _linearGradientStart = (Em 0.0,Px 0.0), _linearGradientStop = (Point 0.0,Mm 0.0), _linearGradientSpread = SpreadRepeat, _linearGradientTransform = [], _linearGradientStops = []}))], _description = "e", _styleRules = [], _documentLocation = "e"}
*** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace: 
  Svg.CAF:$fArbitraryCssElement8
*** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace: 
  Svg.CAF:$fArbitraryCssElement8
QuickFuzz: <<loop>>

So the loop appear to originate from Arbitrary instance, digging more...

-- to restrain
instance Arbitrary Document where
   arbitrary = do
     a4 <- arbitrary
     return $ Document { _viewBox = Nothing
                       , _width = Nothing
                       , _height = Nothing
                       , _elements = a4
                       ,_definitions = mempty
                       , _description = mempty
                       ,  _styleRules = [], _documentLocation = mempty }

instance Arbitrary Tree where
  arbitrary = CircleTree <$> x1

-- And the boomer:

instance Arbitrary DrawAttributes where
  arbitrary = do 
    x1 <- arbitrary
    return $ mempty { _attrClass = x1 }

Removing the arbitrary for _attrClass remove the <<loop>> problem. Good luck to debug your generators :)

from svg-tree.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.