Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't test features that are impossible to get right
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 1 Dec 2017 21:12:56 +0000 (22:12 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 1 Dec 2017 21:12:58 +0000 (22:12 +0100)
There is no automatic refcounting in C so when a process is killed, we
must free it immediately. We could maybe propose a workaround to allow
the users to increase the refcount themself (as needed for #248), but
it's much easier to convert your code to C++ than getting the manual
refcounting right, I'd say. Sorry...

The fix to #248 leads to invalid accesses detected by valgrind when
applied to C/MSG.

teshsuite/msg/process-kill/process-kill.c
teshsuite/msg/process-kill/process-kill.tesh

index 9b2e48b..e9ac481 100644 (file)
@@ -7,7 +7,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_process_kill, "Messages specific for this msg example");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_process_kill, "Messages specific for this msg example");
 
-static int victimA_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+static int victim_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   XBT_INFO("Hello!");
   XBT_INFO("Suspending myself");
 {
   XBT_INFO("Hello!");
   XBT_INFO("Suspending myself");
@@ -18,27 +18,17 @@ static int victimA_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[
   return 0;
 }
 
   return 0;
 }
 
-static int victimB_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
-  XBT_INFO("Terminates before being killed");
-  return 0;
-}
-
 static int killer(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   XBT_INFO("Hello!"); /* - First start a victim process */
 static int killer(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   XBT_INFO("Hello!"); /* - First start a victim process */
-  msg_process_t victimA = MSG_process_create("victim A", victimA_fun, NULL, MSG_host_by_name("Fafard"));
-  msg_process_t victimB = MSG_process_create("victim B", victimB_fun, NULL, MSG_host_by_name("Bourassa"));
+  msg_process_t victim = MSG_process_create("victim", victim_fun, NULL, MSG_host_by_name("Fafard"));
   MSG_process_sleep(10.0);
 
   MSG_process_sleep(10.0);
 
-  XBT_INFO("Resume victimA"); /* - Resume it from its suspended state */
-  MSG_process_resume(victimA);
-
-  XBT_INFO("Kill victimA"); /* - and then kill it */
-  MSG_process_kill(victimA);
+  XBT_INFO("Resume victim"); /* - Resume it from its suspended state */
+  MSG_process_resume(victim);
 
 
-  XBT_INFO("Kill victimB, even if it's already dead"); /* that's a no-op, there is no zombies in SimGrid */
-  MSG_process_kill(victimB);
+  XBT_INFO("Kill victim"); /* - and then kill it */
+  MSG_process_kill(victim);
 
   XBT_INFO("OK, goodbye now. I commit a suicide.");
   MSG_process_kill(MSG_process_self());
 
   XBT_INFO("OK, goodbye now. I commit a suicide.");
   MSG_process_kill(MSG_process_self());
index 0f96f81..7b20fb9 100644 (file)
@@ -4,11 +4,9 @@ p Testing a MSG_process_kill function
 
 $ $SG_TEST_EXENV ${bindir:=.}/process-kill ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:killer@Tremblay) Hello!
 
 $ $SG_TEST_EXENV ${bindir:=.}/process-kill ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:killer@Tremblay) Hello!
-> [  0.000000] (2:victim A@Fafard) Hello!
-> [  0.000000] (2:victim A@Fafard) Suspending myself
-> [  0.000000] (3:victim B@Bourassa) Terminates before being killed
-> [ 10.000000] (1:killer@Tremblay) Resume victimA
-> [ 10.000000] (1:killer@Tremblay) Kill victimA
-> [ 10.000000] (1:killer@Tremblay) Kill victimB, even if it's already dead
+> [  0.000000] (2:victim@Fafard) Hello!
+> [  0.000000] (2:victim@Fafard) Suspending myself
+> [ 10.000000] (1:killer@Tremblay) Resume victim
+> [ 10.000000] (1:killer@Tremblay) Kill victim
 > [ 10.000000] (1:killer@Tremblay) OK, goodbye now. I commit a suicide.
 > [ 10.000000] (0:maestro@) Simulation time 10
 > [ 10.000000] (1:killer@Tremblay) OK, goodbye now. I commit a suicide.
 > [ 10.000000] (0:maestro@) Simulation time 10