]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix an extremely subtle concurrency bug triggered by running on 32-thread
authorNathan Whitehorn <nwhitehorn@FreeBSD.org>
Mon, 9 Feb 2015 02:17:21 +0000 (02:17 +0000)
committerNathan Whitehorn <nwhitehorn@FreeBSD.org>
Mon, 9 Feb 2015 02:17:21 +0000 (02:17 +0000)
commit53607fe3cc8d46cfc7dd2399f1adc8b9581dc5a9
treeece8cbcc3339340563db9ebb7d0ed4789451f10d
parentf1e484179757d5fe3c43ed31972b6bf6e034c012
Fix an extremely subtle concurrency bug triggered by running on 32-thread
POWER8 systems. During thread switch, there was a very small window when
the stack pointer was set to the stack pointer of the outgoing thread, but
after the lock on that thread had already been released.

If, during that window, the outgoing thread were rescheduled on another CPU
and begin execution and an exception were taken on the original CPU, the
trap handler and the outgoing thread would simultaneously execute on the same
stack, causing memory corruption. Fix this by making sure to release the
old thread only after cpu_switch() is done with its stack.

MFC after: 2 weeks
Sponsored by: FreeBSD Foundation
sys/powerpc/powerpc/swtch64.S