mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
Merge "[dev.typeparams] all: merge master (912f075
) into dev.typeparams" into dev.typeparams
This commit is contained in:
commit
611056ec34
|
@ -181,6 +181,7 @@ pkg syscall (windows-amd64), type SysProcAttr struct, AdditionalInheritedHandles
|
|||
pkg syscall (windows-amd64), type SysProcAttr struct, ParentProcess Handle
|
||||
pkg testing, method (*B) Setenv(string, string)
|
||||
pkg testing, method (*T) Setenv(string, string)
|
||||
pkg testing, type TB interface, Setenv(string, string)
|
||||
pkg text/template/parse, const SkipFuncCheck = 2
|
||||
pkg text/template/parse, const SkipFuncCheck Mode
|
||||
pkg time, const Layout = "01/02 03:04:05PM '06 -0700"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!--{
|
||||
"Title": "The Go Programming Language Specification",
|
||||
"Subtitle": "Version of Jun 28, 2021",
|
||||
"Subtitle": "Version of Jul 1, 2021",
|
||||
"Path": "/ref/spec"
|
||||
}-->
|
||||
|
||||
|
@ -6782,7 +6782,8 @@ The rules for <a href="/pkg/unsafe#Pointer">valid uses</a> of <code>Pointer</cod
|
|||
|
||||
<p>
|
||||
The function <code>Slice</code> returns a slice whose underlying array starts at <code>ptr</code>
|
||||
and whose length and capacity are <code>len</code>:
|
||||
and whose length and capacity are <code>len</code>.
|
||||
<code>Slice(ptr, len)</code> is equivalent to
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
|
@ -6790,7 +6791,8 @@ and whose length and capacity are <code>len</code>:
|
|||
</pre>
|
||||
|
||||
<p>
|
||||
As a special case, if <code>ptr</code> is <code>nil</code> and <code>len</code> is zero,
|
||||
except that, as a special case, if <code>ptr</code>
|
||||
is <code>nil</code> and <code>len</code> is zero,
|
||||
<code>Slice</code> returns <code>nil</code>.
|
||||
</p>
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ stack frame is laid out in the following sequence:
|
|||
r1.x uintptr
|
||||
r1.y [2]uintptr
|
||||
a1Spill uint8
|
||||
a2Spill uint8
|
||||
a3Spill uint8
|
||||
_ [6]uint8 // alignment padding
|
||||
|
||||
In the stack frame, only the `a2` field is initialized on entry; the
|
||||
|
|
|
@ -186,14 +186,14 @@ func HeapAllocReason(n ir.Node) string {
|
|||
return "too large for stack"
|
||||
}
|
||||
|
||||
if (n.Op() == ir.ONEW || n.Op() == ir.OPTRLIT) && n.Type().Elem().Width >= ir.MaxImplicitStackVarSize {
|
||||
if (n.Op() == ir.ONEW || n.Op() == ir.OPTRLIT) && n.Type().Elem().Width > ir.MaxImplicitStackVarSize {
|
||||
return "too large for stack"
|
||||
}
|
||||
|
||||
if n.Op() == ir.OCLOSURE && typecheck.ClosureType(n.(*ir.ClosureExpr)).Size() >= ir.MaxImplicitStackVarSize {
|
||||
if n.Op() == ir.OCLOSURE && typecheck.ClosureType(n.(*ir.ClosureExpr)).Size() > ir.MaxImplicitStackVarSize {
|
||||
return "too large for stack"
|
||||
}
|
||||
if n.Op() == ir.OMETHVALUE && typecheck.PartialCallType(n.(*ir.SelectorExpr)).Size() >= ir.MaxImplicitStackVarSize {
|
||||
if n.Op() == ir.OMETHVALUE && typecheck.PartialCallType(n.(*ir.SelectorExpr)).Size() > ir.MaxImplicitStackVarSize {
|
||||
return "too large for stack"
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ func HeapAllocReason(n ir.Node) string {
|
|||
if !ir.IsSmallIntConst(r) {
|
||||
return "non-constant size"
|
||||
}
|
||||
if t := n.Type(); t.Elem().Width != 0 && ir.Int64Val(r) >= ir.MaxImplicitStackVarSize/t.Elem().Width {
|
||||
if t := n.Type(); t.Elem().Width != 0 && ir.Int64Val(r) > ir.MaxImplicitStackVarSize/t.Elem().Width {
|
||||
return "too large for stack"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1115,8 +1115,14 @@ func (state *debugState) buildLocationLists(blockLocs []*BlockDebug) {
|
|||
continue
|
||||
}
|
||||
|
||||
mustBeFirst := func(v *Value) bool {
|
||||
return v.Op == OpPhi || v.Op.isLoweredGetClosurePtr() ||
|
||||
v.Op == OpArgIntReg || v.Op == OpArgFloatReg
|
||||
}
|
||||
|
||||
zeroWidthPending := false
|
||||
apcChangedSize := 0 // size of changedVars for leading Args, Phi, ClosurePtr
|
||||
blockPrologComplete := false // set to true at first non-zero-width op
|
||||
apcChangedSize := 0 // size of changedVars for leading Args, Phi, ClosurePtr
|
||||
// expect to see values in pattern (apc)* (zerowidth|real)*
|
||||
for _, v := range b.Values {
|
||||
slots := state.valueNames[v.ID]
|
||||
|
@ -1125,16 +1131,16 @@ func (state *debugState) buildLocationLists(blockLocs []*BlockDebug) {
|
|||
|
||||
if opcodeTable[v.Op].zeroWidth {
|
||||
if changed {
|
||||
if hasAnyArgOp(v) || v.Op == OpPhi || v.Op.isLoweredGetClosurePtr() {
|
||||
if mustBeFirst(v) || v.Op == OpArg {
|
||||
// These ranges begin at true beginning of block, not after first instruction
|
||||
if zeroWidthPending {
|
||||
panic(fmt.Errorf("Unexpected op '%s' mixed with OpArg/OpPhi/OpLoweredGetClosurePtr at beginning of block %s in %s\n%s", v.LongString(), b, b.Func.Name, b.Func))
|
||||
if blockPrologComplete && mustBeFirst(v) {
|
||||
panic(fmt.Errorf("Unexpected placement of op '%s' appearing after non-pseudo-op at beginning of block %s in %s\n%s", v.LongString(), b, b.Func.Name, b.Func))
|
||||
}
|
||||
apcChangedSize = len(state.changedVars.contents())
|
||||
// Other zero-width ops must wait on a "real" op.
|
||||
zeroWidthPending = true
|
||||
continue
|
||||
}
|
||||
// Other zero-width ops must wait on a "real" op.
|
||||
zeroWidthPending = true
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
@ -1145,6 +1151,7 @@ func (state *debugState) buildLocationLists(blockLocs []*BlockDebug) {
|
|||
// Not zero-width; i.e., a "real" instruction.
|
||||
|
||||
zeroWidthPending = false
|
||||
blockPrologComplete = true
|
||||
for i, varID := range state.changedVars.contents() {
|
||||
if i < apcChangedSize { // buffered true start-of-block changes
|
||||
state.updateVar(VarID(varID), v.Block, BlockStart)
|
||||
|
|
|
@ -489,7 +489,7 @@ func walkNew(n *ir.UnaryExpr, init *ir.Nodes) ir.Node {
|
|||
base.Errorf("%v can't be allocated in Go; it is incomplete (or unallocatable)", n.Type().Elem())
|
||||
}
|
||||
if n.Esc() == ir.EscNone {
|
||||
if t.Size() >= ir.MaxImplicitStackVarSize {
|
||||
if t.Size() > ir.MaxImplicitStackVarSize {
|
||||
base.Fatalf("large ONEW with EscNone: %v", n)
|
||||
}
|
||||
return stackTempAddr(init, t)
|
||||
|
|
2
src/cmd/dist/test.go
vendored
2
src/cmd/dist/test.go
vendored
|
@ -781,7 +781,7 @@ func (t *tester) registerTests() {
|
|||
t.registerTest("testasan", "../misc/cgo/testasan", "go", "run", ".")
|
||||
}
|
||||
if goos == "linux" && goarch != "ppc64le" {
|
||||
// because syscall.SysProcAttri struct used in misc/cgo/testsanitizers is only built on linux.
|
||||
// because syscall.SysProcAttr struct used in misc/cgo/testsanitizers is only built on linux.
|
||||
// Some inconsistent failures happen on ppc64le so disable for now.
|
||||
t.registerHostTest("testsanitizers", "../misc/cgo/testsanitizers", "misc/cgo/testsanitizers", ".")
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
@ -299,7 +300,7 @@ func copyMetadata(modPath, pkg, dst, src string, copiedFiles map[string]bool) {
|
|||
if modPath == pkg {
|
||||
break
|
||||
}
|
||||
pkg = filepath.Dir(pkg)
|
||||
pkg = path.Dir(pkg)
|
||||
dst = filepath.Dir(dst)
|
||||
src = filepath.Dir(src)
|
||||
}
|
||||
|
|
31
src/cmd/go/testdata/script/mod_vendor_issue46867.txt
vendored
Normal file
31
src/cmd/go/testdata/script/mod_vendor_issue46867.txt
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Regression test for golang.org/issue/46867:
|
||||
# 'go mod vendor' on Windows attempted to open and copy
|
||||
# files from directories outside of the module.
|
||||
|
||||
cd subdir
|
||||
go mod vendor
|
||||
! exists vendor/example.net/NOTICE
|
||||
exists vendor/example.net/m/NOTICE
|
||||
|
||||
-- subdir/go.mod --
|
||||
module golang.org/issue46867
|
||||
|
||||
go 1.17
|
||||
|
||||
replace example.net/m v0.1.0 => ./m
|
||||
|
||||
require example.net/m v0.1.0
|
||||
-- subdir/issue.go --
|
||||
package issue
|
||||
|
||||
import _ "example.net/m/n"
|
||||
-- subdir/m/go.mod --
|
||||
module example.net/m
|
||||
|
||||
go 1.17
|
||||
-- subdir/m/n/n.go --
|
||||
package n
|
||||
-- subdir/m/NOTICE --
|
||||
This notice is in module m and SHOULD be vendored.
|
||||
-- subdir/NOTICE --
|
||||
This notice is outside of module m and SHOULD NOT be vendored.
|
|
@ -1957,3 +1957,43 @@ func TestCVE202133195(t *testing.T) {
|
|||
t.Errorf("LookupAddr returned unexpected error, got %q, want %q", err, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNullMX(t *testing.T) {
|
||||
fake := fakeDNSServer{
|
||||
rh: func(n, _ string, q dnsmessage.Message, _ time.Time) (dnsmessage.Message, error) {
|
||||
r := dnsmessage.Message{
|
||||
Header: dnsmessage.Header{
|
||||
ID: q.Header.ID,
|
||||
Response: true,
|
||||
RCode: dnsmessage.RCodeSuccess,
|
||||
},
|
||||
Questions: q.Questions,
|
||||
Answers: []dnsmessage.Resource{
|
||||
{
|
||||
Header: dnsmessage.ResourceHeader{
|
||||
Name: q.Questions[0].Name,
|
||||
Type: dnsmessage.TypeMX,
|
||||
Class: dnsmessage.ClassINET,
|
||||
},
|
||||
Body: &dnsmessage.MXResource{
|
||||
MX: dnsmessage.MustNewName("."),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return r, nil
|
||||
},
|
||||
}
|
||||
r := Resolver{PreferGo: true, Dial: fake.DialContext}
|
||||
rrset, err := r.LookupMX(context.Background(), "golang.org")
|
||||
if err != nil {
|
||||
t.Fatalf("LookupMX: %v", err)
|
||||
}
|
||||
if want := []*MX{&MX{Host: "."}}; !reflect.DeepEqual(rrset, want) {
|
||||
records := []string{}
|
||||
for _, rr := range rrset {
|
||||
records = append(records, fmt.Sprintf("%v", rr))
|
||||
}
|
||||
t.Errorf("records = [%v]; want [%v]", strings.Join(records, " "), want[0])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -427,6 +427,7 @@ func (t *Transport) onceSetNextProtoDefaults() {
|
|||
//
|
||||
// The environment values may be either a complete URL or a
|
||||
// "host[:port]", in which case the "http" scheme is assumed.
|
||||
// The schemes "http", "https", and "socks5" are supported.
|
||||
// An error is returned if the value is a different form.
|
||||
//
|
||||
// A nil URL and nil error are returned if no proxy is defined in the
|
||||
|
|
|
@ -500,7 +500,9 @@ func (r *Resolver) LookupMX(ctx context.Context, name string) ([]*MX, error) {
|
|||
if mx == nil {
|
||||
continue
|
||||
}
|
||||
if !isDomainName(mx.Host) {
|
||||
// Bypass the hostname validity check for targets which contain only a dot,
|
||||
// as this is used to represent a 'Null' MX record.
|
||||
if mx.Host != "." && !isDomainName(mx.Host) {
|
||||
return nil, &DNSError{Err: "MX target is invalid", Name: name}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1061,7 +1061,9 @@ func newstack() {
|
|||
// recheck the bounds on return.)
|
||||
if f := findfunc(gp.sched.pc); f.valid() {
|
||||
max := uintptr(funcMaxSPDelta(f))
|
||||
for newsize-gp.sched.sp < max+_StackGuard {
|
||||
needed := max + _StackGuard
|
||||
used := gp.stack.hi - gp.sched.sp
|
||||
for newsize-used < needed {
|
||||
newsize *= 2
|
||||
}
|
||||
}
|
||||
|
|
|
@ -644,6 +644,7 @@ type TB interface {
|
|||
Log(args ...interface{})
|
||||
Logf(format string, args ...interface{})
|
||||
Name() string
|
||||
Setenv(key, value string)
|
||||
Skip(args ...interface{})
|
||||
SkipNow()
|
||||
Skipf(format string, args ...interface{})
|
||||
|
|
|
@ -217,11 +217,13 @@ func Alignof(x ArbitraryType) uintptr
|
|||
func Add(ptr Pointer, len IntegerType) Pointer
|
||||
|
||||
// The function Slice returns a slice whose underlying array starts at ptr
|
||||
// and whose length and capacity are len:
|
||||
// and whose length and capacity are len.
|
||||
// Slice(ptr, len) is equivalent to
|
||||
//
|
||||
// (*[len]ArbitraryType)(unsafe.Pointer(ptr))[:]
|
||||
//
|
||||
// As a special case, if ptr is nil and len is zero, Slice returns nil.
|
||||
// except that, as a special case, if ptr is nil and len is zero,
|
||||
// Slice returns nil.
|
||||
//
|
||||
// The len argument must be of integer type or an untyped constant.
|
||||
// A constant len argument must be non-negative and representable by a value of type int;
|
||||
|
|
Loading…
Reference in a new issue