Skip to content

mutithread erro coredump #8

Description

@jiudianren

qestion1 :

thread1 add a period timer and save time_id.
thread2 is the timer thread.

afer thread2 unlock .
thread 1 use the time_id to call Timer::remove() ,
in Timer::remove , delete the time_id and set handler to nullptr,
but thread 1 is executing the handler.
the coredump happen.

lock.unlock();   
events[te.ref].handler(te.ref);
lock.lock();

what should i do to avoid the problem?

question 2:
thread1 add a period timer and save time_id.
thread2 is the timer thread.

thread 1 will call Timer::remove() in handler callback.
while the handler is executing ,it call Timer::remove, But in Timer::remove set handler to nullptr .
and so the program core dump.

	events[id].valid = false;
	events[id].handler = nullptr;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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