Fix bug in async_fibre_makecontext for POSIX
authorMatt Caswell <matt@openssl.org>
Sun, 11 Oct 2015 15:17:27 +0000 (16:17 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 20 Nov 2015 23:35:19 +0000 (23:35 +0000)
async_fibre_makecontext was initialise the fibre first and then calling
getcontext(). It should be the other way around because the getcontext
call may overwrite some of the things we just initialised. This didn't
cause an issue on Linux and so the problem went unnoticed. On OS-X it
causes a crash.

Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/async/arch/async_posix.h

index aac12f16443e944523e10318f3ac7eddcec40dc7..0f914647134853c13993805e31223338e05f457d 100644 (file)
@@ -97,8 +97,8 @@ static inline int async_fibre_swapcontext(async_fibre *o, async_fibre *n, int r)
 }
 
 #  define async_fibre_makecontext(c) \
-            (async_fibre_init(c) \
-            && !getcontext(&(c)->fibre) \
+            (!getcontext(&(c)->fibre) \
+            && async_fibre_init(c) \
             && (makecontext(&(c)->fibre, async_start_func, 0), 1))
 #  define async_fibre_init_dispatcher(d)