Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 12121df

Browse files
adrpoOpenModelica-Hudson
authored andcommitted
fix crashes of omcCAPI on Windows
- use threadData from stack not via GC_malloc_uncollectable - increase exe stack on windows - link with pthread Belonging to [master]: - #2201
1 parent 027e5cb commit 12121df

File tree

11 files changed

+561
-545
lines changed

11 files changed

+561
-545
lines changed

Makefile.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ $(OMBUILDDIR)/include/omc/c/gc_version.h: 3rdParty/gc/include/gc_version.h mkbui
112112
$(OMBUILDDIR)/include/omc/c/gc_pthread_redirects.h: 3rdParty/gc/include/gc_pthread_redirects.h mkbuilddirs
113113
cp -pPR $< $@
114114
3rdParty/gc/Makefile: 3rdParty/gc/configure.ac
115-
(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")
115+
(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")
116116

117117
3rdParty/Ipopt/Makefile: $(LAPACK_TARGET)
118118
@# 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.

SimulationRuntime/c/meta/meta_modelica_data.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ void mmc_catch_dummy_fn();
253253
#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;
254254
#define MMC_CATCH_TOP(X) pthread_setspecific(mmc_thread_data_key,oldThreadData); } else {pthread_setspecific(mmc_thread_data_key,oldThreadData);X;}}}
255255

256+
/* use this to allocate and initialize threadData */
257+
#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); }
258+
256259
/* adrpo: assume MMC_DBL_PAD always! */
257260
struct mmc_real_lit { /* there must be no padding between `header' and `data' */
258261
mmc_uint_t filler;

0 commit comments

Comments
 (0)