From 7783cc04ff41dd5be2b6ece9aa5b3bf6911b847b Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 23 Feb 2017 10:56:52 +0100 Subject: [PATCH] change a 'use after free' into a leak. For now --- src/simix/ActorImpl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index bc0c3d2053..5553d28e98 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -695,6 +695,7 @@ static int SIMIX_process_join_finish(smx_process_exit_status_t status, smx_activ sleep->surf_sleep = nullptr; } sleep->unref(); + // intrusive_ptr_release(process); // FIXME: We are leaking here. See comment in SIMIX_process_join() return 0; } @@ -702,6 +703,12 @@ smx_activity_t SIMIX_process_join(smx_actor_t issuer, smx_actor_t process, doubl { smx_activity_t res = SIMIX_process_sleep(issuer, timeout); static_cast(res)->ref(); + /* We are leaking the process here, but if we don't take the ref, we get a "use after free". + * The correct solution would be to derivate the type SynchroSleep into a SynchroProcessJoin, + * but the code is not clean enough for now for this. + * The C API should first be properly replaced with the C++ one, which is a fair amount of work. + */ + intrusive_ptr_add_ref(process); SIMIX_process_on_exit(process, (int_f_pvoid_pvoid_t)SIMIX_process_join_finish, res); return res; } -- 2.20.1