Skip to content

Commit 0229a90

Browse files
committed
Fix the creation of stack integrity cookie (if used in the build) in pthread startup routine so that calling functions that check the validity of the stack is safe from pthreads.
1 parent 26606be commit 0229a90

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/pthread-main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ this.onmessage = function(e) {
7777
assert(STACK_MAX > STACK_BASE);
7878
Runtime.establishStackSpace(e.data.stackBase, e.data.stackBase + e.data.stackSize);
7979
var result = 0;
80+
//#if STACK_OVERFLOW_CHECK
81+
if (typeof writeStackCookie === 'function') writeStackCookie();
82+
//#endif
8083

8184
PThread.receiveObjectTransfer(e.data);
8285

@@ -90,6 +93,10 @@ this.onmessage = function(e) {
9093
} else {
9194
result = Module['asm'].dynCall_i(e.data.start_routine); // as a hack, try signature 'i' as fallback.
9295
}
96+
//#if STACK_OVERFLOW_CHECK
97+
if (typeof checkStackCookie === 'function') checkStackCookie();
98+
//#endif
99+
93100
} catch(e) {
94101
if (e === 'Canceled!') {
95102
PThread.threadCancel();

0 commit comments

Comments
 (0)