google / kernel-sanitizers

Linux Kernel Sanitizers, fast bug-detectors for the Linux kernel
https://google.github.io/kernel-sanitizers/
437 stars 87 forks source link

When does ktsan task destroy? #213

Open zizhiyoumu-fuzz opened 5 years ago

zizhiyoumu-fuzz commented 5 years ago

While testing , I found sometimes ktsan task is not destroy.At this time, task state is TASK_DEAD, but not enter finish_task_switch function.After adding some log, I found during context switch, task is switch.Why?When does ktsan task destroy?

anatol commented 5 years ago

The ktsan task data structures are cleaned up (destroyed) by ktsan_task_destroy function. Please check its implementation.

This function is called in finish_task_switch in case if the process is in DEAD state and its context need to be cleaned up.

Does it answer you question?

zizhiyoumu-fuzz commented 5 years ago

The function finish_task_switch I can found.But I find that in finish_task_switch function, it's unlikely prev_state is TASK_DEAD.When I fork and exit processes frequently, the ktsan_task_destroy is slower than create, the maximum number of threads is reached。How can I deal with it?