SVG importer crashing with a simple, large file from Inkscape 0.48 #38191

Closed
opened 2014-01-13 13:05:53 +01:00 by Simon Repp · 10 comments

System Information
Ubuntu 13.10, NVIDIA Quadro 1000M

Blender Version
Broken: 2.69.0 r60991

Short description of error

While trying to import a very simple but large svg file I prepared (graphs.svg), Blender crashes.
The svg was originally generated in the browser with d3.js, then saved, read into inkscape 0.48, and from there exported as Plain SVG.
It contains some ~30 graphs (no fill, black stroke) , the markup is dead simple and can be easily read with a text editor.

The crash occurs still inside the python import script, this is the traceback:

Traceback (most recent call last):
  File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/__init__.py", line 61, in execute
  **self.as_keywords(ignore=("filter_glob",)))
  File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1851, in load
    load_svg(filepath)
  File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1843, in load_svg
    loader.createGeom(False)
  File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1077, in createGeom
    self._doCreateGeom(instancing)
  File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1129, in _doCreateGeom
    geom.createGeom(instancing)
  File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1077, in createGeom
    self._doCreateGeom(instancing)
  File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1755, in _doCreateGeom
    super()._doCreateGeom(False)
  File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1129, in _doCreateGeom
    geom.createGeom(instancing)
  File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1077, in createGeom
    self._doCreateGeom(instancing)
File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1200, in _doCreateGeom
  bezt = act_spline.bezier_points[-1]
IndexError: bpy_prop_collection[-1]: out of range.

Exact steps for others to reproduce the error

  • Download and save graphs.svg on your disk
  • Open blender (e.g. w/ startup file)
  • Go to File > Import > Scalable Vector Graphics (.svg)
  • Find and choose the previously downloaded file
  • Blender freezes for a few seconds and then crashes
**System Information** Ubuntu 13.10, NVIDIA Quadro 1000M **Blender Version** Broken: 2.69.0 r60991 **Short description of error** While trying to import a very simple but large svg file I prepared (![graphs.svg](https://archive.blender.org/developer/F67744/graphs.svg)), Blender crashes. The svg was originally generated in the browser with d3.js, then saved, read into inkscape 0.48, and from there exported as Plain SVG. It contains some ~30 graphs (no fill, black stroke) , the markup is dead simple and can be easily read with a text editor. The crash occurs still inside the python import script, this is the traceback: ``` Traceback (most recent call last): File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/__init__.py", line 61, in execute ``` **self.as_keywords(ignore=("filter_glob",))) ``` File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1851, in load load_svg(filepath) File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1843, in load_svg loader.createGeom(False) File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1077, in createGeom self._doCreateGeom(instancing) File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1129, in _doCreateGeom geom.createGeom(instancing) File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1077, in createGeom self._doCreateGeom(instancing) File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1755, in _doCreateGeom super()._doCreateGeom(False) File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1129, in _doCreateGeom geom.createGeom(instancing) File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1077, in createGeom self._doCreateGeom(instancing) ``` ``` File "/opt/blender_downloaded/2.69/scripts/addons/io_curve_svg/import_svg.py", line 1200, in _doCreateGeom bezt = act_spline.bezier_points[-1] IndexError: bpy_prop_collection[-1]: out of range. ``` **Exact steps for others to reproduce the error** - Download and save ![graphs.svg](https://archive.blender.org/developer/F67744/graphs.svg) on your disk - Open blender (e.g. w/ startup file) - Go to **File** > **Import** > **Scalable Vector Graphics (.svg)** - Find and choose the previously downloaded file - Blender freezes for a few seconds and then crashes
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @simonrepp

Added subscriber: @simonrepp
Simon Repp self-assigned this 2014-01-13 13:10:32 +01:00
Author

I'll look a bit into it, feel free to beat me to it in case you're familiar with the code and able to provide a fast fix.
Especially let me know if you think my svg file is the actual problem here ... Not that I created anything fancy there, but you never know ... :)

I'll look a bit into it, feel free to beat me to it in case you're familiar with the code and able to provide a fast fix. Especially let me know if you think my svg file is the actual problem here ... Not that I created anything fancy there, but you never know ... :)
Author

