Share

Fandango: scripted 3d CAD

Tracker: Bugs

5 Severe crash when entities are initialized nested - ID: 704939
Last Update: Comment added ( j_soffer )

The following code crashes the X server:

def knot3(m=3.0, l=4.0):
beginTrianglesEntity() ### begin (A)
x = 1.5
y = 0.0
z = 0.0
line_from(x, y, z) ### begin (B)
triangle(x, y, x+0.1, y, x+0.1, y+0.1) ### (A)
continues
for i in range(1, 1001):
mu = (i*2*pi*m)/1000.0
nu = (l*mu)/m
x = cos(mu) * (1 + (cos(nu) / 2.0))
y = sin(mu) * (1 + (cos(nu) / 2.0))
z = sin(nu) / 2.0
line_to(x, y, z) ### (B) continues
triangle(x, y, x+0.1, y, x, y+0.1, z, z, z) ###
(A) continues

This happens because of the way iMem::beginEntity and
the entity marshall interactuate; internally, these
functions are called:

iTriangles->beginEntity(layer); (set values a)
iPageStrip->beginEntity(layer); (set values b)
iPageStrip->pushPoint(x, y, z); (increase entities_count b)
iTriangles->pushPoint(x1, y1, z1); (increase
entities_count a)

In short, entities_count is increased twice, and the
address where iTriangles expects to found the bounding
boxes is where iPageStrip set them.

As a temporary workaround, don't add points to an
entity if it is not the one that was created le last.
For example, the crashing function above must be written:

def knot3(m=3.0, l=4.0):
x = 1.5
y = 0.0
z = 0.0
beginTrianglesEntity() # Begin an entity for a triangle
triangle(x, y, x+0.1, y, x+0.1, y+0.1) # draw the
triangle
for i in range(1, 1001):
mu = (i*2*pi*m)/1000.0
nu = (l*mu)/m
x = cos(mu) * (1 + (cos(nu) / 2.0))
y = sin(mu) * (1 + (cos(nu) / 2.0))
z = sin(nu) / 2.0
triangle(x, y, x+0.1, y, x, y+0.1, z, z, z) #
draw more triangles
x = 1.5
y = 0.0
z = 0.0
line_from(x, y, z) # begin an entity for line strips
for i in range(1, 1001):
mu = (i*2*pi*m)/1000.0
nu = (l*mu)/m
x = cos(mu) * (1 + (cos(nu) / 2.0))
y = sin(mu) * (1 + (cos(nu) / 2.0))
z = sin(nu) / 2.0
line_to(x, y, z) # Continue the line strips

Note that no line_to was called between
beginTrianglesEntity and triangle, and no triangle was
called between line_from and line_to.

I'm actively working on a fix.


Jaime Soffer ( j_soffer ) - 2003-03-17 12:11

5

Closed

None

Jaime Soffer

None

None

Public


Comments ( 2 )




Date: 2003-11-13 00:32
Sender: j_sofferProject Admin

Logged In: YES
user_id=306513

The crash was handled long ago, but a permanent solution
(which does not involve closing the application) has just
been implemented on the 0.2.5 release. Closing.


Date: 2003-03-17 22:36
Sender: j_sofferProject Admin

Logged In: YES
user_id=306513

The CVS has now a kludge; the value of the pointers is
checked in fixEntity() and the application exits instead of
corrupting the heap. Downgrading to medium priority.


Log in to comment.

Attached File

No Files Currently Attached

Changes ( 4 )

Field Old Value Date By
status_id Open 2003-11-13 00:32 j_soffer
close_date - 2003-11-13 00:32 j_soffer
priority 9 2003-03-17 22:36 j_soffer
assigned_to nobody 2003-03-17 12:13 j_soffer