aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-12-10 20:03:02 +0100
committerSverker Eriksson <[email protected]>2015-11-26 19:48:10 +0100
commit3198ed17179f35b86f7f8ab5c0b9c165d44c1ba6 (patch)
tree35515804bc4214ab04342ec6845dd0581fc559c2 /erts
parent41e0c6e584d392ed0d5fbbc51a84418c4f7abcf5 (diff)
downloadotp-3198ed17179f35b86f7f8ab5c0b9c165d44c1ba6.tar.gz
otp-3198ed17179f35b86f7f8ab5c0b9c165d44c1ba6.tar.bz2
otp-3198ed17179f35b86f7f8ab5c0b9c165d44c1ba6.zip
erts: Workaround for strange crash on win64 in alloc_SUITE test code
For some reason setjmp() crash when having jmp_buf heap allocated but works when stack allocated.
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/test/alloc_SUITE_data/testcase_driver.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/erts/emulator/test/alloc_SUITE_data/testcase_driver.c b/erts/emulator/test/alloc_SUITE_data/testcase_driver.c
index 83ee1b67ca..5b35f581ea 100644
--- a/erts/emulator/test/alloc_SUITE_data/testcase_driver.c
+++ b/erts/emulator/test/alloc_SUITE_data/testcase_driver.c
@@ -45,7 +45,7 @@ typedef struct {
TestCaseState_t visible;
ErlNifEnv* curr_env;
int result;
- jmp_buf done_jmp_buf;
+ jmp_buf* done_jmp_buf;
char *comment;
char comment_buf[COMMENT_BUF_SZ];
} InternalTestCaseState_t;
@@ -110,13 +110,20 @@ testcase_nif_run(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
InternalTestCaseState_t *itcs;
const char* result_atom;
+ jmp_buf the_jmp_buf;
if (!enif_get_resource(env, argv[0], testcase_rt, (void**)&itcs))
return enif_make_badarg(env);
itcs->curr_env = env;
- if (setjmp(itcs->done_jmp_buf) == 0) {
+ /* For some unknown reason, first call to setjmp crashes on win64
+ * when jmp_buf is allocated as part of the resource. But it works when
+ * allocated on stack. It used to work when this was a driver.
+ */
+ itcs->done_jmp_buf = &the_jmp_buf;
+
+ if (setjmp(the_jmp_buf) == 0) {
testcase_run(&itcs->visible);
itcs->result = TESTCASE_SUCCEEDED;
}
@@ -184,7 +191,7 @@ void testcase_succeeded(TestCaseState_t *tcs, char *frmt, ...)
itcs->result = TESTCASE_SUCCEEDED;
itcs->comment = itcs->comment_buf;
- longjmp(itcs->done_jmp_buf, 1);
+ longjmp(*itcs->done_jmp_buf, 1);
}
void testcase_skipped(TestCaseState_t *tcs, char *frmt, ...)
@@ -202,14 +209,14 @@ void testcase_skipped(TestCaseState_t *tcs, char *frmt, ...)
itcs->result = TESTCASE_SKIPPED;
itcs->comment = itcs->comment_buf;
- longjmp(itcs->done_jmp_buf, 1);
+ longjmp(*itcs->done_jmp_buf, 1);
}
void testcase_continue(TestCaseState_t *tcs)
{
InternalTestCaseState_t *itcs = (InternalTestCaseState_t *) tcs;
itcs->result = TESTCASE_CONTINUE;
- longjmp(itcs->done_jmp_buf, 1);
+ longjmp(*itcs->done_jmp_buf, 1);
}
void testcase_failed(TestCaseState_t *tcs, char *frmt, ...)
@@ -236,7 +243,7 @@ void testcase_failed(TestCaseState_t *tcs, char *frmt, ...)
abort();
}
- longjmp(itcs->done_jmp_buf, 1);
+ longjmp(*itcs->done_jmp_buf, 1);
}
void *testcase_alloc(size_t size)