Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go1.23 with memory regions patch #1

Draft
wants to merge 69 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
362f22d
[release-branch.go1.23] update codereview.cfg for release-branch.go1.23
dr2chase Jun 18, 2024
f3bdcda
[release-branch.go1.23] internal/syscall/unix: fix UTIME_OMIT for dra…
kolyshkin May 30, 2024
eba9e08
[release-branch.go1.23] cmd/compile: support generic alias type
cuonglm Jun 20, 2024
62c3a63
[release-branch.go1.23] internal/godebugs: fix old value for httpserv…
neild Jun 20, 2024
7dff743
[release-branch.go1.23] go1.23rc1
gopherbot Jun 21, 2024
8bd4ed6
[release-branch.go1.23] all: merge master (8f1ec59) into release-bran…
cherrymui Jul 15, 2024
7e4d6c2
[release-branch.go1.23] all: merge master (6948b4d) into release-bran…
cherrymui Jul 15, 2024
30b6fd6
[release-branch.go1.23] go1.23rc2
gopherbot Jul 16, 2024
f5e4e45
[release-branch.go1.23] all: merge master (5e8a731) into release-bran…
dmitshur Jul 22, 2024
559c775
[release-branch.go1.23] os: document CopyFS behavior for symlinks in …
neild Jul 24, 2024
3509415
[release-branch.go1.23] cmd/compile: more informative panic when impo…
griesemer Jul 24, 2024
c9940fe
[release-branch.go1.23] types2, go/types: fix instantiation of named …
cuonglm Jul 25, 2024
7adb012
[release-branch.go1.23] crypto/tls: fix testHandshake close flakes
FiloSottile Aug 1, 2024
63b0f80
[release-branch.go1.23] go/types, types2: only use fileVersion if 1.2…
matloob Aug 7, 2024
ec7d609
[release-branch.go1.23] revert "go/types, types2: only use fileVersio…
cagedmantis Aug 13, 2024
6885bad
[release-branch.go1.23] go1.23.0
gopherbot Aug 13, 2024
dbecb41
[release-branch.go1.23] os: fix Chtimes test flakes
kolyshkin Aug 8, 2024
3c93405
[release-branch.go1.23] os: use O_EXCL instead of O_TRUNC in CopyFS t…
panjf2000 Aug 16, 2024
76346b3
[release-branch.go1.23] unique: use TypeFor instead of TypeOf to get …
mknyszek Aug 21, 2024
9166d2f
[release-branch.go1.23] go/types, types2: Named.cleanup must also han…
griesemer Aug 15, 2024
8002845
[release-branch.go1.23] runtime: on AIX, fix call to _cgo_sys_thread_…
pmur Aug 19, 2024
7afe17b
[release-branch.go1.23] go/types, types2: use max(fileVersion, go1.21…
matloob Aug 16, 2024
9c939a1
[release-branch.go1.23] runtime: store bp on cgocallback as unsafe.Po…
mknyszek Aug 27, 2024
9625a7f
[release-branch.go1.23] go/types, types2: unalias tilde terms in underIs
timothy-king Aug 15, 2024
6de5a71
[release-branch.go1.23] database/sql: fix panic with concurrent Conn …
nklaassen Aug 22, 2024
3d1f1f2
[release-branch.go1.23] cmd: vendor golang.org/x/telemetry@internal-b…
prattmic Aug 28, 2024
53487e5
[release-branch.go1.23] go/parser: track depth in nested element lists
rolandshoemaker Jun 10, 2024
fa8ff1a
[release-branch.go1.23] encoding/gob: cover missed cases when checkin…
rolandshoemaker May 3, 2024
032ac07
[release-branch.go1.23] go/build/constraint: add parsing limits
rolandshoemaker Jun 20, 2024
69234de
[release-branch.go1.23] go1.23.1
gopherbot Sep 5, 2024
80ff7cd
[release-branch.go1.23] cmd/cgo: correct padding required by alignment
ianlancetaylor Aug 27, 2024
a886959
[release-branch.go1.23] runtime: size maps.Clone destination bucket a…
randall77 Aug 29, 2024
82575f7
[release-branch.go1.23] internal/weak: shade pointer in weak-to-stron…
mknyszek Sep 4, 2024
e6598e7
[release-branch.go1.23] os: dup pidfd if caller sets PidFD manually
fuweid Aug 22, 2024
a74951c
[release-branch.go1.23] unique: don't retain uncloned input as key
mknyszek Sep 4, 2024
c8c6f9a
[release-branch.go1.23] syscall: on exec failure, close pidfd
ianlancetaylor Sep 6, 2024
fbddfae
[release-branch.go1.23] cmd/compile: fix wrong esacpe analysis for ra…
cuonglm Sep 18, 2024
3b2e846
[release-branch.go1.23] runtime: if stop/reset races with running tim…
ianlancetaylor Sep 7, 2024
ed07b32
[release-branch.go1.23] go1.23.2
gopherbot Oct 1, 2024
f8080ed
[release-branch.go1.23] runtime: fix TestGdbAutotmpTypes on gdb versi…
shuLhan Jul 13, 2024
9563300
[release-branch.go1.23] os: ignore SIGSYS in checkPidfd
cions Sep 24, 2024
cc16cdf
[release-branch.go1.23] runtime: clear isSending bit earlier
ianlancetaylor Oct 2, 2024
7fc8312
[release-branch.go1.23] os: add clone(CLONE_PIDFD) check to pidfd fea…
prattmic Jun 11, 2024
6495ce0
[release-branch.go1.23] syscall: use SYS_EXIT_GROUP in CLONE_PIDFD fe…
prattmic Oct 2, 2024
35c010a
[release-branch.go1.23] runtime: fix GoroutineProfile stacks not gett…
felixge Aug 30, 2024
8d79bf7
[release-branch.go1.23] runtime: don't frob isSending for tickers
ianlancetaylor Oct 14, 2024
58babf6
[release-branch.go1.23] runtime,time: use atomic.Int32 for isSending
mknyszek Oct 21, 2024
cfe0ae0
[release-branch.go1.23] runtime: uphold goroutine profile invariants …
mknyszek Oct 23, 2024
5472853
[release-branch.go1.23] cmd/link: generate Mach-O UUID when -B flag i…
cherrymui Oct 7, 2024
6ba3a8a
[release-branch.go1.23] internal/poll: keep copying after successful …
neild Oct 23, 2024
958f3a0
[release-branch.go1.23] internal/poll: handle the special case of sen…
panjf2000 Oct 24, 2024
a0d15cb
[release-branch.go1.23] runtime: fix MutexProfile missing root frames
felixge Sep 7, 2024
1207de4
[release-branch.go1.23] runtime: reduce syscall.SyscallX stack usage
qmuntal Oct 8, 2024
c390a1c
[release-branch.go1.23] go1.23.3
gopherbot Nov 6, 2024
3726f07
[release-branch.go1.23] cmd/compile: use a non-fragile test for "does…
dr2chase Oct 25, 2024
777f43a
[release-branch.go1.23]time: accept "+01" in TestLoadFixed on OpenBSD
dmitshur Nov 4, 2024
847cb6f
[release-branch.go1.23] syscall: mark SyscallN as noescape
qmuntal Nov 5, 2024
d8adc6c
[release-branch.go1.23] runtime: prevent weak->strong conversions dur…
mknyszek Nov 1, 2024
be062b7
[release-branch.go1.23] runtime: explicitly keep handle alive during …
mknyszek Nov 20, 2024
25f042d
[release-branch.go1.23] runtime: reserve 4kB for system stack on wind…
rsc Nov 12, 2024
5164a86
[release-branch.go1.23] cmd/trace: also show end stack traces
felixge Nov 26, 2024
194de8f
[release-branch.go1.23] go1.23.4
gopherbot Dec 3, 2024
69c8cfe
[release-branch.go1.23] cmd/compile/internal/importer: enable aliases
timothy-king Aug 9, 2024
59b7d40
[release-branch.go1.23] runtime: update and restore g0 stack bounds a…
cherrymui Jul 22, 2024
1576793
[release-branch.go1.23] net: don't use sendfile for irregular files; …
ianlancetaylor Dec 11, 2024
3417000
[release-branch.go1.23] crypto/tls: fix Config.Time in tests using ex…
FiloSottile Jan 2, 2025
1dde0b4
[release-branch.go1.23] runtime: hold traceAcquire across casgstatus …
mknyszek Dec 23, 2024
29a6c83
local changes after patch for memory regions
csgourav Jan 17, 2025
2158471
cockroach go diff patch
csgourav Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go1.23.4
time 2024-11-27T20:27:20Z
3 changes: 2 additions & 1 deletion codereview.cfg
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
branch: master
branch: release-branch.go1.23
parent-branch: master
23 changes: 16 additions & 7 deletions src/cmd/cgo/gcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2579,6 +2579,11 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
if dt.BitSize > 0 {
fatalf("%s: unexpected: %d-bit int type - %s", lineno(pos), dt.BitSize, dtype)
}

if t.Align = t.Size; t.Align >= c.ptrSize {
t.Align = c.ptrSize
}

switch t.Size {
default:
fatalf("%s: unexpected: %d-byte int type - %s", lineno(pos), t.Size, dtype)
Expand All @@ -2595,9 +2600,8 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
Len: c.intExpr(t.Size),
Elt: c.uint8,
}
}
if t.Align = t.Size; t.Align >= c.ptrSize {
t.Align = c.ptrSize
// t.Align is the alignment of the Go type.
t.Align = 1
}

case *dwarf.PtrType:
Expand Down Expand Up @@ -2826,6 +2830,11 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
if dt.BitSize > 0 {
fatalf("%s: unexpected: %d-bit uint type - %s", lineno(pos), dt.BitSize, dtype)
}

if t.Align = t.Size; t.Align >= c.ptrSize {
t.Align = c.ptrSize
}

switch t.Size {
default:
fatalf("%s: unexpected: %d-byte uint type - %s", lineno(pos), t.Size, dtype)
Expand All @@ -2842,9 +2851,8 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
Len: c.intExpr(t.Size),
Elt: c.uint8,
}
}
if t.Align = t.Size; t.Align >= c.ptrSize {
t.Align = c.ptrSize
// t.Align is the alignment of the Go type.
t.Align = 1
}

case *dwarf.VoidType:
Expand Down Expand Up @@ -3110,10 +3118,11 @@ func (c *typeConv) Struct(dt *dwarf.StructType, pos token.Pos) (expr *ast.Struct
}

// Round off up to talign, assumed to be a power of 2.
origOff := off
off = (off + talign - 1) &^ (talign - 1)

if f.ByteOffset > off {
fld, sizes = c.pad(fld, sizes, f.ByteOffset-off)
fld, sizes = c.pad(fld, sizes, f.ByteOffset-origOff)
off = f.ByteOffset
}
if f.ByteOffset < off {
Expand Down
1 change: 1 addition & 0 deletions src/cmd/cgo/internal/test/cgo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func Test31891(t *testing.T) { test31891(t) }
func Test42018(t *testing.T) { test42018(t) }
func Test45451(t *testing.T) { test45451(t) }
func Test49633(t *testing.T) { test49633(t) }
func Test69086(t *testing.T) { test69086(t) }
func TestAlign(t *testing.T) { testAlign(t) }
func TestAtol(t *testing.T) { testAtol(t) }
func TestBlocking(t *testing.T) { testBlocking(t) }
Expand Down
34 changes: 34 additions & 0 deletions src/cmd/cgo/internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,19 @@ typedef struct {
} issue67517struct;
static void issue67517(issue67517struct* p) {}

// Issue 69086.
// GCC added the __int128 type in GCC 4.6, released in 2011.
typedef struct {
int a;
#ifdef __SIZEOF_INT128__
unsigned __int128 b;
#else
uint64_t b;
#endif
unsigned char c;
} issue69086struct;
static int issue690861(issue69086struct* p) { p->b = 1234; return p->c; }
static int issue690862(unsigned long ul1, unsigned long ul2, unsigned int u, issue69086struct s) { return (int)(s.b); }
*/
import "C"

Expand Down Expand Up @@ -2349,3 +2362,24 @@ func issue67517() {
b: nil,
})
}

// Issue 69086.
func test69086(t *testing.T) {
var s C.issue69086struct

typ := reflect.TypeOf(s)
for i := 0; i < typ.NumField(); i++ {
f := typ.Field(i)
t.Logf("field %d: name %s size %d align %d offset %d", i, f.Name, f.Type.Size(), f.Type.Align(), f.Offset)
}

s.c = 1
got := C.issue690861(&s)
if got != 1 {
t.Errorf("field: got %d, want 1", got)
}
got = C.issue690862(1, 2, 3, s)
if got != 1234 {
t.Errorf("call: got %d, want 1234", got)
}
}
57 changes: 52 additions & 5 deletions src/cmd/cgo/internal/testcarchive/carchive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"unicode"
)

var globalSkip = func(t *testing.T) {}
var globalSkip = func(t testing.TB) {}

// Program to run.
var bin []string
Expand All @@ -59,12 +59,12 @@ func TestMain(m *testing.M) {

func testMain(m *testing.M) int {
if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
globalSkip = func(t *testing.T) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
globalSkip = func(t testing.TB) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
return m.Run()
}
if runtime.GOOS == "linux" {
if _, err := os.Stat("/etc/alpine-release"); err == nil {
globalSkip = func(t *testing.T) { t.Skip("skipping failing test on alpine - go.dev/issue/19938") }
globalSkip = func(t testing.TB) { t.Skip("skipping failing test on alpine - go.dev/issue/19938") }
return m.Run()
}
}
Expand Down Expand Up @@ -1291,8 +1291,8 @@ func TestPreemption(t *testing.T) {
}
}

// Issue 59294. Test calling Go function from C after using some
// stack space.
// Issue 59294 and 68285. Test calling Go function from C after with
// various stack space.
func TestDeepStack(t *testing.T) {
globalSkip(t)
testenv.MustHaveGoBuild(t)
Expand Down Expand Up @@ -1350,6 +1350,53 @@ func TestDeepStack(t *testing.T) {
}
}

func BenchmarkCgoCallbackMainThread(b *testing.B) {
// Benchmark for calling into Go fron C main thread.
// See issue #68587.
//
// It uses a subprocess, which is a C binary that calls
// Go on the main thread b.N times. There is some overhead
// for launching the subprocess. It is probably fine when
// b.N is large.

globalSkip(b)
testenv.MustHaveGoBuild(b)
testenv.MustHaveCGO(b)
testenv.MustHaveBuildMode(b, "c-archive")

if !testWork {
defer func() {
os.Remove("testp10" + exeSuffix)
os.Remove("libgo10.a")
os.Remove("libgo10.h")
}()
}

cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo10.a", "./libgo10")
out, err := cmd.CombinedOutput()
b.Logf("%v\n%s", cmd.Args, out)
if err != nil {
b.Fatal(err)
}

ccArgs := append(cc, "-o", "testp10"+exeSuffix, "main10.c", "libgo10.a")
out, err = exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput()
b.Logf("%v\n%s", ccArgs, out)
if err != nil {
b.Fatal(err)
}

argv := cmdToRun("./testp10")
argv = append(argv, fmt.Sprint(b.N))
cmd = exec.Command(argv[0], argv[1:]...)

b.ResetTimer()
err = cmd.Run()
if err != nil {
b.Fatal(err)
}
}

