Skip to content

Commit 7c08383

Browse files
committed
Merge commit '0f7b7600fbf2bda2da9fde3d538b17d9cd39f11d' into tailscale.go1.24
2 parents c1d3e9e + 0f7b760 commit 7c08383

File tree

9 files changed

+136
-10
lines changed

9 files changed

+136
-10
lines changed

doc/godebug.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ and the [go command documentation](/cmd/go#hdr-Build_and_test_caching).
153153

154154
### Go 1.24
155155

156+
Go 1.24 added a new `fips140` setting that controls whether the Go
157+
Cryptographic Module operates in FIPS 140-3 mode.
158+
The possible values are:
159+
- "off": no special support for FIPS 140-3 mode. This is the default.
160+
- "on": the Go Cryptographic Module operates in FIPS 140-3 mode.
161+
- "only": like "on", but cryptographic algorithms not approved by
162+
FIPS 140-3 return an error or panic.
163+
For more information, see [FIPS 140-3 Compliance](/doc/security/fips140).
164+
This setting is fixed at program startup time, and can't be modified
165+
by changing the `GODEBUG` environment variable after the program starts.
166+
156167
Go 1.24 changed the global [`math/rand.Seed`](/pkg/math/rand/#Seed) to be a
157168
no-op. This behavior is controlled by the `randseednop` setting.
158169
For Go 1.24 it defaults to `randseednop=1`.

src/cmd/compile/internal/inline/inl.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,38 @@ func canInlineCallExpr(callerfn *ir.Func, n *ir.CallExpr, callee *ir.Func, bigCa
10091009
return false, 0, false
10101010
}
10111011

1012+
isClosureParent := func(closure, parent *ir.Func) bool {
1013+
for p := closure.ClosureParent; p != nil; p = p.ClosureParent {
1014+
if p == parent {
1015+
return true
1016+
}
1017+
}
1018+
return false
1019+
}
1020+
if isClosureParent(callerfn, callee) {
1021+
// Can't recursively inline a parent of the closure into itself.
1022+
if log && logopt.Enabled() {
1023+
logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", fmt.Sprintf("recursive call to closure parent: %s, %s", ir.FuncName(callerfn), ir.FuncName(callee)))
1024+
}
1025+
return false, 0, false
1026+
}
1027+
if isClosureParent(callee, callerfn) {
1028+
// Can't recursively inline a closure if there's a call to the parent in closure body.
1029+
if ir.Any(callee, func(node ir.Node) bool {
1030+
if call, ok := node.(*ir.CallExpr); ok {
1031+
if name, ok := call.Fun.(*ir.Name); ok && isClosureParent(callerfn, name.Func) {
1032+
return true
1033+
}
1034+
}
1035+
return false
1036+
}) {
1037+
if log && logopt.Enabled() {
1038+
logopt.LogOpt(n.Pos(), "cannotInlineCall", "inline", fmt.Sprintf("recursive call to closure parent: %s, %s", ir.FuncName(callerfn), ir.FuncName(callee)))
1039+
}
1040+
return false, 0, false
1041+
}
1042+
}
1043+
10121044
if base.Flag.Cfg.Instrumenting && types.IsNoInstrumentPkg(callee.Sym().Pkg) {
10131045
// Runtime package must not be instrumented.
10141046
// Instrument skips runtime package. However, some runtime code can be

src/os/os_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3848,3 +3848,14 @@ func TestRemoveReadOnlyFile(t *testing.T) {
38483848
}
38493849
})
38503850
}
3851+
3852+
func TestOpenFileDevNull(t *testing.T) {
3853+
// See https://go.dev/issue/71752.
3854+
t.Parallel()
3855+
3856+
f, err := OpenFile(DevNull, O_WRONLY|O_CREATE|O_TRUNC, 0o644)
3857+
if err != nil {
3858+
t.Fatalf("OpenFile(DevNull): %v", err)
3859+
}
3860+
f.Close()
3861+
}

src/runtime/stubs.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,16 @@ func asmcgocall(fn, arg unsafe.Pointer) int32
312312

313313
func morestack()
314314

315+
// morestack_noctxt should be an internal detail,
316+
// but widely used packages access it using linkname.
317+
// Notable members of the hall of shame include:
318+
// - github.com/bytedance/sonic
319+
//
320+
// Do not remove or change the type signature.
321+
// See go.dev/issues/67401.
322+
// See go.dev/issues/71672.
323+
//
324+
//go:linkname morestack_noctxt
315325
func morestack_noctxt()
316326

317327
func rt0_go()

src/runtime/symtab.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,18 @@ var pinnedTypemaps []map[typeOff]*_type
480480
// the relocated one.
481481
var aixStaticDataBase uintptr // linker symbol
482482

483-
var firstmoduledata moduledata // linker symbol
483+
var firstmoduledata moduledata // linker symbol
484+
485+
// lastmoduledatap should be an internal detail,
486+
// but widely used packages access it using linkname.
487+
// Notable members of the hall of shame include:
488+
// - github.com/bytedance/sonic
489+
//
490+
// Do not remove or change the type signature.
491+
// See go.dev/issues/67401.
492+
// See go.dev/issues/71672.
493+
//
494+
//go:linkname lastmoduledatap
484495
var lastmoduledatap *moduledata // linker symbol
485496

