]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.20] runtime: fallback to TEB arbitrary pointer when TLS slots...
authorqmuntal <quimmuntal@gmail.com>
Thu, 20 Apr 2023 15:30:38 +0000 (17:30 +0200)
committerGopher Robot <gobot@golang.org>
Thu, 22 Jun 2023 15:27:07 +0000 (15:27 +0000)
commit6b45fb7b73636dc56b54652d7090de9db3dfff30
treed3a11563fd0c954e48cc0e92422bbd6f0f136715
parentbe30960e587a2892e44c07c0124eec34418ee31f
[release-branch.go1.20] runtime: fallback to TEB arbitrary pointer when TLS slots are full

Note: This CL is cherry-picked from CL 486816 omitting the changes
in sys_windows_386.s, which don't apply to go1.20 release branch
because windows/386 started using the TEB TLS slot in go1.21 (CL 454675).

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 #60535
Updates #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>
(cherry picked from commit 715d53c090ea02dbd73c301684ecbd09b476989e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/504475
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
src/runtime/signal_windows_test.go
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]