Skip to content

Commit

Permalink
FreeBSD fixes. The minimum stack size is too small and causes a segv.…
Browse files Browse the repository at this point in the history
… The ss_sp field in the

sigaltstack structure is char* rather than void* so added a cast.


git-svn-id: svn://svn.code.sf.net/p/polyml/code/trunk/polyml@515 ae7d391e-3f74-4a2b-a0db-a8776840fd2a
  • Loading branch information
dcjm committed Jul 29, 2008
1 parent 66dde98 commit c59360b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libpolyml/sighandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,9 @@ void initThreadSignals(TaskData *taskData)
struct sigaltstack ex_stack;
#endif
memset(&ex_stack, 0, sizeof(ex_stack));
ex_stack.ss_sp = taskData->signalStack;
// Cast to char* because ss_sp is char* in FreeBSD.
// Linux simply casts it back to void*.
ex_stack.ss_sp = (char*)taskData->signalStack;
ex_stack.ss_size = SIGSTKSZ;
ex_stack.ss_flags = 0; /* not SS_DISABLE */
int sigaltstack_result = sigaltstack(&ex_stack, NULL);
Expand Down Expand Up @@ -526,7 +528,11 @@ void SigHandler::Init(void)
pthread_attr_init(&attrs);
pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
#ifdef PTHREAD_STACK_MIN
#if (PTHREAD_STACK_MIN < 4096)
pthread_attr_setstacksize(&attrs, 4096); // But not too small: FreeBSD makes it 2k
#else
pthread_attr_setstacksize(&attrs, PTHREAD_STACK_MIN); // Only small stack.
#endif
#endif
pthread_create(&detectionThreadId, &attrs, SignalDetectionThread, 0);
pthread_attr_destroy(&attrs);
Expand Down

0 comments on commit c59360b

Please sign in to comment.