[cs631apue] thread stacks

Jan Schaumann jschauma at stevens.edu
Tue Oct 21 17:54:37 EDT 2025


Jan Schaumann <jschauma at stevens.edu> wrote:

> I think different OS may handle this differently,
> however, and it may be useful to check if the same
> predictable offset is used by e.g., OpenBSD, which I
> think may have stronger protections (but I don't have
> an OpenBSD system set up right now).

Ok, I just needed to confirm that I hadn't been
imagining things, and yes, on OpenBSD, each thread
gets an unpredictable stack:

openbsd$ uname -a
OpenBSD openbsd 7.7 GENERIC.MP#361 arm64
openbsd$ ./a.out  
Main at 0x76e2a028f0.
Thread 0 is at 0x226d9daf80.
Thread 1 is at 0x226045d2b0.
Thread 2 is at 0x220efef3c0.
Thread 3 is at 0x22a80e8660.

Stack address differences between threads:
Thread 0 - Thread 1: 223861968 bytes
Thread 1 - Thread 2: 1363599088 bytes
Thread 2 - Thread 3: 2567934624 bytes
openbsd$

-Jan


More information about the cs631apue mailing list