I have found a bug in my ASOC project. The trouble is - it isn’t consistent. It crashes after 3 or 4 or ten runs unexpectedly. I have tracked it down to one of two handlers. They both will cause it independentaly. Removing the code in either stops the crashes associated with that one.
This one appends text to a log file:
on wrightTotestlog_(stuffToWrite) if textlog then try log "In" set stuffToWrite to stuffToWrite as string do shell script "echo '" & newstuff & "' >>" & quoted form of LogPath log "out" end try end if end wrightTotestlog_
This one appends text to a property “logText” which is later used to update a log window text view:
on updateLogText_(newline) log "IN" set aa to my logText as string set bb to newline as string set my logText to (my logText as string) & return & bb log "Out" end updateLogText
Every time there is a crash it stops after the “in” and throws the bad access error.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xffffffffffffffba
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Application Specific Information:
objc: garbage collection is ON
From what I have read, this error usually results from accessing a variable that has been released already, not having retained something etc… but with ASOC and GC on I can not figure out what is the culprit.
Running the exact same code and parameters repeatedly goes fine and then suddenly crashes.
Any clues where to look, if I am assigning something I shouldn’t, etc. would be much appreciated. I have spent hours trying different syntax with always the same results. I just want to update a log as the code rolls along.