Arrays, recursion and crashes?

David Bovill david at openpartnership.net
Tue Aug 5 10:10:18 EDT 2008


Still hammering away at this bug. It seems something to do with introducing
bad data when deleting an array key. I use the syntax:

delete local someArray [someKey]
>

When I delete a particular key I see strange chars - probably from binary
data in the field displaying the result. I looks like furrther processing of
the array in this state causes the crash. I don't think recursion has
anything to do with it. So its either call by reference parameters or most
likely simply the nature of the key and the data.

The keys are formed of 4 items - a handler name, a single char, a number, a
long reference to a control. So they are long and contain anything that a
named control contains - though there is nothing strange I can see there.

I'll test with different data, with the same script and then try replacing
these long keys with simple ones to see where the bug is... any pointers
would be great, as tracking down crash bugs is very slow work!

2008/8/5 David Bovill <david at openpartnership.net>

> Rev rarely crashes nowadays - but I've got it crashing regularly now :) It
> seems to be in the same area that has caused me problems before so i thuoght
> I would see if others have any similar experiences.
>
> The context: I have an array which is used to store a "graph" = a linked
> series of nodes. Each node is actually a key in the array, and the name of
> the key is the name of a rev control. The elements of the array are other
> named controls with may in turn link to other nodes in the array (named
> controls) producing a graph. The recursive script walks the graph to delete
> a node and anything that node links to that is not linked by other nodes -
> that is it chops off any hanging branches.
>
> This is the general purpose array handler to do this - the one that
> crashes:
>
> on linkArray_DeleteNode @someArray, someKey, @alreadyDeleted
>>     -- was "array_DeleteLinks"
>>     -- Treats an array as a place to store graphs.
>>     -- a recusive command
>>
>>     -- do a recursion safety check to avoid infinite loops
>>     if someKey is among the lines of alreadyDeleted then return false
>>     put someKey & CR after alreadyDeleted
>>
>>     -- delete the node someKey
>>     put someArray [someKey] into childKeys
>>     delete local someArray [someKey]
>>     if childKeys is empty then return false
>>
>>     --  delete any links to the deleted node from other nodes
>>     repeat for each key testKey in someArray
>>         array_DeleteFromIndex someKey, testKey, someArray
>>     end repeat
>>
>>     -- delete any child nodes of the deleted node (chop the branch off)
>>     -- even if there are links from it
>>     -- but not if other nodes link to it
>>     put array_Reverse(someArray) into reversedArray
>>
>>     repeat for each line childKey in childKeys
>>         -- lets work out what other nodes link TO the child
>>         put reversedArray [childKey] into otherLinkingNodes
>>         -- apart from someKey
>>         line_Delete someKey, otherLinkingNodes
>>
>>         if otherLinkingNodes is empty then
>>             -- recursively delete node
>>             linkArray_DeleteNode someArray, childKey, alreadyDeleted
>>         end if
>>     end repeat
>>     return true
>> end linkArray_DeleteNode
>
>
> Its hard to track down bugs that cause crashes and I can't post a stack as
> the example uses a lot of libraries. Any thoughts?
>



More information about the use-livecode mailing list