aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2022-01-14runtime: skip known TestSegv failure mode on linux-mips64le-mengzhuoBryan C. Mills
Also adjust other skips to actually call t.Skip, so that the test correctly shows as skipped instead of passing. For #50605 Change-Id: Ied482f231a879224c5a92e2c47a6b21c1593a7da Reviewed-on: https://go-review.googlesource.com/c/go/+/378554 Trust: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-14runtime: fix net poll racesRuss Cox
The netpoll code was written long ago, when the only multiprocessors that Go ran on were x86. It assumed that an atomic store would trigger a full memory barrier and then used that barrier to order otherwise racy access to a handful of fields, including pollDesc.closing. On ARM64, this code has finally failed, because the atomic store is on a value completely unrelated to any of the racily-accessed fields, and the ARMv8 hardware, unlike x86, is clever enough not to do a full memory barrier for a simple atomic store. We are seeing a constant background rate of trybot failures where the net/http tests deadlock - a netpollblock has clearly happened after the pollDesc has begun to close. The code that does the racy reads is netpollcheckerr, which needs to be able to run without acquiring a lock. This CL fixes the race, without introducing unnecessary inefficiency or deadlock, by arranging for every updater of the relevant fields to publish a summary as a single atomic uint32, and then having netpollcheckerr use a single atomic load to fetch the relevant bits and then proceed as before. Fixes #45211 (until proven otherwise!). Change-Id: Ib6788c8da4d00b7bda84d55ca3fdffb5a64c1a0a Reviewed-on: https://go-review.googlesource.com/c/go/+/378234 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Trust: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-14cmd/compile: add call to ImportedBody() when exporting shape inst bodyDan Scales
When we export a shape instantiation, because a particular fully-instantiated type is needed by an inlineable function, we possibly export the body of the instantiation, if it is inlineable. In this case, we should have been calling ImportedBody() to make sure that the function body had already been read in (if it is actually imported from another package). Fixes #50598 Change-Id: I512d2bcc745faa6ff3a97e25bc8f46e2c2643d23 Reviewed-on: https://go-review.googlesource.com/c/go/+/378494 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
2022-01-13cmd/compile: stop interface conversions for generic method calls from allocatingKeith Randall
Let T be a type parameter, and say we instantiate it with S, a type that isn't pointer-like (e.g. a pair of ints, or as in 50182, a slice). Then to call a method m on a variable of type T, the compiler does essentially: var v T = ... i := (interface{m()})(v) i.m() The conversion at that second line allocates, as we need to make the data word for an interface. And in the general case, that interface may live an arbitrarily long time. But in this case, we know it doesn't. The data word of i has type *S. When we call i.m, we can't call S.m directly. It is expecting an S, not a *S. We call through a wrapper defined on *S, which looks like: func (p *S) m() { var s S = *p s.m() } The value passed in for p is exactly the data word mentioned above. It never escapes anywhere - the wrapper copies a type S variable out of *p and p is dead after that. That means that in the situation where we build an interface for the explicit purpose of calling a method on it, and use that built interface nowhere else, the allocation of the data word for that interface is known to die before the call returns and thus can be stack allocated. One tricky case is that although the allocation of the backing store of the interface conversion doesn't escape, pointers we store *inside* that allocation might escape (in fact they definitely will, unless we can devirtualize the receiver). Fixes #50182 Change-Id: I40e893955c2e6871c54ccecf1b9f0cae17871b0d Reviewed-on: https://go-review.googlesource.com/c/go/+/378178 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-13testing: skip flaky TestRaiseException on windows-amd64-2012Patrik Nyblom
This is in relation to #49681 Change-Id: I32ad8b506cf8fb0a94b15c3cc8b1eaf5af728c59 Reviewed-on: https://go-review.googlesource.com/c/go/+/378254 Run-TryBot: Patrik Nyblom <pnyb@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Patrik Nyblom <pnyb@google.com>
2022-01-13cmd/compile: descend through types to find fully-instantiated typesDan Scales
In order to make sure we export the dictionaries/shape methods for all fully-instantiated types in inlineable functions, we need to descend fully into types. For example, we may have a map type (e.g. map[transactionID]Promise[*ByteBuffer]), where the key or value is a new fully-instantiated type. So, I add a new checkFullyInst() traversal function, which traverses all encountered types, but maintains a map, so it only traverse it type once. We need to descend fully into interfaces, structs, and methods, since a fully-instantiated type make occur in any fields or arguments/results of methods, etc. Fixes #50561 Change-Id: I88681a30384168539ed7229eed709f4e73ff0666 Reviewed-on: https://go-review.googlesource.com/c/go/+/378154 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-13cmd/compile: unique LinkString for renamed, embedded fieldsMatthew Dempsky
Using type aliases, it's possible to create structs with embedded fields that have no corresponding type literal notation. However, we still need to generate a unique name for these types to use for linker symbols. This CL introduces a new "struct{ Name = Type }" syntax for use in LinkString formatting to represent these types. Reattempt at CL 372914, which was rolled back due to race-y LocalPkg.Lookup call that isn't safe for concurrency. Fixes #50190. Change-Id: I0b7fd81e1b0b3199a6afcffde96ade42495ad8d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/378434 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2022-01-13database/sql: consolidate test polling loopsBryan C. Mills
Also eliminate some arbitrary deadlines and sleeps. Fixes #49958 Change-Id: I999b39a896e430e3bb93aa8b8c9444f28bbaa9d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/378395 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2022-01-13cmd/go: run go install in workspace modeMichael Matloob
It's too confusing to users to run go install in module mode, so run it in workspace mode instead. Fixes #50036 Change-Id: Ia99927bd98f54be4c42224a247543892045e3464 Reviewed-on: https://go-review.googlesource.com/c/go/+/377334 Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-13cmd/go: reset modfetch state between modules in go work syncMichael Matloob
go work sync resets the state in the modload package before each iteration where it updates the workspace modules' go.mod files. But before this change it wasn't resetting the global state in the modfetch package. This is necessary because the modfetch package keeps track of the sums that will be written to go.sum. Further, the fetch caches will update information about which modules are used when fetching packages, and so those caches need to be cleared between each workspace module. Thanks bcmills for helping me debug! Fixes #50038 Change-Id: I5679c18a80feb7c5194c4a5f7e7129c7d198ef7b Reviewed-on: https://go-review.googlesource.com/c/go/+/376655 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-13all: add a handful of fuzz targetsRoland Shoemaker
Adds simple fuzz targets to archive/tar, archive/zip, compress/gzip, encoding/json, image/jpeg, image/gif, and image/png. Second attempt, this time we don't use the archives in testdata when fuzzing archive/tar, since those are rather memory intensive, and were crashing a number of builders. Change-Id: I4828d64fa4763c0d8c980392a6578e4dfd956e13 Reviewed-on: https://go-review.googlesource.com/c/go/+/378174 Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-12cmd/go: enable fuzz testing for FreeBSDAyan George
Add "freebsd" to GOOS for which sys.FuzzSupported() returns true and add freebsd to the build tags to fuzz test source. Fixes #46554 Change-Id: I5f695ecc8f09c0ab4279ced23b4715b788fcade0 Reviewed-on: https://go-review.googlesource.com/c/go/+/377855 Trust: Bryan Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
2022-01-12go/types, types2: fix tracing output for type and expr listsRobert Griesemer
- support printing of expression and type lists in sprintf - simplified some code in go/types/exprstring.go - fixed a typo in syntax package Change-Id: Ic4bc154200aad95958d5bc2904a9ea17cf518388 Reviewed-on: https://go-review.googlesource.com/c/go/+/377974 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-12go/types, types2: prevent unification from recursing endlesslyRobert Griesemer
This is a stop gap solution to avoid panics due to stack overflow during type unification. While this doesn't address the underlying issues (for which we are still investigating the correct approach), it prevents a panic during compilation and reports a (possibly not quite correct) error message. If the programs are correct in the first place, manually providing the desired type arguments is a viable work-around, resulting in code that will continue to work even when the issues here are fixed satisfactorily. For #48619. For #48656. Change-Id: I13bb14552b38b4170b5a1b820e3172d88ff656ec Reviewed-on: https://go-review.googlesource.com/c/go/+/377954 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-12go/types, types2: make function type inference argument-order independentRobert Griesemer
If we have more than 2 arguments, we may have arguments with named and unnamed types. If that is the case, permutate params and args such that the arguments with named types are first in the list. This doesn't affect type inference if all types are taken as is. But when we have inexact unification enabled (as is the case for function type inference), when a named type is unified with an unnamed type, unification proceeds with the underlying type of the named type because otherwise unification would fail right away. This leads to an asymmetry in type inference: in cases where arguments of named and unnamed types are passed to parameters with identical type, different types (named vs underlying) may be inferred depending on the order of the arguments. By ensuring that named types are seen first, order dependence is avoided and unification succeeds where it can. This CL implements the respectice code but keeps it disabled for now, pending decision whether we want to address this issue in the first place. For #43056. Change-Id: Ibe3b08ec2afe90a24a8c30cd1875d504bcc2ef39 Reviewed-on: https://go-review.googlesource.com/c/go/+/377894 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-12go/ast: mention that FieldLists can now be enclosed by bracketsRobert Findley
Type parameter lists are stored using ast.FieldLists. Update the documentation to reflect that the enclosing delimiter may be a bracket. Change-Id: Id103e7b38975e94a1b521f75695edc10408ad3dd Reviewed-on: https://go-review.googlesource.com/c/go/+/378014 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-12Revert "all: add a handful of fuzz targets"Bryan Mills
This reverts CL 352109. Reason for revert: causing OOM failures on several builders, and may cause OOMs for end users with small machines as well. Change-Id: I58308d09919969d5a6512ee5cee6aa5c4af6769b Reviewed-on: https://go-review.googlesource.com/c/go/+/377934 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Katie Hockman <katie@golang.org>
2022-01-12go/types, types2: do not run CTI before FTIRobert Griesemer
Until now, CTI (constraint type inference) was run before FTI (function type inference). This lead to situations where CTI infered a type that is missing necessary methods even though a function argument of correct type was given. This can happen when constraint type inference produces a inferred type that is the structural type of multiple types, which then is an underlying type, possibly without methods. This CL removes the initial CTI step; it is only applied after FTI with type arguments is run, and again after FTI with untyped arguments is run. Various comments are adjusted to reflect the new reality. Fixes #50426. Change-Id: I700ae6e762d7aa00d742943a2880f1a1db33c2b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/377594 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-12all: add a handful of fuzz targetsRoland Shoemaker
Adds simple fuzz targets to archive/tar, archive/zip, compress/gzip, encoding/json, image/jpeg, image/gif, and image/png. Change-Id: Ide1a8de88a9421e786eeeaea3bb93f41e0bae347 Reviewed-on: https://go-review.googlesource.com/c/go/+/352109 Trust: Katie Hockman <katie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-12cmd/compile/types2, go/types: add position for "have" in failed interface ↵Emmanuel T Odeke
satisfaction With this change, we shall now see: *myS does not implement S (wrong type for DoSomething method) have DoSomething() (string, error) at ./main.go:9:14 want DoSomething() (int, error) instead of previously: *myS does not implement S (wrong type for DoSomething method) have DoSomething() (string, error) want DoSomething() (int, error) Fixes #42841 Fixes #45813 Change-Id: I66990929e39b0d36f2e91da0d92f60586a9b84e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/373634 Trust: Robert Findley <rfindley@google.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2022-01-11cmd/compile: fix the names of methods created during type substitutionDan Scales
The names given to methods of types created during type substitution were possible incorrect when the type parameters themselves were nested types. Fixes #50485 Change-Id: I7e0043ed22c26406a5f9d8d51d9e928770a678f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/377494 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-11cmd/compile: in typ0(), load base type before checking s.DefDan Scales
The loading of the base type in typ0() may cause s.Def to be defined for the instantiated type, so load the base type before checking s.Def. Fixes #50486 Change-Id: Ic039bc8f774dda534f4ccd1f920220b7a10dede6 Reviewed-on: https://go-review.googlesource.com/c/go/+/377094 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2022-01-11cmd/compile: resolve dictionaries/shape methods in markInlBody, if neededDan Scales
Issue #50552 is due to a problem with my recent improvement in the interaction between generics and inlining. In markInlBody(), we now mark dictionaries and shape methods for export, so they will be available for any package that inlines the current inlineable function. But we need to make sure that the dictionary and method symbols have actually been resolved into Nodes (looked up in the import data), if they are not already defined, so we can then mark them for export. Improved header comment on Resolve(). Fixes #50552 Change-Id: I89e52d39d3b9894591d2ad6eb3a8ed3bb5f1e0a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/377714 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2022-01-11go/types, types2: mention type decl scopes in Info.Scopes documentationRobert Findley
We now may have a scope associated with a type declaration, so need to update our API documentation accordingly. Change-Id: Ic66dc3b7cd1969b25fb7c4bee986d76ab3544042 Reviewed-on: https://go-review.googlesource.com/c/go/+/377655 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-11cmd/compile: print "internal compiler error" message for all compiler panicsDan Scales
Change hidePanic (now renamed handlePanic) to print out the "internal compiler error" message for all panics and runtime exceptions, similar to what we already do for the SSA backend in ssa.Compile(). Previously, hidePanic would not catch panics/exceptions unless it wanted to completely hide the panic because there had already been some compiler errors. Tested by manually inserting a seg fault in the compiler, and verifying that the seg fault is cause and "internal compiler error" message (with stack trace) is displayed proeprly. Updates #50423 Change-Id: Ibe846012e147fcdcc63ac147aae4bdfc47bf5a58 Reviewed-on: https://go-review.googlesource.com/c/go/+/376057 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2022-01-11runtime: improve asanread/asanwrite nosplit commentAustin Clements
Explain the conditions under which they are called on stacks that cannot grow. Change-Id: I08ee5480face7fbedeccc09e55b8149c5a793c2e Reviewed-on: https://go-review.googlesource.com/c/go/+/376036 Trust: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Fannie Zhang <Fannie.Zhang@arm.com>
2022-01-11cmd/go: skip TestScript/test_fuzz_test_race on !raceTobias Klauser
Skip the test on targets which don't support the race detector. This fixes the linux-386-longtest builder after CL 376554. Updates #50488 Change-Id: I08bf6f72cc0731761d49121eb7cfaa8b53906d37 Reviewed-on: https://go-review.googlesource.com/c/go/+/377634 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org>
2022-01-10go/types, types2: refer to type parameter if so for interface pointer errorsRobert Griesemer
Follow-up on comment in CL 376914. Also: - add missing check != nil test in assignableTo - use check.sprintf rather than fmt.Sprintf in missingMethodReason For #48312. Change-Id: Ie209b4101a7f2c279e42a59987d0068079c8b69f Reviewed-on: https://go-review.googlesource.com/c/go/+/377375 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-10go/types, types2: better error message for type parameter field accessRobert Griesemer
Fixes #50516. Also call DefPredeclaredTestFuncs in TestFixedbugs so it can be run independently again. Change-Id: I78d4cc11790b1543a2545a7ab297a223b3d5e3c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/376954 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-10go/types, types2: better error message when using *interface instead of ↵Robert Griesemer
interface - detect *interface case and report specific error - replaced switch with sequence of if's for more clarity - fixed isInterfacePtr: it applies to all interfaces, incl. type parameters - reviewed/fixed all uses of isInterfacePtr - adjusted error messages to be consistently of the format "type %s is pointer to interface, not interface" Fixes #48312. Change-Id: Ic3c8cfcf93ad57ecdb60f6a727cce9e1aa4afb5d Reviewed-on: https://go-review.googlesource.com/c/go/+/376914 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-10testing: only snapshot coverage during fuzzingRoland Shoemaker
Only snapshot/reset coverage counters when we are actually fuzzing. This prevents a race when running corpus/seed values during the testing phase. Fixes #50488 Change-Id: I7dd5a0353a296c0b13eede29ad9af7c78814fa2d Reviewed-on: https://go-review.googlesource.com/c/go/+/376554 Trust: Katie Hockman <katie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-10cmd/compile: use exact constant in go_asm.hIan Lance Taylor
Fixes #50523 Change-Id: Idab1b44d106250e9301d90ee6571f0ea51242dd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/377074 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Liz Fong-Jones <lizf@honeycomb.io> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-10Revert "cmd/compile: unique LinkString for renamed, embedded fields"Matthew Dempsky
This reverts CL 372914. Reason for revert: missing synchronization Change-Id: I7ebb6de082cebb73741d803ff00e3465bbafab81 Reviewed-on: https://go-review.googlesource.com/c/go/+/377379 Trust: Dan Scales <danscales@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dan Scales <danscales@google.com> Trust: Matthew Dempsky <mdempsky@google.com>
2022-01-10cmd/compile, test: updated comments in crawler.go, added testDan Scales
Added a test to make sure that the private methods of a local generic type are properly exported, if there is a global variable with that type. Added comments in crawler.go, to give more detail and to give more about the overall purpose. Fixed one place where t.isFullyInstantiated() should be replaced by isPtrFullyInstantiated(t), so that we catch pointers to generic types that may be used as a method receiver. Change-Id: I9c42d14eb6ebe14d249df7c8fa39e889f7cd3f22 Reviewed-on: https://go-review.googlesource.com/c/go/+/374754 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-10cmd/compile: unique LinkString for renamed, embedded fieldsMatthew Dempsky
Using type aliases, it's possible to create structs with embedded fields that have no corresponding type literal notation. However, we still need to generate a unique name for these types to use for linker symbols. This CL introduces a new "struct{ Name = Type }" syntax for use in LinkString formatting to represent these types. Fixes #50190. Change-Id: I025ceb09a86e00b7583d3b9885d612f5d6cb44fe Reviewed-on: https://go-review.googlesource.com/c/go/+/372914 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Robert Griesemer <gri@golang.org>
2022-01-10runtime: expand TestGdbPythonCgo skip to include mips64leBryan C. Mills
The failure mode in #37794 does not match the failure mode described in #18784. However, since the test is currently skipped on all other MIPS variants, it may be that they suffer from the same underlying GDB bug. Ideally one of the Go MIPS maintainers should file an upstream bug and remove the skip once it is fixed; in the meantime, there is no point in continuing to let the test fail on just one of the four MIPS variants. For #37794 Change-Id: I570f51cc04cbb7ef1ed7efd526e26886af53bfb6 Reviewed-on: https://go-review.googlesource.com/c/go/+/376654 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-10cmd/compile: fix interaction between generics and inliningDan Scales
Finally figured out how to deal with the interaction between generics and inlining. The problem has been: what to do if you inline a function that uses a new instantiated type that hasn't been seen in the current package? This might mean that you need to do another round of function/method instantiatiations after inlining, which might lead to more inlining, etc. (which is what we currently do, but it's not clear when you can stop the inlining/instantiation loop). We had thought that one solution was to export instantiated types (even if not marked as exportable) if they are referenced in exported inlineable functions. But that was quite complex and required changing the export format. But I realized that we really only need to make sure the relevant dictionaries and shape instantiations for the instantiated types are exported, not the instantiated type itself and its wrappers. The instantiated type is naturally created as needed, and the wrappers are generated automatically while writing out run-time type (making use of the exported dictionaries and shape instantiations). So, we just have to make sure that those dictionaries and shape instantiations are exported, and then they will be available without any extra round of instantiations after inlining. We now do this in crawler.go. This is especially needed when the instantiated type is only put in an interface, so relevant dictionaries/shape instantiations are not directly referenced and therefore exported, but are still needed for the itab. This fix avoids the phase ordering problem where we might have to keep creating new type instantiations and instantiated methods after each round of inlining we do. Removed the extra round of instantiation/inlining that were added in the previous fix. The existing tests test/typeparam{geninline.go,structinit.go} already test this situation of inlining a function referencing a new instantiated type. Added the original example from issue 50121 as test (has 5 packages), since it found a problem with this code that the current simpler test for 50121 did not find. Change-Id: Iac5d0dddf4be19376f6de36ee20a83f0d8f213b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/375494 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2022-01-10runtime/pprof: run TestCPUProfileMultithreadMagnitude subtests separatelyMichael Pratt
Currently TestCPUProfileMultithreadMagnitude runs two CPU consumption functions in a single profile and then analyzes the results as separate subtests. This works fine, but when debugging failures it makes manual analysis of the profile dump a bit annoying. Refactor the test to collect separate profiles for each subtest for easier future analysis. For #50097. For #50232. Change-Id: Ia1c8bb86aaaf652e64c5e660dcc2da47d2194c2b Reviewed-on: https://go-review.googlesource.com/c/go/+/372800 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Rhys Hiltner <rhys@justin.tv> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-01-10net/http: map FS Open errors just like DirJonathan Amsterdam
When an http.FileServer is given a path like file1/file2 where file1 exists but file2 does not, the proper HTTP status should be NotFound. Some OSes return a "not a directory" error instead, so this must be mapped to NotFound. That mapping was already being done for the Dir FileSystem implementation, as discussed in #18984. But it wasn't for the FS implementation. This CL does the same mapping for FS, by generalizing the function that did it for Dir. Fixes #49552 Change-Id: I61d6aa8ef101158e9674707d44e653f5dedbd040 Reviewed-on: https://go-review.googlesource.com/c/go/+/376874 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-09go/types, types2: better error message for invalid == on type parametersRobert Griesemer
Fixes #48712. Change-Id: I6f214cdfdd1815493f2a04828e8f0097f1d8c124 Reviewed-on: https://go-review.googlesource.com/c/go/+/372734 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-08net/http/internal/testcert: use FIPS-compliant certificateDamien Neil
Upgrade the test certificate from RSA 1024 (not FIPS-approved) to RSA 2048 (FIPS-approved), allowing tests to pass when the dev.boringcrypto branch FIPS-only mode is enabled. Fixes #48674. Change-Id: I613d2f8d0207bf3683fd0df256bf0167604996c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/353869 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2022-01-07runtime: skip TestSegv traceback check on 386Michael Pratt
The VDSO (__kernel_vsyscall) is reachable via asmcgocall(cgo_start_thread) on linux-386, which causes traceback to throw. Fixes #49182. For #50504. Change-Id: Idb78cb8de752203ce0ed63c2dbd2d12847338688 Reviewed-on: https://go-review.googlesource.com/c/go/+/376656 Reviewed-by: Cherry Mui <cherryyz@google.com> Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com>
2022-01-07cmd/compile: accept string|[]byte-constrained 2nd argument in appendRobert Griesemer
Similarly to what we do for the built-in function `copy`, where we allow a string as 2nd argument to append, also permit a type parameter constrained by string|[]byte. While at it, change date in the manual.go2 test files so that we don't need to constantly correct it when copying a test case from that file into a proper test file. Fixes #50281. Change-Id: I23fed66736aa07bb3c481fe97313e828425ac448 Reviewed-on: https://go-review.googlesource.com/c/go/+/376214 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-07syscall: in TestDirent, make as many ReadDirent calls as are neededBryan C. Mills
ReadDirent returns only as many directory entries as will fit in the buffer, and each entry is variable-length — so we have no guarantee in general that a buffer of a given arbitrary size can hold even one entry, let alone all ten entries expected by the test. Instead, iterate calls to ReadDirent until one of the calls returns zero entries and no error, indicating that the directory has been read to completion. Fixes #37323 Change-Id: I7f1cedde7666107256604e4ea1ac13c71f22151a Reviewed-on: https://go-review.googlesource.com/c/go/+/376334 Trust: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-07cmd/compile: fix conv of slice of user-define byte type to stringDan Scales
types2 allows the conversion of a slice of a user-defined byte type B (not builtin uint8 or byte) to string. But runtime.slicebytetostring requires a []byte argument, so add in a CONVNOP from []B to []byte if needed. Same for the conversion of a slice of user-defined rune types to string. I made the same change in the transformations of the old typechecker, so as to keep tcConv() and transformConv() in sync. That fixes the bug for -G=0 mode as well. Fixes #23536 Change-Id: Ic79364427f27489187f3f8015bdfbf0769a70d69 Reviewed-on: https://go-review.googlesource.com/c/go/+/376056 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-07cmd/compile: fix instantiation of types referenced during inliningCuong Manh Le
CL 352870 added extra phase for instantiation after inlining, to take care of the new fully-instantiated types. However, when fetching inlined body of these types's methods, we need to allow OADDR operations on untyped expressions, the same as what main inlining phase does. The problem does not show up, until CL 371554, which made the compiler do not re-typecheck while importing, thus leaving a OXDOT node to be marked as address taken when it's not safe to do that. Fixes #50437 Change-Id: I20076b872182c520075a4f8b84230f5bcb05b341 Reviewed-on: https://go-review.googlesource.com/c/go/+/375574 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2022-01-07math/big: fix spurious race in Rat.Denom, Float.SetRatRuss Cox
Rat maintains the invariant that x.b.neg is always false, but Rat.Denom was writing x.b.neg = false itself too. That makes Rat.Denom a writing operation, when it should be a read-only operation. That in turn makes it unsafe to use from multiple goroutines, which is highly unexpected. Make it read-only and therefore race-free again. Fixes #50473. Change-Id: I97b87913954511e5200c0665d16b9ed63422e505 Reviewed-on: https://go-review.googlesource.com/c/go/+/375935 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2022-01-07go/types, types2: disallow multiple blank type parametersRobert Griesemer
Work-around for #50481: report an error for multiple blank type parameters. It's always possible to use non-blank names in those cases. We expect to lift this restriction for 1.19. For #50481. Change-Id: Ifdd2d91340aac1da3387f7d80d46e44f5997c2a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/376058 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Dan Scales <danscales@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06cmd/compile: report type parameter error for methods only onceRobert Griesemer
Move switch to enable method type parameters entirely to the parser, by adding the mode AllowMethodTypeParams. Ensure that the error messages are consistent. Remove unnecessary code in the type checker. Fixes #50317. Change-Id: I4f3958722400bdb919efa4c494b85cf62f4002bb Reviewed-on: https://go-review.googlesource.com/c/go/+/376054 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06testing: fix deadlock with t.Parallel in testing seed corpusKatie Hockman
The c.startParallel channel on the testContext is stuck in t.Parallel() because c.running starts at 1 for the main fuzz parent test, and is causing a deadlock because it is never released. It would normally be released by tRunner, but needs to instead be released by fRunner instead for fuzz tests. Fixes #50217 Change-Id: I2d010e9adddfd8e8321ff2f9dd2e43daf46c128f Reviewed-on: https://go-review.googlesource.com/c/go/+/374054 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>