From: mquinson Date: Mon, 8 Jan 2007 22:48:50 +0000 (+0000) Subject: Harden the detection of broken makecontext: check that makecontext arguments can... X-Git-Tag: v3.3~2313 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/207b809260da856cb7a1dc08b357dc0d34aa42f1 Harden the detection of broken makecontext: check that makecontext arguments can be pointers git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3046 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/acmacro/context.m4 b/acmacro/context.m4 index 17dff0777b..604457e3f2 100644 --- a/acmacro/context.m4 +++ b/acmacro/context.m4 @@ -136,10 +136,10 @@ ucontext_t uc_main; void child(void *arg) { - if (arg != (void *)12345) + if (arg != (void *)2147483648) exit(1); if (swapcontext(&uc_child, &uc_main) != 0) - exit(1); + exit(2); } int main(int argc, char *argv[]) @@ -149,28 +149,28 @@ int main(int argc, char *argv[]) /* the default is that it fails */ if ((fp = fopen("conftestval", "w")) == NULL) - exit(1); + exit(3); fprintf(fp, "no\n"); fclose(fp); /* configure a child user-space context */ if ((stack = malloc(64*1024)) == NULL) - exit(1); + exit(4); if (getcontext(&uc_child) != 0) - exit(1); + exit(5); uc_child.uc_link = NULL; uc_child.uc_stack.ss_sp = (char *)stack+(32*1024); uc_child.uc_stack.ss_size = 32*1024; uc_child.uc_stack.ss_flags = 0; - makecontext(&uc_child, child, 2, (void *)12345); + makecontext(&uc_child, child, 2, (void *)2147483648); /* switch into the user context */ if (swapcontext(&uc_main, &uc_child) != 0) - exit(1); + exit(6); /* Fine, child came home */ if ((fp = fopen("conftestval", "w")) == NULL) - exit(1); + exit(7); fprintf(fp, "yes\n"); fclose(fp); diff --git a/configure b/configure index 3b4e15c89d..71e9548f5c 100755 --- a/configure +++ b/configure @@ -23627,10 +23627,10 @@ ucontext_t uc_main; void child(void *arg) { - if (arg != (void *)12345) + if (arg != (void *)2147483648) exit(1); if (swapcontext(&uc_child, &uc_main) != 0) - exit(1); + exit(2); } int main(int argc, char *argv[]) @@ -23640,28 +23640,28 @@ int main(int argc, char *argv[]) /* the default is that it fails */ if ((fp = fopen("conftestval", "w")) == NULL) - exit(1); + exit(3); fprintf(fp, "no\n"); fclose(fp); /* configure a child user-space context */ if ((stack = malloc(64*1024)) == NULL) - exit(1); + exit(4); if (getcontext(&uc_child) != 0) - exit(1); + exit(5); uc_child.uc_link = NULL; uc_child.uc_stack.ss_sp = (char *)stack+(32*1024); uc_child.uc_stack.ss_size = 32*1024; uc_child.uc_stack.ss_flags = 0; - makecontext(&uc_child, child, 2, (void *)12345); + makecontext(&uc_child, child, 2, (void *)2147483648); /* switch into the user context */ if (swapcontext(&uc_main, &uc_child) != 0) - exit(1); + exit(6); /* Fine, child came home */ if ((fp = fopen("conftestval", "w")) == NULL) - exit(1); + exit(7); fprintf(fp, "yes\n"); fclose(fp);