Skip to content

Commit

Permalink
fix crashes of omcCAPI on Windows
Browse files Browse the repository at this point in the history
- use threadData from stack not via GC_malloc_uncollectable
- increase exe stack on windows
- link with pthread

Belonging to [master]:
  - OpenModelica/OMCompiler#2201
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Feb 14, 2018
1 parent 027e5cb commit 12121df
Show file tree
Hide file tree
Showing 11 changed files with 561 additions and 545 deletions.
2 changes: 1 addition & 1 deletion Makefile.common
Expand Up @@ -112,7 +112,7 @@ $(OMBUILDDIR)/include/omc/c/gc_version.h: 3rdParty/gc/include/gc_version.h mkbui
$(OMBUILDDIR)/include/omc/c/gc_pthread_redirects.h: 3rdParty/gc/include/gc_pthread_redirects.h mkbuilddirs
cp -pPR $< $@
3rdParty/gc/Makefile: 3rdParty/gc/configure.ac
(cd 3rdParty/gc && autoreconf -vif && automake --add-missing && ./configure "--host=$(host)" $(LIBGC_EXTRA_CONFIGURATION) --disable-gcj-support --disable-java-finalization --enable-large-config CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS) -DLARGE_CONFIG -DTHREAD_LOCAL_ALLOC")
(cd 3rdParty/gc && autoreconf -vif && automake --add-missing && ./configure "--host=$(host)" $(LIBGC_EXTRA_CONFIGURATION) --enable-static --disable-gcj-support --disable-java-finalization --enable-large-config CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS) -DLARGE_CONFIG -DTHREAD_LOCAL_ALLOC")

3rdParty/Ipopt/Makefile: $(LAPACK_TARGET)
@# Note: CXX is passed LDFLAGS, which is wrong. However, Ipopt does not respect LDFLAGS and fails to link OSX C++ code if we do not do this.
Expand Down
3 changes: 3 additions & 0 deletions SimulationRuntime/c/meta/meta_modelica_data.h
Expand Up @@ -253,6 +253,9 @@ void mmc_catch_dummy_fn();
#define MMC_TRY_TOP_INTERNAL() { threadData_t *oldThreadData = (threadData_t*)pthread_getspecific(mmc_thread_data_key); pthread_setspecific(mmc_thread_data_key,threadData); pthread_mutex_init(&threadData->parentMutex,NULL); mmc_init_stackoverflow(threadData); MMC_TRY_INTERNAL(mmc_jumper) threadData->mmc_stack_overflow_jumper = threadData->mmc_jumper;
#define MMC_CATCH_TOP(X) pthread_setspecific(mmc_thread_data_key,oldThreadData); } else {pthread_setspecific(mmc_thread_data_key,oldThreadData);X;}}}

/* use this to allocate and initialize threadData */
#define MMC_ALLOC_AND_INIT_THREADDATA(_omc_threadData) { size_t len = sizeof(threadData_t); _omc_threadData = (threadData_t*)GC_malloc_uncollectable(len); memset(_omc_threadData, 0, len); pthread_setspecific(mmc_thread_data_key, _omc_threadData); pthread_mutex_init(&_omc_threadData->parentMutex,NULL); mmc_init_stackoverflow(_omc_threadData); }

/* adrpo: assume MMC_DBL_PAD always! */
struct mmc_real_lit { /* there must be no padding between `header' and `data' */
mmc_uint_t filler;
Expand Down

0 comments on commit 12121df

Please sign in to comment.