486497
var modulesSlice *[]*moduledata // see activeModules
@@ -591,6 +602,16 @@ func moduledataverify() {
591602

592603
const debugPcln = false
593604

605+
// moduledataverify1 should be an internal detail,
606+
// but widely used packages access it using linkname.
607+
// Notable members of the hall of shame include:
608+
// - github.com/bytedance/sonic
609+
//
610+
// Do not remove or change the type signature.
611+
// See go.dev/issues/67401.
612+
// See go.dev/issues/71672.
613+
//
614+
//go:linkname moduledataverify1
594615
func moduledataverify1(datap *moduledata) {
595616
// Check that the pclntab's format is valid.
596617
hdr := datap.pcHeader

src/runtime/sys_linux_s390x.s

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ TEXT runtime·usleep(SB),NOSPLIT,$16-4
112112
MOVW $1000000, R3
113113
DIVD R3, R2
114114
MOVD R2, 8(R15)
115-
MOVW $1000, R3
116-
MULLD R2, R3
115+
MULLD R2, R3 // Convert sec to usec and subtract
117116
SUB R3, R4
117+
MOVW $1000, R3
118+
MULLD R3, R4 // Convert remaining usec into nsec.
118119
MOVD R4, 16(R15)
119120

120121
// nanosleep(&ts, 0)

src/syscall/syscall_windows.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func NewCallbackCDecl(fn any) uintptr {
235235
//sys GetVersion() (ver uint32, err error)
236236
//sys formatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) = FormatMessageW
237237
//sys ExitProcess(exitcode uint32)
238-
//sys CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile int32) (handle Handle, err error) [failretval==InvalidHandle] = CreateFileW
238+
//sys createFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile int32) (handle Handle, err error) [failretval == InvalidHandle || e1 == ERROR_ALREADY_EXISTS ] = CreateFileW
239239
//sys readFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) = ReadFile
240240
//sys writeFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) = WriteFile
241241
//sys SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) [failretval==0xffffffff]
@@ -404,18 +404,20 @@ func Open(name string, flag int, perm uint32) (fd Handle, err error) {
404404
const _FILE_FLAG_WRITE_THROUGH = 0x80000000
405405
attrs |= _FILE_FLAG_WRITE_THROUGH
406406
}
407-
h, err := CreateFile(namep, access, sharemode, sa, createmode, attrs, 0)
408-
if err != nil {
407+
h, err := createFile(namep, access, sharemode, sa, createmode, attrs, 0)
408+
if h == InvalidHandle {
409409
if err == ERROR_ACCESS_DENIED && (flag&O_WRONLY != 0 || flag&O_RDWR != 0) {
410410
// We should return EISDIR when we are trying to open a directory with write access.
411411
fa, e1 := GetFileAttributes(namep)
412412
if e1 == nil && fa&FILE_ATTRIBUTE_DIRECTORY != 0 {
413413
err = EISDIR
414414
}
415415
}
416-
return InvalidHandle, err
416+
return h, err
417417
}
418-
if flag&O_TRUNC == O_TRUNC {
418+
// Ignore O_TRUNC if the file has just been created.
419+
if flag&O_TRUNC == O_TRUNC &&
420+
(createmode == OPEN_EXISTING || (createmode == OPEN_ALWAYS && err == ERROR_ALREADY_EXISTS)) {
419421
err = Ftruncate(h, 0)
420422
if err != nil {
421423
CloseHandle(h)
@@ -1454,3 +1456,13 @@ func GetStartupInfo(startupInfo *StartupInfo) error {
14541456
getStartupInfo(startupInfo)
14551457
return nil
14561458
}
1459+
1460+
func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile int32) (handle Handle, err error) {
1461+
handle, err = createFile(name, access, mode, sa, createmode, attrs, templatefile)
1462+
if handle != InvalidHandle {
1463+
// CreateFileW can return ERROR_ALREADY_EXISTS with a valid handle.
1464+
// We only want to return an error if the handle is invalid.
1465+
err = nil
1466+
}
1467+
return handle, err
1468+
}

src/syscall/zsyscall_windows.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixedbugs/issue71680.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// compile
2+
3+
// Copyright 2025 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package p
8+
9+
type Parser struct{}
10+
type Node struct{}
11+
12+
type parserState func(p *Parser) parserState
13+
14+
func parserStateData(root *Node) parserState {
15+
return func(p *Parser) parserState {
16+
return parserStateOpenMap(root)(p)
17+
}
18+
}
19+
20+
func parserStateOpenMap(root *Node) parserState {
21+
return func(p *Parser) parserState {
22+
switch {
23+
case p != nil:
24+
return parserStateData(root)(p)
25+
}
26+
return parserStateOpenMap(root)(p)
27+
}
28+
}

0 commit comments

Comments
 (0)