]> Cypherpunks repositories - gostls13.git/commit
runtime: fallback to TEB arbitrary pointer when TLS slots are full
authorqmuntal <quimmuntal@gmail.com>
Thu, 20 Apr 2023 15:30:38 +0000 (17:30 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Tue, 25 Apr 2023 15:37:00 +0000 (15:37 +0000)
commit715d53c090ea02dbd73c301684ecbd09b476989e
tree91becbd7765a53639e91d30c4bd95a9ab5f6ab65
parent14f833f117dde3c370fb6cb47ce45a34c46eb2de
runtime: fallback to TEB arbitrary pointer when TLS slots are full

The Go runtime allocates the TLS slot in the TEB TLS slots instead of
using the TEB arbitrary pointer. See CL 431775 for more context.

The problem is that the TEB TLS slots array only has capacity for 64
indices, allocating more requires some complex logic that we don't
support yet.

Although the Go runtime only allocates one index, a Go DLL can be
loaded in a process with more than 64 TLS slots allocated,
in which case it abort.

This CL avoids aborting by falling back to the older behavior, that
is to use the TEB arbitrary pointer.

Fixes #59213

Change-Id: I39c73286fe2da95aa9c5ec5657ee0979ecbec533
Reviewed-on: https://go-review.googlesource.com/c/go/+/486816
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/runtime/signal_windows_test.go
src/runtime/sys_windows_386.s
src/runtime/sys_windows_amd64.s
src/runtime/sys_windows_arm64.s
src/runtime/testdata/testwintls/main.c [new file with mode: 0644]
src/runtime/testdata/testwintls/main.go [new file with mode: 0644]