kokopelli icon indicating copy to clipboard operation
kokopelli copied to clipboard

Kokopelli crashes on svg export

Open James-Fletcher opened this issue 11 years ago • 3 comments

The file below reliably causes kokopelli to crash when you try to export to sag. I've downloaded and built the most recent sources on my Mac (Mac OS 10.9.2) and I get the following error:

python(81590,0x11bcc9000) malloc: *** error for object 0x7fe1aac86ef0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Abort trap: 6

This is a reduced version of the file narrowing down the error. Removing the final 'slot' (slotl2) in the file below or adjusting the width of the 'slot' makes the export work.

============ .ko file ==============


# Build all parts centered on origin unless otherwise stated

from koko.lib.shapes import *
from math import sqrt

# One cad unit is 1mm
cad.mm_per_unit = 1

# Sizes for 12mm ply on shopbot with 6mm downcut tool
material_thickness = 12 # 12mm ply, measures as 11.6mm to 12mm
initial_material_thickness = material_thickness
tool_size = 6

scale = 50 #one castle unit is 5cm

wall_height = 2*scale
wall_width = 7*scale

tab_height = wall_height/2 # tab should be 10mm high
initial_tab_height = tab_height
tab_width = material_thickness #scale/2

wall = rectangle(-(wall_width/2), wall_width/2, -wall_height/2, wall_height/2)



tab = rectangle(0,tab_width, -(tab_height/2),tab_height/2)
dog = circle(0,0, tool_size/2)
dog_offset = tool_size/3

# tab sticking out of left side
wall += move(tab, -((wall_width/2) + (tab_width)), 0)
wall -= move(dog, -((wall_width/2)+dog_offset), -((tab_height/2)+dog_offset))
wall -= move(dog, -((wall_width/2)+dog_offset), ((tab_height/2)+dog_offset))

# tab inset into right side
#wall -= move(tab, (wall_width/2)-tab_width, 0)
#wall -= move(dog, ((wall_width/2)-tab_width+dog_offset), -((tab_height/2)-dog_offset))
#wall -= move(dog, ((wall_width/2)-tab_width+dog_offset), ((tab_height/2)-dog_offset))

#
# reduce slot width
#

# l2 - exact - 0.4mm width
#material_thickness = initial_material_thickness - 0.4
material_thickness = initial_material_thickness - 0.4
slotl2 = rectangle(-(material_thickness/2), material_thickness/2, -(tab_height/2),tab_height/2)
slotl2 += move(dog, -((material_thickness/2)-dog_offset), -((tab_height/2)-dog_offset))
slotl2 += move(dog, -((material_thickness/2)-dog_offset), ((tab_height/2)-dog_offset))
slotl2 += move(dog, ((material_thickness/2)-dog_offset), -((tab_height/2)-dog_offset))
slotl2 += move(dog, ((material_thickness/2)-dog_offset), ((tab_height/2)-dog_offset))
wall -= move(slotl2, -(initial_material_thickness*6), 0)


cad.shape = wall




James-Fletcher avatar Mar 22 '14 00:03 James-Fletcher

I've reproduced this bug and am working on tracking it down.

mkeeter avatar Mar 27 '14 00:03 mkeeter

Alright, this is a messy bug related to how we contour objects. It looks like your model's expression has zeros on the borders of the spatial partitioning scheme, which breaks multi-scale contouring in subtle ways.

Unfortunately, I haven't touched this code since May of last year, and the code is full of comments like

// Upgrade disconnected edges from children
// (necessary for multi-scale path merging; trust me on this)

This requires a pretty involved fix that I'm unlikely to get to anytime soon. If you're interested in fixing it yourself, take a look at contour.c. I can give you a more detailed explanation of the failure but no easy solution.

Otherwise, try exporting your model at a slightly different scale (i.e. 10.01) or tweaking the parameters by a fraction of a percent; anything that gets the equation's zero points off of the boundaries will solve the crashing.

mkeeter avatar Mar 27 '14 01:03 mkeeter

Ok, thanks Mat. I may have a dig around myself. If there’s nothing obvious I’ll probably just tinker fractionally with the scale.

James Fletcher

On 27 Mar 2014, at 01:15, Matt Keeter [email protected] wrote:

Alright, this is a messy bug related to how we contour objects. It looks like your model's expression has zeros on the borders of the spatial partitioning scheme, which breaks multi-scale contouring in subtle ways.

Unfortunately, I haven't touched this code since May of last year, and the code is full of comments like

// Upgrade disconnected edges from children // (necessary for multi-scale path merging; trust me on this) This requires a pretty involved fix that I'm unlikely to get to anytime soon. If you're interested in fixing it yourself, take a look at contour.c. I can give you a more detailed explanation of the failure but no easy solution.

Otherwise, try exporting your model at a slightly different scale (i.e. 10.01) or tweaking the parameters by a fraction of a percent; anything that gets the equations zero points off of the boundaries will solve the crashing.

— Reply to this email directly or view it on GitHub.

James-Fletcher avatar Mar 27 '14 07:03 James-Fletcher