Module Name: src Committed By: martin Date: Tue Jun 27 18:51:47 UTC 2023
Modified Files: src/sys/kern [netbsd-10]: kern_timeout.c Log Message: Pull up following revision(s) (requested by pho in ticket #219): sys/kern/kern_timeout.c: revision 1.74 sys/kern/kern_timeout.c: revision 1.75 sys/kern/kern_timeout.c: revision 1.76 callout(9): Fix panic() in callout_destroy() (kern/57226) The culprit was callout_halt(). "(c->c_flags & CALLOUT_FIRED) != 0" wasn't the correct way to check if a callout is running. It failed to wait for a running callout to finish in the following scenario: 1. cpu0 initializes a callout and schedules it. 2. cpu0 invokes callout_softlock() and fires the callout, setting the flag CALLOUT_FIRED. 3. The callout invokes callout_schedule() to re-schedule itself. 4. callout_schedule_locked() clears the flag CALLOUT_FIRED, and releases the lock. 5. Before the lock is re-acquired by callout_softlock(), cpu1 decides to destroy the callout. It first invokes callout_halt() to make sure the callout finishes running. 6. But since CALLOUT_FIRED has been cleared, callout_halt() thinks it's not running and therefore returns without invoking callout_wait(). 7. cpu1 proceeds to invoke callout_destroy() while it's still running on cpu0. callout_destroy() detects that and panics. callout(9): Tidy up the condition for "callout is running on another LWP" No functional changes. callout(9): Delete the unused member cc_cancel from struct callout_cpu I see no reason why it should be there, and believe its a leftover from some old code. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.73.2.1 src/sys/kern/kern_timeout.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.