Thought i'd run the file through http://validator.w3.org ... and it validates.
That makes it less likely an Inkscape related problem, i guess.
Back to reading code ...

Thought i'd run the file through http://validator.w3.org ... and it validates. That makes it less likely an Inkscape related problem, i guess. Back to reading code ...
Author

So the error occurs when the importer generates the geometry inside blender. (That is, after parsing, which seems to work fine)
Inside class SVGGeometryPATH an object (curve) is created, a bezier spline is added to it, then the script starts adding bezier points, copying over the coordinates from the parsed data.
When printing the spline's bezier_points array length it becomes apparent that the error occurs right when an overflow happens:

len(act_spline.bezier_points)
...

32764
32765
32766
32767 (= signed 16 bit int range upper border)

  • 32768 (= signed 16 bit int range lower border)

So now the question is: Is this by design?

If Blender internally only allows splines with a maximum of 32767 points - and intentionally so - then this is not really a bug of the importer, but rather a shortcoming in gracefully handling this case and reporting that Blender does not support curves with that many points. If on the other hand, we would actually want Blender to be able to handle such an amount of spline data, we probably have to dig deeper and fix how (or in other words: with which type) the bezier points are allocated internally.

I hope my assessment of the situation is correct and I didn't overlook something else.
In any case, I would now need feedback to continue. TIA :)

So the error occurs when the importer generates the geometry inside blender. (That is, after parsing, which seems to work fine) Inside `class SVGGeometryPATH` an object (curve) is created, a bezier spline is added to it, then the script starts adding bezier points, copying over the coordinates from the parsed data. When printing the spline's bezier_points array length it becomes apparent that the error occurs right when an overflow happens: ``` len(act_spline.bezier_points) ``` ``` ... ``` 32764 32765 32766 32767 (= signed 16 bit int range upper border) - 32768 (= signed 16 bit int range lower border) So now the question is: Is this by design? If Blender internally only allows splines with a maximum of 32767 points - and intentionally so - then this is not really a bug of the importer, but rather a shortcoming in gracefully handling this case and reporting that Blender does not support curves with that many points. If on the other hand, we would actually want Blender to be able to handle such an amount of spline data, we probably have to dig deeper and fix how (or in other words: with which type) the bezier points are allocated internally. I hope my assessment of the situation is correct and I didn't overlook something else. In any case, I would now need feedback to continue. TIA :)
Author

Here's two little python snippets for triggering the issue directly from the console:

Create Curve (= 2 points) and add 32765 points = 32767 points - works

bpy.ops.curve.primitive_bezier_curve_add()
bpy.data.objects['BezierCurve'].data.splines[0].bezier_points.add(count=32765)

Create Curve (= 2 points) and add 32766 points = 32768 points - crashes

bpy.ops.curve.primitive_bezier_curve_add()
bpy.data.objects['BezierCurve'].data.splines[0].bezier_points.add(count=32766)
Here's two little python snippets for triggering the issue directly from the console: Create Curve (= 2 points) and add 32765 points = 32767 points - **works** ``` bpy.ops.curve.primitive_bezier_curve_add() bpy.data.objects['BezierCurve'].data.splines[0].bezier_points.add(count=32765) ``` Create Curve (= 2 points) and add 32766 points = 32768 points - **crashes** ``` bpy.ops.curve.primitive_bezier_curve_add() bpy.data.objects['BezierCurve'].data.splines[0].bezier_points.add(count=32766)

Added subscribers: @Sergey, @brecht

Added subscribers: @Sergey, @brecht

It seems reasonable to me to bump some members in the curve data structures like pntsu from short to int, since this seems quite low. But you'd need to carefully check all the files where such member variables are used, since they may still be assigned to shorts in some computations.

It seems reasonable to me to bump some members in the curve data structures like pntsu from short to int, since this seems quite low. But you'd need to carefully check all the files where such member variables are used, since they may still be assigned to shorts in some computations.
Author

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author

Fixed in D212

Fixed in [D212](https://archive.blender.org/developer/D212)
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#38191
No description provided.