authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-03-23 20:12:10+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-03-23 20:12:10+01:00
logb21d3535a53d03578705f5458c02afc37922d39f
treef56e606d02dfa5e5d7a19ab9610d3a6cd7446f31
parent09a5f172f876c20e52d6cc0c634d15ddeee8f1ff

std: Fix parameters for pthread_attr_setstack

The guard page size shouldn't be taken into account, pthread is only interested in the usable area.

1 files changed, 6 insertions(+), 1 deletions(-)

lib/std/thread.zig+6-1
......@@ -375,7 +375,12 @@ pub const Thread = struct {
375375 if (c.pthread_attr_init(&attr) != 0) return error.SystemResources;
376376 defer assert(c.pthread_attr_destroy(&attr) == 0);
377377
378 assert(c.pthread_attr_setstack(&attr, mmap_slice.ptr, stack_end_offset) == 0);
378 // Tell pthread where the effective stack start is and its size
379 assert(c.pthread_attr_setstack(
380 &attr,
381 mmap_slice.ptr + guard_end_offset,
382 stack_end_offset - guard_end_offset,
383 ) == 0);
379384
380385 const err = c.pthread_create(&thread_ptr.data.handle, &attr, MainFuncs.posixThreadMain, @intToPtr(*c_void, arg));
381386 switch (err) {