Skip to content

EXC_BAD_ACCESS (SIGSEGV) crash reason #13

@peternlewis

Description

@peternlewis
                    //        I was receiving about 3 EXC_BAD_ACCESS (SIGSEGV) crash reports a month that listed the 'path' objc_msgSend

A sequence which will generate this is:

VDKQueue deallocs
_keepWatcherThreadRunning = NO
[self removeAllPaths];

At that point all entries's are deallocated.

Meanwhile the thread is stuck in kevent
An event happens on the file
the thread reads the event, retrieves the dangling entry pointer from ev.udata
crash ensues

Multithreading is hard.

A bandaid solution would be to add

if ( !_keepWatcherThreadRunning ) break;

after the kevent, that will minimise the period where the dealloc can happen, but it will still be possible, just far less likely.

Really the events need to be retained by the thread as well and only released when the thread completes, or otherwise the entries need to be validated or looked for some other way that avoids leaving a dangling pointer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions