Skip to content

Commit

Permalink
Fixed bootstrapping? If it doesn't we need a new tarball
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17218 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Sep 12, 2013
1 parent ad8946e commit ba50037
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion SimulationRuntime/c/meta/meta_modelica.h
Expand Up @@ -635,7 +635,7 @@ void mmc_catch_dummy_fn();
#if 1

extern pthread_key_t mmc_jumper;
#define MMC_INIT() pthread_key_create(&mmc_jumper,NULL);init_metamodelica_segv_handler();mmc_GC_init(mmc_GC_settings_default);
#define MMC_INIT() pthread_key_create(&mmc_jumper,NULL);init_metamodelica_segv_handler();mmc_GC_init(mmc_GC_settings_default);MMC_INIT_STACK_OVERFLOW();
#define MMC_TRY_INTERNAL(X) { jmp_buf new_mmc_jumper, *old_jumper; old_jumper = (jmp_buf*)pthread_getspecific(X); pthread_setspecific(X,&new_mmc_jumper); if (setjmp(new_mmc_jumper) == 0) {
#define MMC_TRY() MMC_TRY_INTERNAL(mmc_jumper)

Expand Down
12 changes: 6 additions & 6 deletions SimulationRuntime/c/meta/meta_modelica_segv.c
Expand Up @@ -31,6 +31,9 @@
/* Stack overflow handling */

#include <meta_modelica.h>

pthread_key_t mmc_stack_overflow_jumper;

#if defined(linux) || defined(__APPLE_CC__)
#include <stdlib.h>
#include <stdio.h>
Expand All @@ -50,7 +53,6 @@
/* If we find a SIGSEGV near the end of the stack, it is probably due to a stack overflow. 64kB for a function frame seems reasonable. */
#define LIMIT_FOR_STACK_OVERFLOW 65536

jmp_buf *mmc_stack_overflow_jumper;
static void *trace[TRACE_NFRAMES];
static int trace_size;
static int trace_size_skip=0; /* First index we should use; that is skip handler, etc */
Expand Down Expand Up @@ -93,16 +95,16 @@ static sigset_t segvset;

static void handler(int signo, siginfo_t *si, void *ptr)
{
int isStackOverflow;
int isStackOverflow,unused;
isStackOverflow = si->si_addr < stackBottom && (si->si_addr > stackBottom - LIMIT_FOR_STACK_OVERFLOW);
if (isStackOverflow) {
setTrace(3,0);
sigprocmask(SIG_UNBLOCK, &segvset, NULL);
longjmp(*mmc_stack_overflow_jumper,1);
longjmp(*((jmp_buf*)pthread_getspecific(mmc_stack_overflow_jumper)),1);
}
/* This backtrace uses very little stack-space, and segmentation faults we always want to print... */
setTrace(3,16);
write(2, "\nLimited backtrace at point of segmentation fault\n", 50);
unused=write(2, "\nLimited backtrace at point of segmentation fault\n", 50);
backtrace_symbols_fd(trace+trace_size_skip, trace_size-trace_size_skip, 2);
sigaction(SIGSEGV, &default_segv_action, 0);
}
Expand Down Expand Up @@ -148,8 +150,6 @@ void init_metamodelica_segv_handler()
}

#else
#include <setjmp.h>
jmp_buf *mmc_stack_overflow_jumper;
void printStacktraceMessages()
{
}
Expand Down
4 changes: 3 additions & 1 deletion SimulationRuntime/c/meta/meta_modelica_segv.h
Expand Up @@ -33,7 +33,9 @@
#ifndef META_MODELICA_SEGV_H_
#define META_MODELICA_SEGV_H_

extern jmp_buf *mmc_stack_overflow_jumper;
#include <pthread.h>
extern pthread_key_t mmc_stack_overflow_jumper;
#define MMC_INIT_STACK_OVERFLOW() pthread_key_create(&mmc_stack_overflow_jumper,NULL)
#define MMC_TRY_STACK() MMC_TRY_INTERNAL(mmc_stack_overflow_jumper)
#define MMC_CATCH_STACK() MMC_CATCH_INTERNAL(mmc_stack_overflow_jumper)

Expand Down

0 comments on commit ba50037

Please sign in to comment.