File tree 3 files changed +17
-4
lines changed
3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -94,10 +94,6 @@ var LibraryPThread = {
94
94
} ,
95
95
initWorker: function ( ) {
96
96
PThread . initShared ( ) ;
97
- #if EMBIND
98
- // Embind must initialize itself on all threads, as it generates support JS.
99
- Module [ '___embind_register_native_and_builtin_types' ] ( ) ;
100
- #endif // EMBIND
101
97
#if MODULARIZE
102
98
// The promise resolve function typically gets called as part of the execution
103
99
// of the Module `run`. The workers/pthreads don't execute `run` here, they
Original file line number Diff line number Diff line change 12
12
var threadInfoStruct = 0 ; // Info area for this thread in Emscripten HEAP (shared). If zero, this worker is not currently hosting an executing pthread.
13
13
var selfThreadId = 0 ; // The ID of this thread. 0 if not hosting a pthread.
14
14
var parentThreadId = 0 ; // The ID of the parent pthread that launched this thread.
15
+ #if EMBIND
16
+ var initializedJS = false ; // Guard variable for one-time init of the JS state (currently only embind types registration)
17
+ #endif
15
18
16
19
var Module = { } ;
17
20
@@ -178,6 +181,15 @@ this.onmessage = function(e) {
178
181
Module [ 'PThread' ] . receiveObjectTransfer ( e . data ) ;
179
182
Module [ 'PThread' ] . setThreadStatus ( Module [ '_pthread_self' ] ( ) , 1 /*EM_THREAD_STATUS_RUNNING*/ ) ;
180
183
184
+ #if EMBIND
185
+ // Embind must initialize itself on all threads, as it generates support JS.
186
+ // We only do this once per worker since they get reused
187
+ if ( ! initializedJS ) {
188
+ Module [ '___embind_register_native_and_builtin_types' ] ( ) ;
189
+ initializedJS = true ;
190
+ }
191
+ #endif // EMBIND
192
+
181
193
try {
182
194
// pthread entry points are always of signature 'void *ThreadMain(void *arg)'
183
195
// Native codebases sometimes spawn threads with other thread entry point signatures,
Original file line number Diff line number Diff line change @@ -8176,6 +8176,11 @@ def test():
8176
8176
self .emcc_args += ['-DPOOL' ]
8177
8177
test ()
8178
8178
8179
+ print ('with embind and stack overflow checks (see #12356)' )
8180
+ self .set_setting ('STACK_OVERFLOW_CHECK' , 2 )
8181
+ self .emcc_args += ['--bind' ]
8182
+ test ()
8183
+
8179
8184
@node_pthreads
8180
8185
def test_pthread_exceptions (self ):
8181
8186
self .set_setting ('PTHREAD_POOL_SIZE' , '2' )
You can’t perform that action at this time.
0 commit comments