func TestSharedObject(t *testing.T) {
// Test that we can put a Go c-archive into a C shared object.
globalSkip(t)
Expand Down
12 changes: 12 additions & 0 deletions src/cmd/cgo/internal/testcarchive/testdata/libgo10/a.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import "C"

//export GoF
func GoF() {}

func main() {}
22 changes: 21 additions & 1 deletion src/cmd/cgo/internal/testcarchive/testdata/libgo9/a.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,29 @@ package main

import "runtime"

// extern void callGoWithVariousStack(int);
import "C"

func main() {}

//export GoF
func GoF() { runtime.GC() }
func GoF(p int32) {
runtime.GC()
if p != 0 {
panic("panic")
}
}

//export callGoWithVariousStackAndGoFrame
func callGoWithVariousStackAndGoFrame(p int32) {
if p != 0 {
defer func() {
e := recover()
if e == nil {
panic("did not panic")
}
runtime.GC()
}()
}
C.callGoWithVariousStack(C.int(p));
}
22 changes: 22 additions & 0 deletions src/cmd/cgo/internal/testcarchive/testdata/main10.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include <stdio.h>
#include <stdlib.h>

#include "libgo10.h"

int main(int argc, char **argv) {
int n, i;

if (argc != 2) {
perror("wrong arg");
return 2;
}
n = atoi(argv[1]);
for (i = 0; i < n; i++)
GoF();

return 0;
}
16 changes: 12 additions & 4 deletions src/cmd/cgo/internal/testcarchive/testdata/main9.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@

void use(int *x) { (*x)++; }

void callGoFWithDeepStack() {
void callGoFWithDeepStack(int p) {
int x[10000];

use(&x[0]);
use(&x[9999]);

GoF();
GoF(p);

use(&x[0]);
use(&x[9999]);
}

void callGoWithVariousStack(int p) {
GoF(0); // call GoF without using much stack
callGoFWithDeepStack(p); // call GoF with a deep stack
GoF(0); // again on a shallow stack
}

int main() {
GoF(); // call GoF without using much stack
callGoFWithDeepStack(); // call GoF with a deep stack
callGoWithVariousStack(0);

callGoWithVariousStackAndGoFrame(0); // normal execution
callGoWithVariousStackAndGoFrame(1); // panic and recover
}
11 changes: 6 additions & 5 deletions src/cmd/compile/internal/escape/solve.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,10 @@ func containsClosure(f, c *ir.Func) bool {
return false
}

// Closures within function Foo are named like "Foo.funcN..."
// TODO(mdempsky): Better way to recognize this.
fn := f.Sym().Name
cn := c.Sym().Name
return len(cn) > len(fn) && cn[:len(fn)] == fn && cn[len(fn)] == '.'
for p := c.ClosureParent; p != nil; p = p.ClosureParent {
if p == f {
return true
}
}
return false
}
17 changes: 17 additions & 0 deletions src/cmd/compile/internal/importer/gcimporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,23 @@ func TestIssue25596(t *testing.T) {
compileAndImportPkg(t, "issue25596")
}

func TestIssue70394(t *testing.T) {
testenv.MustHaveGoBuild(t)

// This package only handles gc export data.
if runtime.Compiler != "gc" {
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
}

pkg := compileAndImportPkg(t, "alias")
obj := lookupObj(t, pkg.Scope(), "A")

typ := obj.Type()
if _, ok := typ.(*types2.Alias); !ok {
t.Fatalf("type of %s is %s, wanted an alias", obj, typ)
}
}

func importPkg(t *testing.T, path, srcDir string) *types2.Package {
pkg, err := Import(make(map[string]*types2.Package), path, srcDir, nil)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions src/cmd/compile/internal/importer/testdata/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package testdata

type A = int32
17 changes: 12 additions & 5 deletions src/cmd/compile/internal/importer/ureader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"cmd/compile/internal/syntax"
"cmd/compile/internal/types2"
"cmd/internal/src"
"internal/buildcfg"
"internal/pkgbits"
)

Expand All @@ -28,11 +29,9 @@ func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input
pr := pkgReader{
PkgDecoder: input,

ctxt: ctxt,
imports: imports,
// Currently, the compiler panics when using Alias types.
// TODO(gri) set to true once this is fixed (issue #66873)
enableAlias: false,
ctxt: ctxt,
imports: imports,
enableAlias: true,

posBases: make([]*syntax.PosBase, input.NumElems(pkgbits.RelocPosBase)),
pkgs: make([]*types2.Package, input.NumElems(pkgbits.RelocPkg)),
Expand Down Expand Up @@ -411,6 +410,14 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types2.Package, string) {
panic("weird")

case pkgbits.ObjAlias:
if buildcfg.Experiment.AliasTypeParams && len(r.dict.bounds) > 0 {
// Temporary work-around for issue #68526: rather than panicking
// with an non-descriptive index-out-of-bounds panic when trying
// to access a missing type parameter, instead panic with a more
// descriptive error. Only needed for Go 1.23; Go 1.24 will have
// the correct implementation.
panic("importing generic type aliases is not supported in Go 1.23 (see issue #68526)")
}
pos := r.pos()
typ := r.typ()
return newAliasTypeName(pr.enableAlias, pos, objPkg, objName, typ)
Expand Down
Loading