1
0
mirror of https://github.com/golang/go synced 2024-10-05 08:21:22 -06:00
Commit Graph

7207 Commits

Author SHA1 Message Date
Mikio Hara
a0509d8510 syscall: simplify netlink sockets
R=dave, rsc
CC=golang-dev
https://golang.org/cl/7039044
2013-01-14 19:29:03 +09:00
Rémy Oudompheng
406ca3c2f1 encoding/json: fix panics on type mismatches.
Fixes #4222.
Fixes #4628.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7100049
2013-01-14 08:44:16 +01:00
Alex Brainman
06af0ea3f3 encoding/gob: fix broken test (fix build)
R=golang-dev, kevlar
CC=adg, golang-dev
https://golang.org/cl/7093056
2013-01-14 17:03:19 +11:00
Kyle Lemons
bc1152a32e encoding/gob: handle encoding of different indirects of GobEncoder
Fixes #4647.

R=r, golang-dev
CC=golang-dev
https://golang.org/cl/7085051
2013-01-14 16:07:11 +11:00
Robert Griesemer
94878070af go/types: Moving from *ast.Objects to types.Objects (step 2).
Completely removed *ast.Objects from being exposed by the
types API. *ast.Objects are still required internally for
resolution, but now the door is open for an internal-only
rewrite of identifier resolution entirely at type-check
time. Once that is done, ASTs can be type-checked whether
they have been created via the go/parser or otherwise,
and type-checking does not require *ast.Object or scope
invariants to be maintained externally.

R=adonovan
CC=golang-dev
https://golang.org/cl/7096048
2013-01-13 10:33:08 -08:00
Rémy Oudompheng
c13866db7f cmd/5c: fix handling of side effects when assigning a struct literal.
Also undo revision a5b96b602690 used to workaround the bug.

Fixes #4643.

R=rsc, golang-dev, dave, minux.ma, lucio.dere, bradfitz
CC=golang-dev
https://golang.org/cl/7090043
2013-01-12 09:16:50 +01:00
Caleb Spare
b78f5f0e3a testing: document whitespace trimming of example expected/actual output.
Fixes #4642.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7090044
2013-01-12 11:18:15 +11:00
Kamil Kisiel
ad63c7e50b text/template: Document that range can be used on chan types.
Fixes #4640.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7082044
2013-01-12 11:06:13 +11:00
Ryan Slade
3073a02b19 testing: in example, empty output not distinguished from missing output
Fixes #4485.

R=golang-dev, rsc, adg
CC=golang-dev
https://golang.org/cl/7071050
2013-01-12 11:05:53 +11:00
Brad Fitzpatrick
05bf9a456a net/http/cgi: fix test case sensitivity on Windows
Fixes #4645

R=golang-dev, alex.brainman, minux.ma
CC=golang-dev
https://golang.org/cl/7105047
2013-01-11 15:11:08 -08:00
Robert Griesemer
8b62f54eb7 go/types: export QualifiedName.IsSame and NamedType.AstObj
R=adonovan
CC=golang-dev
https://golang.org/cl/7103047
2013-01-11 14:55:49 -08:00
Brad Fitzpatrick
20130f141f database/sql: document args, add a couple examples
Fixes #3460

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/7096046
2013-01-11 14:46:49 -08:00
Robert Griesemer
5a9463bda7 go/types: Moving from *ast.Objects to types.Objects (step 1).
The existing type checker was relying on augmenting ast.Object
fields (empty interfaces) for its purposes. While this worked
for some time now, it has become increasingly brittle. Also,
the need for package information for Fields and Methods would
have required a new field in each ast.Object. Rather than making
them bigger and the code even more subtle, in this CL we are moving
away from ast.Objects.

The types packge now defines its own objects for different
language entities (Const, Var, TypeName, Func), and they
implement the types.Object interface. Imported packages
create a Package object which holds the exported entities
in a types.Scope of types.Objects.

For type-checking, the current package is still using ast.Objects
to make this transition manageable. In a next step, the type-
checker will also use types.Objects instead, which opens the door
door to resolving ASTs entirely by the type checker. As a result,
the AST and type checker become less entangled, and ASTs can be
manipulated "by hand" or programmatically w/o having to worry
about scope and object invariants that are very hard to maintain.

(As a consequence, a future parser can do less work, and a
future AST will not need to define objects and scopes anymore.
Also, object resolution which is now split across the parser,
the ast, (ast.NewPackage), and even the type checker (for composite
literal keys) can be done in a single place which will be simpler
and more efficient.)

Change details:
- Check now takes a []*ast.File instead of a map[string]*ast.File.
It's easier to handle (I deleted code at all use sites) and does
not suffer from undefined order (which is a pain for testing).
- ast.Object.Data is now a *types.Package rather then an *ast.Scope
if the object is a package (obj.Kind == ast.Pkg). Eventually this
will go away altogether.
- Instead of an ast.Importer, Check now uses a types.Importer
(which returns a *types.Package).
- types.NamedType has two object fields (Obj Object and obj *ast.Object);
eventually there will be only Obj. The *ast.Object is needed during
this transition since a NamedType may refer to either an imported
(using types.Object) or locally defined (using *ast.Object) type.
- ast.NewPackage is not used anymore - there's a local copy for
package-level resolution of imports.
- struct fields now take the package origin into account.
- The GcImporter is now returning a *types.Package. It cannot be
used with ast.NewPackage anymore. If that functionality is still
used, a copy of the old GcImporter should be made locally (note
that GcImporter was part of exp/types and it's API was not frozen).
- dot-imports are not handled for the time being (this will come back).

R=adonovan
CC=golang-dev
https://golang.org/cl/7058060
2013-01-11 13:53:38 -08:00
Gwenael Treguier
7f0449a108 database/sql: check NumInput on Stmt.Exec
Fixes #3678.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6460087
2013-01-11 13:28:33 -08:00
Brad Fitzpatrick
bef4cb475c net/http: buffer before chunking
This introduces a buffer between writing from a handler and
writing chunks.  Further, it delays writing the header until
the first full chunk is ready.  In the case where the first
full chunk is also the final chunk (for small responses), that
means we can also compute a Content-Length, which is a nice
side effect for certain benchmarks.

Fixes #2357

R=golang-dev, dave, minux.ma, rsc, adg, balasanjay
CC=golang-dev
https://golang.org/cl/6964043
2013-01-11 10:03:43 -08:00
Georg Reinke
98259b9211 os: use syscall.Pipe2 on Linux
Update #2656

R=golang-dev, iant, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7065063
2013-01-11 08:30:25 -08:00
Stéphane Travostino
53e342f648 bytes: fix UnreadByte failure after ReadBytes
Fixes #4583.

R=golang-dev, minux.ma, bradfitz, rsc, dave
CC=golang-dev
https://golang.org/cl/6976050
2013-01-11 17:02:21 +11:00
Rick Arnold
60abc6b577 encoding/json: improve performance of Unmarshal on primitive types
Skip most of the scanning and parsing logic for simple (non-object/array) JSON values.

benchmark                   old ns/op    new ns/op    delta
BenchmarkUnmarshalInt             948          436  -54.01%
BenchmarkUnmarshalUint            930          427  -54.09%
BenchmarkUnmarshalString         1407          715  -49.18%
BenchmarkUnmarshalFloat          1114          536  -51.89%
BenchmarkUnmarshalBool            759          266  -64.95%
BenchmarkUnmarshalStruct         8165         8181   +0.20%

No significant effects on the go1 benchmarks:

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    9647362752   9596196417   -0.53%
BenchmarkFannkuch11      5623613048   5518694872   -1.87%
BenchmarkGobDecode         32944041     33165434   +0.67%
BenchmarkGobEncode         21237482     21080554   -0.74%
BenchmarkGzip             750955920    749861980   -0.15%
BenchmarkGunzip           197369742    197886192   +0.26%
BenchmarkJSONEncode        79274091     78891137   -0.48%
BenchmarkJSONDecode       180257802    175280358   -2.76%
BenchmarkMandelbrot200      7396666      7388266   -0.11%
BenchmarkParse             11446460     11386550   -0.52%
BenchmarkRevcomp         1605152523   1599512029   -0.35%
BenchmarkTemplate         204538247    207765574   +1.58%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            23.30        23.14    0.99x
BenchmarkGobEncode            36.14        36.41    1.01x
BenchmarkGzip                 25.84        25.88    1.00x
BenchmarkGunzip               98.32        98.06    1.00x
BenchmarkJSONEncode           24.48        24.60    1.00x
BenchmarkJSONDecode           10.76        11.07    1.03x
BenchmarkParse                 5.06         5.09    1.01x
BenchmarkRevcomp             158.34       158.90    1.00x
BenchmarkTemplate              9.49         9.34    0.98x

Fixes #3949.

R=golang-dev, dave, bradfitz, timo
CC=golang-dev
https://golang.org/cl/7068043
2013-01-10 17:58:45 -08:00
Alex Brainman
810e439859 net: use windows ConnectEx to dial (when possible)
Update #2631.
Update #3097.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7061060
2013-01-11 12:42:09 +11:00
Georg Reinke
e32d1154ec syscall: implement Pipe2 on Linux and use it in ForkExec
Fixes #2656.

R=golang-dev, bradfitz, iant, minux.ma
CC=golang-dev
https://golang.org/cl/7062057
2013-01-10 17:04:55 -08:00
Rémy Oudompheng
6e981c181c runtime: work around 5c bug in GC code.
5c miscompiles *p++ = struct_literal.

R=dave, golang-dev
CC=golang-dev
https://golang.org/cl/7065069
2013-01-11 00:59:44 +01:00
Jan Ziak
9204eb4d3c runtime: interpret type information during garbage collection
R=rsc, dvyukov, remyoudompheng, dave, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6945069
2013-01-10 15:45:46 -05:00
Dmitriy Vyukov
7847f328cd runtime: faster segmented stacks
benchmark                      old ns/op    new ns/op    delta
BenchmarkStackGrowth                 665          548  -17.59%
BenchmarkStackGrowth-2               333          274  -17.72%
BenchmarkStackGrowth-4               224          168  -25.00%
BenchmarkStackGrowth-8               124           91  -26.21%
BenchmarkStackGrowth-16               82           70  -14.55%
BenchmarkStackGrowth-32               73           59  -19.49%

R=nigeltao, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7026044
2013-01-10 11:36:40 +04:00
Dmitriy Vyukov
f82db7d9e4 runtime: less aggressive per-thread stack segment caching
Introduce global stack segment cache and limit per-thread cache size.
This greatly reduces StackSys memory on workloads that create lots of threads.

benchmark                      old ns/op    new ns/op    delta
BenchmarkStackGrowth                 665          656   -1.35%
BenchmarkStackGrowth-2               333          328   -1.50%
BenchmarkStackGrowth-4               224          172  -23.21%
BenchmarkStackGrowth-8               124           91  -26.13%
BenchmarkStackGrowth-16               82           47  -41.94%
BenchmarkStackGrowth-32               73           40  -44.79%

BenchmarkStackGrowthDeep           97231        94391   -2.92%
BenchmarkStackGrowthDeep-2         47230        58562  +23.99%
BenchmarkStackGrowthDeep-4         24993        49356  +97.48%
BenchmarkStackGrowthDeep-8         15105        30072  +99.09%
BenchmarkStackGrowthDeep-16        10005        15623  +56.15%
BenchmarkStackGrowthDeep-32        12517        13069   +4.41%

TestStackMem#1,MB                  310          12       -96.13%
TestStackMem#2,MB                  296          14       -95.27%
TestStackMem#3,MB                  479          14       -97.08%

TestStackMem#1,sec                 3.22         2.26     -29.81%
TestStackMem#2,sec                 2.43         2.15     -11.52%
TestStackMem#3,sec                 2.50         2.38      -4.80%

R=sougou, no.smile.face, rsc
CC=golang-dev, msolomon
https://golang.org/cl/7029044
2013-01-10 09:57:06 +04:00
Robert Griesemer
ecb75486f8 container/list: avoid memory leaks
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7065067
2013-01-09 15:22:48 -08:00
Rémy Oudompheng
e0bf0374ca go/types: don't parse imported packages multiple times.
R=dave, golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7068044
2013-01-09 22:03:41 +01:00
Robert Griesemer
0141c92a53 go/printer, gofmt: don't print unneeded parentheses around parameter types
Fixes #4624.

R=rsc
CC=golang-dev
https://golang.org/cl/7058052
2013-01-09 11:32:16 -08:00
Robert Griesemer
82accf44bf go/parser: better error message for declaration error
Fixes #4616.

R=rsc
CC=golang-dev
https://golang.org/cl/7069049
2013-01-09 11:31:57 -08:00
Andrey Mirtchovski
be36ab339f utf8: fix typo.
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7063056
2013-01-09 11:07:13 -08:00
Brad Fitzpatrick
f38df4e879 net/http: don't buffer request writing if dest is already buffered
The old code made it impossible to implement a reverse proxy
with anything less than 4k write granularity to the backends.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7060059
2013-01-09 10:33:46 -08:00
Robert Griesemer
65cb1904c1 go/types: "inherit" type in constant declarations w/o initialization expressions (bug fix)
R=adonovan
CC=golang-dev
https://golang.org/cl/7060054
2013-01-08 15:03:30 -08:00
Brad Fitzpatrick
89a7c87e66 all: use io.ByteWriter now that it exists
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7079043
2013-01-08 12:15:19 -08:00
Alex Brainman
548e58781b net/http/cgi: make it work without REQUEST_URI environment variable
Fixes #4367.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7062052
2013-01-08 17:23:46 +11:00
Andrew Gerrand
60544b698e go/doc: recursively inspect selector expressions
Also adds a couple of simple tests for doc.Examples.

Fixes #4561.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7067048
2013-01-07 19:36:38 +11:00
Nigel Tao
30ff0636b7 image/jpeg: handle those (unusual) grayscale images whose sampling
ratio isn't 1x1.

Fixes #4259.

The test data was generated by
cjpeg -quality 50 -sample 2x2 video-005.gray.pgm > video-005.gray.q50.2x2.jpeg
cjpeg -quality 50 -sample 2x2 -progressive video-005.gray.pgm > video-005.gray.q50.2x2.progressive.jpeg

similarly to video-005.gray.q50.* from
http://code.google.com/p/go/source/detail?r=51f26e36ba98
the key difference being the "-sample 2x2".

R=rsc
CC=golang-dev
https://golang.org/cl/7069045
2013-01-07 16:16:11 +11:00
Andrew Gerrand
0f64a6ef8d os: document that Exit does not run deferred calls
Fixes #4101.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/7065048
2013-01-07 14:46:41 +11:00
Matthew Dempsky
2e24a737c5 bytes: Fix missing godoc punctuation.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7067047
2013-01-06 22:44:04 -05:00
Matthew Dempsky
8cf45909b5 bytes: Change Compare example to be consistent with sort.Search's.
R=rsc, adg
CC=golang-dev
https://golang.org/cl/7057049
2013-01-06 22:43:32 -05:00
Andrew Gerrand
a88bbbb771 go/doc: trim only first space or newline from example output comment
Fixes #4487.

R=rsc
CC=golang-dev
https://golang.org/cl/7057048
2013-01-07 13:42:25 +11:00
Andrew Wilkins
02370f6760 go/types: Set Signature.Recv for imported types
R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/7065046
2013-01-06 18:08:58 -08:00
Alex Brainman
20e976073d os: fix Open for empty root directories on windows
Fixes #4601.

R=golang-dev, rsc, bradfitz, kardianos
CC=golang-dev
https://golang.org/cl/7033046
2013-01-07 12:48:32 +11:00
Robin Eklind
f36a53cd5d cmd/gofmt, bufio, image: Consistency and error handling.
cmd/gofmt: Add error handling for ioutil.WriteFile.
bufio: Consistency, rename e to err.
image: Consistency, fix comment for asReader.

R=golang-dev, dave, minux.ma, adg
CC=golang-dev
https://golang.org/cl/7029056
2013-01-07 11:15:53 +11:00
Nigel Tao
c753404886 bytes: fix docs: s/array/slice/.
R=rsc, mdempsky, dave
CC=golang-dev
https://golang.org/cl/7028051
2013-01-07 10:48:06 +11:00
Matthew Dempsky
46811d27ce src: Use bytes.Equal instead of bytes.Compare where possible.
bytes.Equal is simpler to read and should also be faster because
of short-circuiting and assembly implementations.

Change generated automatically using:
  gofmt -r 'bytes.Compare(a, b) == 0 -> bytes.Equal(a, b)'
  gofmt -r 'bytes.Compare(a, b) != 0 -> !bytes.Equal(a, b)'

R=golang-dev, dave, adg, rsc
CC=golang-dev
https://golang.org/cl/7038051
2013-01-07 10:03:49 +11:00
Matthew Dempsky
56961274bb bytes: Examples recommending bytes.Compare(a, b) rel_op 0 to test a rel_op b.
R=golang-dev, minux.ma, rsc, adg
CC=golang-dev
https://golang.org/cl/7042045
2013-01-07 09:59:37 +11:00
Caleb Spare
396c957a32 encoding/json: documented that ,string applies only to string and numeric fields.
Fixes #4437.

R=golang-dev, adg
CC=golang-dev, rsc
https://golang.org/cl/7064045
2013-01-07 09:44:35 +11:00
Rémy Oudompheng
0f545d9ab2 go/types: less closure creations in gcimporter.
Closures are incredibly expensive on linux/arm due to
repetitive flush of instruction cache.

go test -short on ODROID-X:

Before:
ok      exp/gotype      17.091s
ok      go/types        2.225s

After:
ok      exp/gotype      7.193s
ok      go/types        1.143s

R=dave, minux.ma, rsc
CC=golang-dev, remy
https://golang.org/cl/7062045
2013-01-06 23:38:38 +01:00
Russ Cox
4e2aa9bff0 cmd/ld: use native-endian symbol values in symbol table
The Plan 9 symbol table format defines big-endian symbol values
for portability, but we want to be able to generate an ELF object file
and let the host linker link it, as part of the solution to issue 4069.
The symbol table itself, since it is loaded into memory at run time,
must be filled in by the final host linker, using relocation directives
to set the symbol values. On a little-endian machine, the linker will
only fill in little-endian values during relocation, so we are forced
to use little-endian symbol values.

To preserve most of the original portability of the symbol table
format, we make the table itself say whether it uses big- or
little-endian values. If the table begins with the magic sequence
        fe ff ff ff 00 00
then the actual table begins after those six bytes and contains
little-endian symbol values. Otherwise, the table is in the original
format and contains big-endian symbol values. The magic sequence
looks like an "end of table" entry (the fifth byte is zero), so legacy
readers will see a little-endian table as an empty table.

All the gc architectures are little-endian today, so the practical
effect of this CL is to make all the generated tables little-endian,
but if a big-endian system comes along, ld will not generate
the magic sequence, and the various readers will fall back to the
original big-endian interpretation.

R=ken2
CC=golang-dev
https://golang.org/cl/7066043
2013-01-04 17:03:57 -05:00
Ian Lance Taylor
63bee953a2 runtime: always incorporate hash seed at start of hash computation
Otherwise we can get predictable collisions.

R=golang-dev, dave, patrick, rsc
CC=golang-dev
https://golang.org/cl/7051043
2013-01-04 07:53:42 -08:00
John Graham-Cumming
c09649890f log/syslog: remove RFC5424 version number for greater compatibility
RFC5424 specifies a version number (currently 1) after the facility and
severity in a syslog message (e.g. <7>1 TIMESTAMP ...).  This causes
rsyslog to fail to parse syslog message because the rest of the message
is not fully compliant with RFC5424.

For the widest compatibility, drop the version (messages are in the
RFC3164 BSD syslog format (e.g. <7>TIMESTAMP ...). Have tested this with
syslog-ng, rsyslog and syslogd.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7036050
2013-01-04 10:21:43 -05:00
Jan Ziak
89ec208ee8 runtime: introduce typedefs and delete struct keywords in mgc0.c
R=rsc
CC=golang-dev
https://golang.org/cl/7029055
2013-01-04 10:20:50 -05:00
Matthew Dempsky
98edf09e67 net/http: Sync TimeoutHandler godoc with code.
TimeoutHandler was changed from "ns int64" to "dt time.Duration" on
Nov 30, 2011, but the godoc still refers to "ns".

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7031050
2013-01-03 10:06:04 -08:00
Dave Cheney
14b654369d go/types: add more logging to gc import test
* Extended deadline to 30 seconds
* Added logging of the duration of each package import
* Fail the test immediately if directories cannot be read

R=gri, minux.ma
CC=golang-dev
https://golang.org/cl/7030055
2013-01-03 16:30:25 +11:00
Nigel Tao
699b99fa75 net: fix docs for type IP: s/array/slice/.
R=rsc
CC=golang-dev
https://golang.org/cl/6930047
2013-01-03 14:25:13 +11:00
Brad Fitzpatrick
5e8ca201d1 net/http: make NewRequest pick a ContentLength from a *bytes.Reader too
It already did so for its sibling, *strings.Reader, as well as *bytes.Buffer.

R=edsrzf, dave, adg, kevlar, remyoudompheng, adg, rsc
CC=golang-dev
https://golang.org/cl/7031045
2013-01-02 14:40:27 -08:00
Thomas Kappler
cdec0850f8 encoding/json: don't panic marshaling anonymous non-struct field
Add a check for this case and don't try to follow the anonymous
type's non-existent fields.

Fixes #4474.

R=rsc
CC=golang-dev
https://golang.org/cl/6945065
2013-01-02 17:39:41 -05:00
Rick Arnold
948f0b7a0b net/http: document Request.URL
Request.URL had no documentation before and some people were expecting all fields to be populated.

Fixes #3805.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7008046
2013-01-02 17:37:27 -05:00
Russ Cox
64a0017d6e sync/atomic: document that users must deal with 64-bit alignment
Update #599.

R=dvyukov, iant, minux.ma
CC=golang-dev
https://golang.org/cl/7001056
2013-01-02 15:44:00 -05:00
Robert Griesemer
a846d479b3 go/types: remove most remaining uses of ast.Object from exported API
Also: Return first error whether an error handler is set in the
      context or not (bug fix).

R=adonovan
CC=golang-dev
https://golang.org/cl/7024043
2013-01-02 09:27:33 -08:00
Dave Cheney
c2d2bfcc49 runtime: fix freebsd/arm instruction cache flush
sysarch requires arguments to be passed on the stack, not in registers.

Credit to Shenghou Ma (minux) for the fix.

R=minux.ma, devon.odell
CC=golang-dev
https://golang.org/cl/7037043
2013-01-01 21:47:42 +11:00
Dave Cheney
52dc13b5f3 go/build: disable cgo on freebsd/arm
Under FreeBSD-CURRENT on arm, cgo enabled binaries segfault. Disable cgo support for the moment so we can have a freebsd/arm builder on the dashboard.

R=minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/7031044
2013-01-01 21:46:18 +11:00
Ryan Slade
a4600126d9 encoding/json: encode map key is of string kind, decode only of string type
Allows encoding and decoding of maps with key of string kind, not just string type.
Fixes #3519.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/6943047
2012-12-30 15:40:42 +11:00
Russ Cox
a22389ec38 runtime: say 'fatal error' instead of 'throw'
Fixes #4597.

R=ken2
CC=golang-dev
https://golang.org/cl/7032043
2012-12-29 21:48:25 -05:00
Sébastien Paolacci
e786829e83 runtime: handle locked mmap failure on Linux
Used to then die on a nil pointer situation. Most Linux standard setups are rather
restrictive regarding the default amount of lockable memory.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6997049
2012-12-29 14:34:06 -05:00
Adam Langley
975bf6d323 crypto/rsa: ensure that RSA keys use the full number of bits.
While half of all numbers don't have their most-significant bit set,
this is becoming increasingly impermissible for RSA moduli. In an
attempt to exclude weak keys, several bits of software either do, or
will, enforce that RSA moduli are >= 1024-bits.

However, Go often generates 1023-bit RSA moduli which this software
would then reject.

This change causes crypto/rsa to regenerate the primes in the event
that the result is shorter than requested.

It also alters crypto/rand in order to remove the performance impact
of this:

The most important change to crypto/rand is that it will now set the
top two bits in a generated prime (OpenSSL does the same thing).
Multiplying two n/2 bit numbers, where each have the top two bits set,
will always result in an n-bit product. (The effectively makes the
crypto/rsa change moot, but that seems too fragile to depend on.)

Also this change adds code to crypto/rand to rapidly eliminate some
obviously composite numbers and reduce the number of Miller-Rabin
tests needed to generate a prime.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7002050
2012-12-28 19:11:37 -05:00
Robert Griesemer
c8eb71b057 go/types: Steps towards removing ast.Object from exported API.
- introduced type Method for methods
- renamed StructField -> Field
- removed ObjList
- methods are not sorted anymore in interfaces (for now)

R=adonovan
CC=golang-dev
https://golang.org/cl/7023043
2012-12-28 14:30:36 -08:00
Robert Griesemer
73aaa44c24 go/types: moved from exp/types
This is a just a file move with no other changes
besides the manual import path adjustments in these
two files:

src/pkg/exp/gotype/gotype.go
src/pkg/exp/gotype/gotype_test.go

Note: The go/types API continues to be subject to
possibly significant changes until Go 1.1. Do not
rely on it being stable at this point.

R=adonovan
CC=golang-dev
https://golang.org/cl/7013049
2012-12-28 11:41:44 -08:00
Robert Griesemer
d0428379e7 exp/types: resolve composite literal keys
The parser/resolver cannot accurately resolve
composite literal keys that are identifiers;
it needs type information.
Instead, try to resolve them but leave final
judgement to the type checker.

R=adonovan
CC=golang-dev
https://golang.org/cl/6994047
2012-12-28 10:40:36 -08:00
Brad Fitzpatrick
eb43ce2d77 io/ioutil: fix Discard data race
Fixes #4589

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/7011047
2012-12-28 09:33:22 -08:00
Dmitriy Vyukov
91484c6c48 runtime: fix potential crash in sigqueue
Fixes #4383.

R=golang-dev, minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/6996060
2012-12-28 15:36:06 +04:00
Dave Cheney
7c4183ac24 net: consolidate fd_{free,net,open}bsd.go into fd_bsd.go
These files are identical, so probably pre date // +build.

With a little work, fd_darwin could be merged as well.

R=mikioh.mikioh, jsing, devon.odell, lucio.dere, minux.ma
CC=golang-dev
https://golang.org/cl/7004053
2012-12-28 21:01:52 +11:00
Jan Ziak
90f9beca15 reflect: declare slice as *[]unsafe.Pointer instead of *[]byte
The new garbage collector (CL 6114046) may find the fake *[]byte value
and interpret its contents as bytes rather than as potential pointers.
This may lead the garbage collector to free memory blocks that
shouldn't be freed.

R=dvyukov, rsc, dave, minux.ma, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/7000059
2012-12-28 02:35:04 +08:00
Akshat Kumar
5bcb9707b6 log/syslog: add stub for Plan 9
Proper local system log semantics still need to be
created for Plan 9. In the meantime, the test suite
(viz., exp/gotype) expects there to be some Go
source for each import path. Thus, here is a stub,
equivalent to syslog_windows, for this purpose.

R=golang-dev, rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/7000062
2012-12-27 11:45:03 +11:00
Robert Griesemer
3e8304b377 exp/types: some comment fixes
R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/7018046
2012-12-26 14:04:50 -08:00
Robert Griesemer
888111e081 exp/types: configurable types.Check API
- added Context type for configuration of type checker
- type check all function and method bodies
- (partial) fixes to shift hinting (still not complete)
- revamped test harness - does not rely on specific position
  representation anymore, just a standard (compiler) error
  message
- lots of bug fixes

R=adonovan, rsc
CC=golang-dev
https://golang.org/cl/6948071
2012-12-26 12:48:26 -08:00
Oling Cat
f296adf819 fmt: update an old comment; fix a typo.
R=golang-dev, iant
CC=golang-dev, minux.ma
https://golang.org/cl/6998055
2012-12-25 14:54:24 -08:00
Dmitriy Vyukov
4380fa6d99 runtime: diagnose double wakeup on Note
Double wakeup is prohibited by the Note interface
and checked in lock_sema.c.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6976054
2012-12-24 21:06:57 +04:00
Marcel van Lohuizen
cfcc3ebfa4 exp/norm: changed API of Iter.
Motivations:
 - Simpler UI. Previous API proved a bit awkward for practical purposes.
 - Iter is often used in cases where one want to be able to bail out early.
   The old implementaton had too much look-ahead to be efficient.
Disadvantages:
 - ASCII performance is bad. This is unavoidable for tiny iterations.
   Example is included to show how to work around this.

Description:
Iter now iterates per boundary/segment. It returns a slice of bytes that
either points to the input bytes, the internal decomposition strings,
or the small internal buffer that each iterator has. In many cases, copying
bytes is avoided.
The method Seek was added to support jumping around the input without
having to reinitialize.

Details:
 - Table adjustments: some decompositions exist of multiple segments.
   Decompositions that are of this type are now marked so that Iter can
   handle them separately.
 - The old iterator had a different next function for different normal forms
   that was assigned to a function pointer called by Next.
   The new iterator uses this mechanism to switch between different modes
   for handling different type of input as well.  This greatly improves
   performance for Hangul and ASCII. It is also used for multi-segment
   decompositions.
 - input is now a struct of sting and []byte, instead of an interface.
   This simplifies optimizing the ASCII case.

R=rsc
CC=golang-dev
https://golang.org/cl/6873072
2012-12-24 16:53:25 +01:00
Marcel van Lohuizen
9aa70984a9 exp/locale/collate: include composed characters into the table. This eliminates
the need to decompose characters for the majority of cases.  This considerably
speeds up collation while increasing the table size minimally.

To detect non-normalized strings, rather than relying on exp/norm, the table
now includes CCC information. The inclusion of this information does not
increase table size.

DETAILS
 - Raw collation elements are now a struct that includes the CCC, rather
   than a slice of ints.
 - Builder now ensures that NFD and NFC counterparts are included in the table.
   This also fixes a bug for Korean which is responsible for most of the growth
   of the table size.
 - As there is no more normalization step, code should now handle both strings
   and byte slices as input. Introduced source type to facilitate this.

NOTES
 - This change does not handle normalization correctly entirely for contractions.
   This causes a few failures with the regtest. table_test.go contains a few
   uncommented tests that can be enabled once this is fixed.  The easiest is to
   fix this once we have the new norm.Iter.
 - Removed a test cases in table_test that covers cases that are now guaranteed
   to not exist.

R=rsc, mpvl
CC=golang-dev
https://golang.org/cl/6971044
2012-12-24 16:42:29 +01:00
Dmitriy Vyukov
43f2fc308b runtime/race: make test driver print compilation errors
Currently it silently "succeeds" saying that it run 0 tests
if there are compilations errors.
With this change it fails and outputs the compilation error.

R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/7002058
2012-12-24 15:33:32 +04:00
Rémy Oudompheng
ecbf99ad97 cmd/gc: fix race instrumentation of unaddressable arrays.
Fixes #4578.

R=dvyukov, golang-dev
CC=golang-dev
https://golang.org/cl/7005050
2012-12-24 12:14:41 +01:00
Brad Fitzpatrick
82ae6434b3 net/http: match curl and others' NO_PROXY wildcard handling
NO_PROXY="example.com" should match "foo.example.com", just
the same as NO_PROXY=".example.com".  This is what curl and
Python do.

Fixes #4574

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7005049
2012-12-22 17:41:00 -08:00
Russ Cox
403f012534 runtime: zero d.free field
Not programming in Go anymore:
have to clear fields in local variables.

R=ken2
CC=golang-dev
https://golang.org/cl/7002053
2012-12-22 18:23:26 -05:00
Russ Cox
e49a183b76 runtime/debug: document that Stack is deprecated
Fixes #4070.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7004050
2012-12-22 17:23:50 -05:00
Russ Cox
ec59b840f9 runtime: coalesce 0-size allocations
Fixes #3996.

R=ken2
CC=golang-dev
https://golang.org/cl/7001052
2012-12-22 16:42:22 -05:00
Russ Cox
295a4d8e64 runtime: ignore failure from madvise
When we release memory to the OS, if the OS doesn't want us
to release it (for example, because the program executed
mlockall(MCL_FUTURE)), madvise will fail. Ignore the failure
instead of crashing.

Fixes #3435.

R=ken2
CC=golang-dev
https://golang.org/cl/6998052
2012-12-22 15:06:28 -05:00
Russ Cox
0de71619ce runtime: aggregate defer allocations
benchmark             old ns/op    new ns/op    delta
BenchmarkDefer              165          113  -31.52%
BenchmarkDefer10            155          103  -33.55%
BenchmarkDeferMany          216          158  -26.85%

benchmark            old allocs   new allocs    delta
BenchmarkDefer                1            0  -100.00%
BenchmarkDefer10              1            0  -100.00%
BenchmarkDeferMany            1            0  -100.00%

benchmark             old bytes    new bytes    delta
BenchmarkDefer               64            0  -100.00%
BenchmarkDefer10             64            0  -100.00%
BenchmarkDeferMany           64           66    3.12%

Fixes #2364.

R=ken2
CC=golang-dev
https://golang.org/cl/7001051
2012-12-22 14:54:39 -05:00
Emil Hessman
4b7c2dfcea testing: fix example test fd leak
Close the read side of the pipe.
Fixes #4551.

R=rsc
CC=golang-dev
https://golang.org/cl/6962049
2012-12-22 13:41:01 -05:00
Stéphane Travostino
475f3df43f encoding/json: A JSON tag can be any valid JSON string.
Fixes #3887.

R=golang-dev, daniel.morsing, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6997045
2012-12-22 13:36:55 -05:00
Russ Cox
1cad1f8d1c fmt: document width and flags a bit more
Fixes #4581.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7000052
2012-12-22 13:36:39 -05:00
Rick Arnold
a6d986bd8a flag: add implicit boolFlag interface
Any flag.Value that has an IsBoolFlag method that returns true
will be treated as a bool flag type during parsing.

Fixes #4262.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6944064
2012-12-22 13:34:48 -05:00
Erik St. Martin
54b7ccd514 regexp: fix index panic in Replace
When using subexpressions ($1) as replacements, when they either don't exist or values weren't found causes a panic.
This patch ensures that the match location isn't -1, to prevent out of bounds errors.
Fixes #3816.

R=franciscossouza, rsc
CC=golang-dev
https://golang.org/cl/6931049
2012-12-22 11:14:56 -05:00
Adam Langley
8f1d170fc6 crypto/des: add an example to demonstrate EDE2 operation.
EDE2 is a rare DES mode that can be implemented with crypto/des, but
it's somewhat non-obvious so this CL adds an example of doing so.

Fixes #3537.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6721056
2012-12-22 10:50:11 -05:00
Russ Cox
d324c4af87 encoding/gob: document that structs only encode/decode exported fields
Fixes #4579.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7000051
2012-12-22 10:43:47 -05:00
Chris Jones
a9121a19f0 encoding/xml: Marshal ",any" fields
Fixes #3559.

This makes Marshal handle fields marked ",any" instead of ignoring
them. That makes Marshal more symmetrical with Unmarshal, which seems
to have been a design goal.

Note some test cases were changed, because this patch changes
marshalling behavior. I think the previous behavior was buggy, but
there's still a backward-compatibility question to consider.

R=rsc
CC=golang-dev, n13m3y3r
https://golang.org/cl/6938068
2012-12-22 10:00:36 -05:00
Mikio Hara
9622f5032e net: fix timeout tests
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7003049
2012-12-22 14:56:02 +09:00
Robert Griesemer
4f79cef7f2 go/ast: ast.DeclStmt.Decl must be an *ast.GenDecl node (documentation)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6996046
2012-12-21 11:52:21 -08:00
Dmitriy Vyukov
080d31cc50 runtime/race: update linux runtime to r170876.
This disables checks for limited address space
and unlimited stack. They are not required for Go.
Fixes #4577.

R=golang-dev, iant
CC=golang-dev, kamil.kisiel, minux.ma
https://golang.org/cl/7003045
2012-12-21 19:12:00 +04:00
Mikio Hara
ebcaf081a7 net: make unix connection tests more robust
Avoids unlink the underlying file before the socket close.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7004044
2012-12-21 14:19:33 +09:00
Alex Brainman
9ad0348403 os: remove dead code
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6944066
2012-12-21 16:02:39 +11:00
Dave Cheney
c850d0f34a net/http: simplify serve() connection close
Followup to 6971049.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6970049
2012-12-21 15:14:38 +11:00
Andrew Gerrand
ff27cdb625 go/doc: don't synthesize code for examples that are not self-contained
Fixes #4309.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6974045
2012-12-21 07:06:38 +11:00
Russ Cox
a3677b5f22 math: handle exponent separately in Log2
This guarantees that powers of two return exact answers.

We could do a multiprecision approximation for the
rest of the answer too, but this seems like it should be
good enough.

Fixes #4567.

R=golang-dev, iant, remyoudompheng
CC=golang-dev
https://golang.org/cl/6943074
2012-12-20 12:23:27 -05:00
Joel Sing
708db79011 cgo: enable cgo on openbsd
Enable cgo on OpenBSD.

The OpenBSD ld.so(1) does not currently support PT_TLS sections. Work
around this by fixing up the TCB that has been provided by librthread
and reallocating a TCB with additional space for TLS. Also provide a
wrapper for pthread_create, allowing zeroed TLS to be allocated for
threads created externally to Go.

Joint work with Shenghou Ma (minux).

Requires change 6846064.

Fixes #3205.

R=golang-dev, minux.ma, iant, rsc, iant
CC=golang-dev
https://golang.org/cl/6853059
2012-12-21 01:43:19 +11:00
Joakim Sernbrant
d0283ab62a net/http: only call client SetCookie when needed
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6968049
2012-12-19 16:24:38 -08:00
Andrew Gerrand
ff5d47ebba testing: only capture stdout when running examples
Fixes #4550.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6973048
2012-12-20 10:48:33 +11:00
Brad Fitzpatrick
91934ff5d8 net/http: fix server connection leak on Handler's panic(nil)
If a handler did a panic(nil), the connection was never closed.

Fixes #4050

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6971049
2012-12-19 15:39:19 -08:00
Dave Cheney
07e706f8ce go/token: fix data race on FileSet.last
Fixes #4345.

Benchmarks are promising,

benchmark         old ns/op    new ns/op    delta
BenchmarkPrint     14716391     14747131   +0.21%

benchmark         old ns/op    new ns/op    delta
BenchmarkParse      8846219      8809343   -0.42%

benchmark          old MB/s     new MB/s  speedup
BenchmarkParse         6.61         6.64    1.00x

Also includes additional tests to improve token.FileSet coverage.

R=dvyukov, gri
CC=golang-dev
https://golang.org/cl/6968044
2012-12-20 08:26:24 +11:00
Dave Cheney
4e406a2372 go/token: add test for concurrent use of FileSet.Pos
Update #4354.

Add a test to expose the race in the FileSet position cache.

R=dvyukov, gri
CC=fullung, golang-dev
https://golang.org/cl/6940078
2012-12-18 16:38:00 -08:00
Shenghou Ma
d1ef9b56fb all: fix typos
caught by https://github.com/lyda/misspell-check.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/6949072
2012-12-19 03:04:09 +08:00
Jingcheng Zhang
70e967b7bc runtime: use "mp" and "gp" instead of "m" and "g" for local variable name to avoid confusion with the global "m" and "g".
R=golang-dev, minux.ma, rsc
CC=bradfitz, golang-dev
https://golang.org/cl/6939064
2012-12-19 00:30:29 +08:00
Shenghou Ma
7777bac6e4 runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.

Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          110          118   +7.27%

Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          625          542  -13.28%

Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          992          909   -8.37%

FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          699          695   -0.57%

FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow         1553         1658   +6.76%

OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow         1262         1236   -2.06%

OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow         5089         5043   -0.90%

NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          277          278   +0.36%

NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          103          105   +1.94%

Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.

R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 22:57:25 +08:00
David Symonds
5b46fc417f go/doc: add "hdr-" prefix to headers generated from package overviews.
R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/6935071
2012-12-18 12:19:04 +11:00
Robert Griesemer
acbf011d96 exp/gotype: disable failing tests and add a few more
R=rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/6948066
2012-12-17 14:32:46 -08:00
Dave Cheney
7e9d9eb17b debug/elf: handle missing shstrndx in core files
Fixes #4481.

hello-world-core.gz was generated with a simple hello world c program and core dumped as suggested in the issue.

Also: add support for gz compressed test fixtures.

R=minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/6936058
2012-12-18 07:58:22 +11:00
Dave Cheney
2d3bdab0d6 time: fix panic with time.Parse(time.StampNano, ... )
Fixes #4502.

R=rsc
CC=golang-dev
https://golang.org/cl/6949058
2012-12-18 07:52:23 +11:00
Brad Fitzpatrick
7c3577e48f net/http: fix goroutine leak in error case
Fixes #4531

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6937069
2012-12-17 12:01:00 -08:00
Robert Griesemer
50d8787822 exp/types: completed typechecking of parameter passing
Details:
- fixed variadic parameter passing and calls of the form f(g())
- fixed implementation of ^x for unsigned constants x
- fixed assignability of untyped booleans
- resolved a few TODOs, various minor fixes
- enabled many more tests (only 6 std packages don't typecheck)

R=rsc
CC=golang-dev
https://golang.org/cl/6930053
2012-12-17 11:35:59 -08:00
Shenghou Ma
5a2c275be1 fmt, encoding/gob: fix misuse of Read
reader.Read() can return both 0,nil and len(buf),err.
To be safe, we use io.ReadFull instead of doing reader.Read directly.

Fixes #3472.

R=bradfitz, rsc, ality
CC=golang-dev
https://golang.org/cl/6285050
2012-12-18 01:26:48 +08:00
Anthony Martin
2ad6714793 syscall: lazily populate the environment cache on Plan 9
This decreases the amount of system calls during the
first call to Getenv. Calling Environ will still read
in all environment variables and populate the cache.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6939048
2012-12-17 08:33:51 -08:00
Anthony Martin
432f18221f runtime: implement getenv for Plan 9
With this change the runtime can now read GOMAXPROCS, GOGC, etc.

I'm not quite sure how we missed this.

R=seed, lucio.dere, rsc
CC=golang-dev
https://golang.org/cl/6935062
2012-12-17 11:07:40 -05:00
Rick Arnold
bcb495b39a net/smtp: remove data race from TestSendMail.
A data race was found in TestSendMail by the race detector.

Fixes #4559.

R=golang-dev, bradfitz, dave, rsc
CC=golang-dev
https://golang.org/cl/6944057
2012-12-17 10:45:33 -05:00
Shenghou Ma
57ae2e7371 os: fix docs for Expand
there is no concept of “undefined” variables for Expand。

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6946063
2012-12-17 23:37:02 +08:00
Shenghou Ma
a89aaad195 net/http/pprof: fix doc for /debug/pprof/
Fixes #4548.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6944053
2012-12-17 23:32:08 +08:00
Christopher Nielsen
39835b4aa0 syscall: document that documentation is platform specific
Fixes #4051

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6943063
2012-12-17 22:50:00 +08:00
Dmitriy Vyukov
ca4b868e9a cmd/gc: racewalk: fix compiler crash
The code:
func main() {
        v := make([]int64, 10)
        i := 1
        _ = v[(i*4)/3]
}
crashes compiler with:

Program received signal SIGSEGV, Segmentation fault.
0x000000000043c274 in walkexpr (np=0x7fffffffc9b8, init=0x0) at src/cmd/gc/walk.c:587
587			*init = concat(*init, n->ninit);
(gdb) bt
#0  0x000000000043c274 in walkexpr (np=0x7fffffffc9b8, init=0x0) at src/cmd/gc/walk.c:587
#1  0x0000000000432d15 in copyexpr (n=0x7ffff7f69a48, t=<optimized out>, init=0x0) at src/cmd/gc/subr.c:2020
#2  0x000000000043f281 in walkdiv (init=0x0, np=0x7fffffffca70) at src/cmd/gc/walk.c:2901
#3  walkexpr (np=0x7ffff7f69760, init=0x0) at src/cmd/gc/walk.c:956
#4  0x000000000043d801 in walkexpr (np=0x7ffff7f69bc0, init=0x0) at src/cmd/gc/walk.c:988
#5  0x000000000043cc9b in walkexpr (np=0x7ffff7f69d38, init=0x0) at src/cmd/gc/walk.c:1068
#6  0x000000000043c50b in walkexpr (np=0x7ffff7f69f50, init=0x0) at src/cmd/gc/walk.c:879
#7  0x000000000043c50b in walkexpr (np=0x7ffff7f6a0c8, init=0x0) at src/cmd/gc/walk.c:879
#8  0x0000000000440a53 in walkexprlist (l=0x7ffff7f6a0c8, init=0x0) at src/cmd/gc/walk.c:357
#9  0x000000000043d0bf in walkexpr (np=0x7fffffffd318, init=0x0) at src/cmd/gc/walk.c:566
#10 0x00000000004402bf in vmkcall (fn=<optimized out>, t=0x0, init=0x0, va=0x7fffffffd368) at src/cmd/gc/walk.c:2275
#11 0x000000000044059a in mkcall (name=<optimized out>, t=0x0, init=0x0) at src/cmd/gc/walk.c:2287
#12 0x000000000042862b in callinstr (np=0x7fffffffd4c8, init=0x7fffffffd568, wr=0, skip=<optimized out>) at src/cmd/gc/racewalk.c:478
#13 0x00000000004288b7 in racewalknode (np=0x7ffff7f68108, init=0x7fffffffd568, wr=0, skip=0) at src/cmd/gc/racewalk.c:287
#14 0x0000000000428781 in racewalknode (np=0x7ffff7f65840, init=0x7fffffffd568, wr=0, skip=0) at src/cmd/gc/racewalk.c:302
#15 0x0000000000428abd in racewalklist (l=0x7ffff7f65840, init=0x0) at src/cmd/gc/racewalk.c:97
#16 0x0000000000428d0b in racewalk (fn=0x7ffff7f5f010) at src/cmd/gc/racewalk.c:63
#17 0x0000000000402b9c in compile (fn=0x7ffff7f5f010) at src/cmd/6g/../gc/pgen.c:67
#18 0x0000000000419f86 in funccompile (n=0x7ffff7f5f010, isclosure=0) at src/cmd/gc/dcl.c:1414
#19 0x0000000000424161 in p9main (argc=<optimized out>, argv=<optimized out>) at src/cmd/gc/lex.c:431
#20 0x0000000000401739 in main (argc=<optimized out>, argv=<optimized out>) at src/lib9/main.c:35

The problem is nil init passed to mkcall().

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6940045
2012-12-17 12:55:41 +04:00
Oling Cat
6dd7da8566 fmt: fix a typo
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6937065
2012-12-17 18:13:12 +11:00
Rémy Oudompheng
8c86f1f331 encoding/json: cleanup leftover redundant variables.
Those variables come from ancient times when reflect.Value was
an interface.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/6946059
2012-12-17 02:34:49 +01:00
Rick Arnold
475dee9082 net/smtp: add optional Hello method
Add a Hello method that allows clients to set the server sent in the EHLO/HELO exchange; the default remains localhost.
Based on CL 5555045 by rsc.

Fixes #4219.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6946057
2012-12-16 20:19:35 -05:00
Jan Ziak
013fa63c90 runtime: struct Obj in mgc0.c and buffers in scanblock()
Details:

- This CL is the conceptual skeleton of code found in CL 6114046

- The garbage collector uses struct Obj to specify memory blocks

- scanblock() is putting found memory blocks into an intermediate buffer
  (xbuf) before adding/flushing them to the main work buffer (wbuf)

- The main loop in scanblock() is replaced with a skeleton code that
  in the future will be able to recognize the type of objects and
  thus will improve the garbage collector's precision.
  For now, all objects are simply sequences of pointers so
  the precision of the garbage collector remains unchanged.

- The code plugs .gcdata and .gcbss sections into the garbage collector.
  scanblock() in this CL is unable to make any use of this.

R=rsc, dvyukov, remyoudompheng
CC=dave, golang-dev, minux.ma
https://golang.org/cl/6856121
2012-12-16 19:32:12 -05:00
Mikio Hara
0d197251ee net: change ListenUnixgram signature to return UnixConn instead of UDPConn
This CL breaks Go 1 API compatibility but it doesn't matter because
previous ListenUnixgram doesn't work in any use cases, oops.

The public API change is:
-pkg net, func ListenUnixgram(string, *UnixAddr) (*UDPConn, error)
+pkg net, func ListenUnixgram(string, *UnixAddr) (*UnixConn, error)

Fixes #3875.

R=rsc, golang-dev, dave
CC=golang-dev
https://golang.org/cl/6937059
2012-12-16 11:51:47 +09:00
Mikio Hara
78cee46f3a src: gofmt -w -s
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6935059
2012-12-15 14:19:51 +09:00
Jingcheng Zhang
0b50a5dad7 builtin: correct comment on builtin function delete().
Delete on a nil map is now a no-op.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6938054
2012-12-14 09:13:42 -08:00
James David Chalfant
19e2f26b21 database/sql: adds test for fix in issue 4433.
Tests that here should be automatic retries if a database
driver's connection returns ErrBadConn on Begin. See
"TestTxErrBadConn" in sql_test.go

R=golang-dev
CC=golang-dev
https://golang.org/cl/6942050
2012-12-14 09:00:33 -08:00
Dmitriy Vyukov
10b3e310e2 runtime/race: update runtime to r170112.
This includes GORACE history_size and log_path flags.

This change is actually an addition to:
https://golang.org/cl/6947046

race_linux_amd64.syso somehow fall out of it.

R=minux.ma
CC=golang-dev
https://golang.org/cl/6946051
2012-12-14 13:40:59 +04:00
Dmitriy Vyukov
a719700e89 runtime/race: update runtime to r170112.
This includes GORACE history_size and log_path flags.

R=golang-dev, bradfitz, rsc, remyoudompheng, minux.ma
CC=golang-dev
https://golang.org/cl/6947046
2012-12-14 13:23:43 +04:00
Nick Craig-Wood
473441fc30 os: Improve the accuracy of os.Chtimes
I've been writing some code which involves syncing files (like
rsync) and it became apparent that under Linux I could read
modification times (os.Lstat) with nanosecond precision but
only write them with microsecond precision.  This difference
in precision is rather annoying when trying to discover
whether files need syncing or not!

I've patched syscall and os to increases the accuracy of of
os.Chtimes for Linux and Windows.  This involved exposing the
utimensat system call under Linux and a bit of extra code
under Windows.  I decided not to expose the "at" bit of the
system call as it is impossible to replicate under Windows, so
the patch adds syscall.Utimens() to all architectures along
with a ImplementsUtimens flag.

If the utimensat syscall isn't available (utimensat was added
to Linux in 2.6.22, Released, 8 July 2007) then it silently
falls back to the microsecond accuracy version it uses now.
The improved accuracy for Windows should be good for all
versions of Windows.

Unfortunately Darwin doesn't seem to have a utimensat system
call that I could find so I couldn't implement it there.  The
BSDs do, but since they share their syscall implementation
with Darwin I couldn't figure out how to define a syscall for
*BSD and not Darwin.  I've left this as a TODO in the code.

In the process I implemented the missing methods for Timespec
under Windows which I needed which just happened to round out
the Timespec API for all platforms!

------------------------------------------------------------

Test code: http://play.golang.org/p/1xnGuYOi4b

Linux Before (1000 ns precision)

$ ./utimetest.linux.before z
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 BST
Reading mtime 1344937903123457000: 2012-08-14 10:51:43.123457 +0100 BST

Linux After (1 ns precision)

$ ./utimetest.linux.after z
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 BST
Reading mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 BST

Windows Before (1000 ns precision)

X:\>utimetest.windows.before.exe c:\Test.txt
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 GMTDT
Reading mtime 1344937903123456000: 2012-08-14 10:51:43.123456 +0100 GMTDT

Windows After (100 ns precision)

X:\>utimetest.windows.after.exe c:\Test.txt
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 GMTDT
Reading mtime 1344937903123456700: 2012-08-14 10:51:43.1234567 +0100 GMTDT

R=golang-dev, alex.brainman, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6905057
2012-12-13 13:02:39 -08:00
Shenghou Ma
28a50c7f51 runtime: deletion on nil maps is a no-op now
Fixes #4535.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6942044
2012-12-13 23:48:48 +08:00
Shenghou Ma
31eedd7f3e io: SectionReader.ReadAt should return EOF when buf is not fully read
Fixes #4392.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6858062
2012-12-13 18:36:24 +08:00
Mikio Hara
feb509c794 net: make TestDialTimeoutFDLeak a bit robust
TestDialTimeoutFDLeak will fail when system state somaxconn is
greater than expected fixed value.

Fixes #4384 (again).

R=fullung, dave, rsc
CC=golang-dev
https://golang.org/cl/6873069
2012-12-13 16:21:25 +09:00
Albert Strasheim
b978995f5d runtime/race: fix test for GOMAXPROCS>1
Fixes #4530.

R=dvyukov, dave
CC=golang-dev
https://golang.org/cl/6933052
2012-12-13 10:14:32 +04:00
James David Chalfant
309eae1923 database/sql: Alter *DB.begin to return driver.ErrBadConn when driver.Conn.Begin returns driver.ErrBadConn
Fixes #4433

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6845094
2012-12-12 22:04:55 -08:00
Dave Cheney
ae12e96350 log/syslog: fix flakey test on slow hosts
Fixes #4467.

The syslog tests can fail if the timeout fires before the data arrives at the mock server. Moving the timeout onto the goroutine that is calling ReadFrom() and always processing the data returned before handling the error should improve the reliability of the test.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6920047
2012-12-13 16:26:20 +11:00
Brad Fitzpatrick
f85b94aa85 net/http: return nicer error when Client request Host is blank
Update #4271

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6931052
2012-12-12 12:23:01 -08:00
Brad Fitzpatrick
be5ce4e027 net/http: remove a stale cookie TODO comment, add a test
Fixes #4528

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6922054
2012-12-12 11:36:44 -08:00
Brad Fitzpatrick
08ce7f1d5c net/http: follow certain redirects after POST requests
Fixes #4145

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6923055
2012-12-12 11:09:55 -08:00
Dave Cheney
11d96dd7f5 go/build: give better explanation for "cannot find package"
Fixes #4079.

Some example output:

% go install foo/bar
can't load package: package foo/bar: cannot find package "foo/bar" in any of:
        /home/dfc/go/src/pkg/foo/bar (from $GOROOT)
        /home/dfc/src/foo/bar (from $GOPATH)
        /home/dfc/src2/src/foo/bar

% GOPATH= go install foo/bar
can't load package: package foo/bar: cannot find package "foo/bar" in any of:
	/home/dfc/go/src/pkg/foo/bar (from $GOROOT)
	($GOPATH not set)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6899057
2012-12-12 21:38:52 +11:00
Dave Cheney
4766a35e7c net: TestDialTimeoutFDLeak failure
Fixes #4384.

Implments the suggestion by rsc in comment 15, http://code.google.com/p/go/issues/detail?id=4384#c15

An alternate suggestion would be to temporarily set GOMAXPROCS to 1 during this test.

R=fullung, rsc
CC=golang-dev
https://golang.org/cl/6923046
2012-12-12 07:25:07 +11:00
Ryan Slade
9a12a9c594 encoding/csv: add Error method to Writer
Fixed issue 3931

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6923049
2012-12-11 13:29:13 -05:00
Robert Griesemer
1a6f8dcbaf exp/types: filling in more blanks
- implemented built-in complex()
- implemented missing expression switch checks

R=rsc
CC=golang-dev
https://golang.org/cl/6920046
2012-12-11 10:17:33 -08:00
Russ Cox
3c6c88319e regexp: re-enable TestBadCompile
The code that was commented out was for the old regexp package.
In the new one the errors and the space of valid regexps are different.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6873063
2012-12-11 12:19:39 -05:00
Luit van Drongelen
f4fc163d17 math/big: add SetUint64 and Uint64 functions to *Int
Implementation is mostly identical to passing a non-negative int64 to
SetInt64, and calling Int64 with a non-negative value in the *Int.
Fixes #4389.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6929048
2012-12-11 12:19:10 -05:00
Brad Fitzpatrick
a6701f2699 net/http, net/url: permit Request-URI "*"
Also, implement a global OPTIONS * handler, like Apache.

Permit sending "*" requests to handlers, but not path-based
(ServeMux) handlers.  That means people can go out of their
way to support SSDP or SIP or whatever, but most users will be
unaffected.

See RFC 2616 Section 5.1.2 (Request-URI)
See RFC 2616 Section 9.2 (OPTIONS)

Fixes #3692

R=rsc
CC=golang-dev
https://golang.org/cl/6868095
2012-12-11 12:07:27 -05:00
Brad Fitzpatrick
fc3936380b syscall: let mkall.sh work on multiarch systems (like Precise)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6912063
2012-12-11 12:03:18 -05:00
Brian Ketelsen
1b46e4cd9a regexp/syntax: export ErrUnexpectedParen
Fixes #3712

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6902069
2012-12-11 12:02:14 -05:00
Russ Cox
07cc05864c fmt: fix %v of complex slice
Fixes #4525.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6929049
2012-12-11 11:49:41 -05:00
Shenghou Ma
15353d2114 encoding/base64: new example for NewEncoder with emphasis on Close
Fixes #4394.

R=iant, bradfitz, rsc, remigius.gieben
CC=golang-dev
https://golang.org/cl/6847125
2012-12-11 11:49:02 -05:00
Rick Arnold
2f45f2801d net/url: fix handling of relative paths in ResolveReference.
Fixes #3560.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6886047
2012-12-11 11:06:07 -05:00
Russ Cox
f0d9ccb8da bufio: minor fixes
* note end-of-line and EOF behavior for ReadLine
* diagnose broken Readers

Fixes #3825.
Fixes #4276.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6907060
2012-12-10 17:25:31 -05:00
Brad Fitzpatrick
575de93dd3 mime/multipart: allow setting the Writer boundary
Fixes #4490

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6924044
2012-12-10 16:30:42 -05:00
Brad Fitzpatrick
bef036e3d1 syscall: add type for struct tcp_info
R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/6900050
2012-12-10 11:32:07 -05:00
Francisco Souza
76de81da50 encoding/xml: fix typo in Marshal documentation
Fixes #4512.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6917043
2012-12-10 10:59:15 -05:00
Russ Cox
91527eb1d7 net/rpc: document that Register logs to standard error
Also fix spurious & in example.

Fixes #4349.
Fixes #4489.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6905058
2012-12-10 01:42:53 -05:00
Russ Cox
4f3dd833e3 net/http: fix text for ErrBodyReadAfterClose
Can happen in both request and response.
Also use it in one place that wasn't.

Fixes #3997.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6903057
2012-12-10 01:42:10 -05:00
Russ Cox
00cd6a3be3 time: add Round and Truncate
New in Go 1 will be nanosecond precision in the result of time.Now on Linux.
This will break code that stores time in external formats at microsecond
precision, reads it back, and expects to get exactly the same time.

Code like that can be fixed by using time.Now().Round(time.Microsecond)
instead of time.Now() in those contexts.

R=golang-dev, bradfitz, iant, remyoudompheng
CC=golang-dev
https://golang.org/cl/6903050
2012-12-09 03:59:33 -05:00
David Symonds
ec45952670 math/rand: fix typo in example comment.
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6901056
2012-12-08 19:20:38 +11:00
Russ Cox
b99161e41f math/rand: add example / regression test
This makes sure the outputs do not change for a fixed seed.
See also https://golang.org/cl/6905049.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6907048
2012-12-07 11:58:59 -05:00
Russ Cox
ff2534e076 undo CL 6845121 / 79603a5e4cda
This changes the output of

rand.Seed(0)
perm := rand.Perm(100)

When giving the same seeds to Go 1.0 and Go 1.1 programs
I would like them to generate the same random numbers.

««« original CL description
math/rand: remove noop iteration in Perm

The first iteration always do `m[0], m[0] = m[0], m[0]`, because
`rand.Intn(1)` is 0.

fun note: IIRC in TAOCP version of this algorithm, `i` goes
backward (n-1->1), meaning that the "already" shuffled part of the
array is never altered betweens iterations, while in the current
implementation the "not-yet" shuffled part of the array is
conserved between iterations.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6845121

»»»

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6905049
2012-12-07 11:58:44 -05:00
Robert Griesemer
9088d17afb fix build: remove a flaky test for now
R=rsc
CC=golang-dev
https://golang.org/cl/6889052
2012-12-06 09:47:12 -08:00
Robert Griesemer
e93bdd998c exp/gotype: added many more tests
gotype can now handle much of the standard library.

- marked packages which have type checker issues
- this CL depends on CL 6846131

R=rsc
CC=golang-dev
https://golang.org/cl/6850130
2012-12-06 09:23:13 -08:00
Robert Griesemer
69d0f0cc47 exp/types: checking of type switches and range clauses
Also:
- better handling of type assertions
- implemented built-in error type
- first cut at handling variadic function signatures
- several bug fixes

R=rsc, rogpeppe
CC=golang-dev
https://golang.org/cl/6846131
2012-12-06 09:21:30 -08:00
Brad Fitzpatrick
53d091c5ff net/http: populate ContentLength in HEAD responses
Also fixes a necessary TODO in the process.

Fixes #4126

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6869053
2012-12-05 22:36:23 -08:00
Rick Arnold
5416e6e916 net: document that File reverts connection to blocking mode.
Fixes #2458.

R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/6869054
2012-12-05 23:31:35 -05:00
Brad Fitzpatrick
4fb78c3a16 net/http: implement CloseNotifier
Fixes #2510

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6867050
2012-12-05 19:25:43 -08:00
Brad Fitzpatrick
a034fc9855 net/http: fix bug parsing http_proxy lacking a protocol
Per the curl man page, the http_proxy configuration can be
of the form:

   [protocol://]<host>[:port]

And we had a test that <ip>:<port> worked, but if
the host began with a letter, url.Parse parsed the hostname
as the scheme instead, confusing ProxyFromEnvironment.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6875060
2012-12-05 19:08:42 -08:00
Dave Cheney
9fb96991e6 net: fix data races on deadline vars
Fixes #4434.

This proposal replaces the previous CL 6855110. Due to issue 599, 64-bit atomic operations should probably be avoided, so use a sync.Mutex instead.

Benchmark comparisons against 025b9d070a85 on linux/386:

CL 6855110:

benchmark                        old ns/op    new ns/op    delta
BenchmarkTCPOneShot                 710024       727409   +2.45%
BenchmarkTCPOneShotTimeout          758178       768620   +1.38%
BenchmarkTCPPersistent              223464       228058   +2.06%
BenchmarkTCPPersistentTimeout       234494       242600   +3.46%

This proposal:

benchmark                        old ns/op    new ns/op    delta
BenchmarkTCPOneShot                 710024       718492   +1.19%
BenchmarkTCPOneShotTimeout          758178       748783   -1.24%
BenchmarkTCPPersistent              223464       227628   +1.86%
BenchmarkTCPPersistentTimeout       234494       238321   +1.63%

R=rsc, dvyukov, mikioh.mikioh, alex.brainman, bradfitz
CC=golang-dev, remyoudompheng
https://golang.org/cl/6866050
2012-12-05 15:59:01 +11:00
Alex Brainman
4855c1c145 net: change windows netFD finalizer to behave similar to unix
R=dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6873046
2012-12-05 15:26:18 +11:00
Brad Fitzpatrick
a7c57b05e9 net/http: clarify DefaultTransport docs
Fixes #4281

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6872053
2012-12-04 20:14:58 -08:00
Alex Brainman
87b315a78f net: add missing close socket code
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6868067
2012-12-05 15:13:03 +11:00
Frithjof Schulze
cfc0a59d6e container/heap: Simplify the example.
Using append simplifies the code and makes it work if
the initial capacity of the slice is smaller than the
number of items pushed.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/6869060
2012-12-04 14:11:33 -08:00
Brad Fitzpatrick
add1bed735 net/http: clarify that Request.Host may contain a port number
Fixes #4172

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6872055
2012-12-04 07:09:01 -08:00
Alex Brainman
0420eb3b65 net: report Accept error during TestVariousDeadlines1Proc test
R=golang-dev
CC=golang-dev
https://golang.org/cl/6868057
2012-12-04 17:00:19 +11:00
Rémy Oudompheng
b1c4a8efa9 bytes: avoid duplicate malloc/copy in Buffer.ReadString
Twice faster and twice less garbage.

R=golang-dev, dave, daniel.morsing, bradfitz
CC=golang-dev
https://golang.org/cl/6849128
2012-12-03 14:04:18 +01:00
Mikio Hara
19d793a327 net: simplify ListenTCP
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6875044
2012-12-03 20:00:50 +09:00
Luit van Drongelen
882953f62c encoding/gob: Fix typo in doc.go
Exactly how I find minute details like this is beyond me.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6842125
2012-12-01 15:15:14 -08:00
Johan Euphrosine
d7b0f2a524 math/rand: remove noop iteration in Perm
The first iteration always do `m[0], m[0] = m[0], m[0]`, because
`rand.Intn(1)` is 0.

fun note: IIRC in TAOCP version of this algorithm, `i` goes
backward (n-1->1), meaning that the "already" shuffled part of the
array is never altered betweens iterations, while in the current
implementation the "not-yet" shuffled part of the array is
conserved between iterations.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6845121
2012-12-01 14:11:46 -08:00
Brad Fitzpatrick
444b7b53e0 crypto/tls: fix loading keys labeled just "PRIVATE KEY"
Worked in Go 1, broken in f440e65f93fe.

Fixes #4477

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6865043
2012-12-01 11:02:08 -08:00
Rémy Oudompheng
b18a7c7cae net: remove unnecessary Close contention.
Contention profile in BenchmarkTCPOneShot (Core 2 Quad):

Before
Total: 80.285 seconds
44.743  55.7%  55.7%   44.743  55.7% runtime.chanrecv1
31.995  39.9%  95.6%   31.995  39.9% sync.(*Mutex).Lock
 3.547   4.4% 100.0%    3.547   4.4% runtime.chansend1

After
Total: 48.341 seconds
45.810  94.8%  94.8%   45.810  94.8% runtime.chanrecv1
 2.530   5.2% 100.0%    2.530   5.2% runtime.chansend1
 0.001   0.0% 100.0%    0.001   0.0% sync.(*Mutex).Lock

R=golang-dev, dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6845119
2012-12-01 09:26:07 +01:00
Mikio Hara
e3e885bb48 net: allow "" as a hint wildcard to Resolve{IP,UDP,TCP}Addr
Also fixes comments on ResolveIPAddr.

Fixes #4476.

R=bradfitz, golang-dev
CC=golang-dev
https://golang.org/cl/6854129
2012-12-01 14:49:54 +09:00
Anthony Martin
253ed02918 net: update docs and sync API for Plan 9
R=golang-dev, dave, mikioh.mikioh, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6674043
2012-11-30 11:41:50 -08:00
Shenghou Ma
9e30b708a1 all: set GOMAXPROCS to 1 when counting mallocs
also fix an annoying test that relies on $GOROOT be set.
Fixes #3690.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6844086
2012-12-01 00:38:01 +08:00
Dave Cheney
5b425cc3ab undo CL 6855110 / 869253ef7009
64bit atomics are broken on 32bit systems. This is issue 599.

linux/arm builders all broke with this change, I am concerned that the other 32bit builders are silently impacted.

««« original CL description
net: fix data races on deadline vars

Fixes #4434.

R=mikioh.mikioh, bradfitz, dvyukov, alex.brainman
CC=golang-dev
https://golang.org/cl/6855110
»»»

R=rsc, mikioh.mikioh, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/6852105
2012-11-30 20:02:30 +11:00
Dave Cheney
be0d84e335 net: fix data races on deadline vars
Fixes #4434.

R=mikioh.mikioh, bradfitz, dvyukov, alex.brainman
CC=golang-dev
https://golang.org/cl/6855110
2012-11-30 18:26:51 +11:00
Dmitriy Vyukov
0ce96f9ef4 runtime: better stack traces in race reports
When a race happens inside of runtime (chan, slice, etc),
currently reports contain only user file:line.
If the line contains a complex expression,
it's difficult to figure out where the race exactly.
This change adds one more top frame with exact
runtime function (e.g. runtime.chansend, runtime.mapaccess).

R=golang-dev
CC=golang-dev
https://golang.org/cl/6851125
2012-11-30 10:29:41 +04:00
Alex Brainman
902af974cb os: check only user attributes in TestStatDirModeExec
Some have their system setup in a particular way,
see http://golang.org/issue/4444#c3.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6851129
2012-11-30 16:10:45 +11:00
Brad Fitzpatrick
9c2f410206 net/http: don't send chunked encoding on 204 responses
RFC 2616: "The 204 response MUST NOT include a message-body,
and thus is always terminated by the first empty line after
the header fields."

Previously we'd trigger chunked encoding by default on
responses, and then when finishing the request we'd write the
chunk trailers, which counted as a message-body.

Fixes #4454

R=golang-dev
CC=golang-dev
https://golang.org/cl/6782139
2012-11-29 18:00:51 -08:00
Russ Cox
6d622416f1 net: add test case for SplitHostPort with zone
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6854119
2012-11-29 15:43:05 -05:00
Robert Griesemer
521f11de6b exp/types: various missing checks for array/slice composite literals
- check indices of array/slice composite literals
- handle [...]T
- also: go/defer statements

R=rsc
CC=golang-dev
https://golang.org/cl/6856107
2012-11-29 09:57:37 -08:00
Robert Griesemer
305d7ada2b go/parser: permit [...]T where array types are permitted
More lenient parsing with better error recovery.
It's easier for the type check to pick up the slack.

R=iant
CC=golang-dev
https://golang.org/cl/6856108
2012-11-28 16:03:34 -08:00
Alex Brainman
5b65023563 os: include 0111 in directory file mode on windows
Fixes #4444.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6858079
2012-11-28 17:01:59 +11:00
Alex Brainman
16a5934540 exp/winfsnotify: fix data race in TestNotifyClose
Fixes #4342.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6850080
2012-11-28 17:01:22 +11:00
Alex Brainman
b5aa4789f9 net/http: fix broken TestIssue4191_InfiniteGetToPutTimeout
Test creates 2 tcp connections for put and get. Make sure
these are closed properly after test is over, otherwise
server hangs waiting for connection to be closed.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6842109
2012-11-28 17:00:50 +11:00
Dave Cheney
28b599425d net: move deadline logic into pollServer
Update #4434.

The proposal attempts to reduce the number of places where fd,{r,w}deadline is checked and updated in preparation for issue 4434. In doing so the deadline logic is simplified by letting the pollster return errTimeout from netFD.Wait{Read,Write} as part of the wakeup logic.

The behaviour of setting n = 0 has been restored to match rev 2a55e349097f, which was the previous change to fd_unix.go before CL 6851096.

R=jsing, bradfitz, mikioh.mikioh, rsc
CC=fullung, golang-dev
https://golang.org/cl/6850110
2012-11-28 11:29:25 +11:00
Mikio Hara
da803e5cd3 net: fix ResolveIPAddr
Fixes misedit in CL 6842053.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6849115
2012-11-28 08:45:23 +09:00
Dave Cheney
d244dd09f3 net: fix intermittent TestAddFDReturnsError failure
A fix similar to CL 6859043 was effective in resolving the intermittent failure.

Fixes #4423.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6854102
2012-11-28 10:08:59 +11:00
Mikio Hara
4f74bbd24c net: consoldate literal target address into IP address functions
This CL continues with introducing IPv6 scoped addressing capability
into the net package.

Update #4234.

R=rsc
CC=golang-dev
https://golang.org/cl/6842053
2012-11-28 06:36:05 +09:00
Robert Griesemer
e781b20ac9 go/format: Package format implements standard formatting of Go source.
Package format is a utility package that takes care of
parsing, sorting of imports, and formatting of .go source
using the canonical gofmt formatting parameters.

Use go/format in various clients instead of the lower-level components.

R=r, bradfitz, dave, rogpeppe, rsc
CC=golang-dev
https://golang.org/cl/6852075
2012-11-27 10:29:49 -08:00
Jan Ziak
51b8edcb37 runtime: use reflect·call() to enter the function gc()
Garbage collection code (to be merged later) is calling functions
which have many local variables. This increases the probability that
the stack capacity won't be big enough to hold the local variables.
So, start gc() on a bigger stack to eliminate a potentially large number
of calls to runtime·morestack().

R=rsc, remyoudompheng, dsymonds, minux.ma, iant, iant
CC=golang-dev
https://golang.org/cl/6846044
2012-11-27 13:04:59 -05:00
Dmitriy Vyukov
58ce93b6bf runtime/race: add test case for issue 4453
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6854103
2012-11-27 21:59:08 +04:00
Rick Arnold
94b3f6d728 regexp: add Split
As discussed in issue 2672 and on golang-nuts, this CL adds a Split() method
to regexp. It is based on returning the "opposite" of FindAllString() so that
the returned substrings are everything not matched by the expression.

See: https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/xodBZh9Lh2E

Fixes #2762.

R=remyoudompheng, r, rsc
CC=golang-dev
https://golang.org/cl/6846048
2012-11-27 12:58:27 -05:00
Volker Dobler
b46de71457 regexp: add examples
Update #4125

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6847107
2012-11-27 10:33:15 -05:00
John Graham-Cumming
4228eb7915 log/syslog: correct message format
The syslog implementation was not correctly implementing the
traditional syslog format because it had a confused notion of
'priority'.  syslog priority is not a single number but is, in
fact, the combination of a facility number and a severity. The
previous Go syslog implementation had a single Priority that
appeared to be the syslog severity and no way of setting the
facility.  That meant that all syslog messages from Go
programs appeared to have a facility of 0 (LOG_KERN) which
meant they all appeared to come from the kernel.

Also, the 'prefix' was in fact the syslog tag (changed the
internal name for clarity as the term tag is more widely used)
and the timestamp and hostname values were missing from
messages.

With this change syslog messages are generated in the correct
format with facility and severity combined into a priority,
the timestamp in RFC3339 format, the hostname, the tag (with
the PID in [] appened) and the message.

The format is now:

   <PRI>1 TIMESTAMP HOSTNAME TAG[PID]: MSG

The TIMESTAMP, HOSTNAME and PID fields are filled in
automatically by the package. The TAG and the MSG are supplied
by the user. This is what rsyslogd calls TraditionalFormat and
should be compatible with multiple systems.

R=rsc, jgc, 0xjnml, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/6782118
2012-11-27 10:21:43 -05:00
Dmitriy Vyukov
908e1b5ea1 runtime/race: add unit tests for race detector
R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6525052
2012-11-27 15:04:48 +04:00
Dmitriy Vyukov
d6fd52c088 net: fix flaky test
The test failed on one of the builders with:
timeout_test.go:594: 	ln.Accept: accept tcp 127.0.0.1:19373: use of closed network connection
http://build.golang.org/log/e83f4a152b37071b9d079096e15913811ad296b5

R=golang-dev, bradfitz, dave, mikioh.mikioh, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6859043
2012-11-27 12:18:54 +04:00
Nigel Tao
478aff3d4d exp/cookiejar: new package.
This CL defines the API. Implementation will come in follow-up CLs.

Update #1960.

R=bradfitz, dr.volker.dobler, rsc
CC=golang-dev
https://golang.org/cl/6849092
2012-11-27 18:20:44 +11:00
Robert Griesemer
bb7c3c6803 go/ast: minor cleanup
It's better to use IsValid() then checking a (possibly
partially set up) position against NoPos directly.

R=dsymonds
CC=golang-dev
https://golang.org/cl/6855099
2012-11-26 17:17:49 -08:00
Anthony Martin
178c8578d5 os/user: update stub documentation
R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6844088
2012-11-26 16:02:08 -08:00
Anthony Martin
4ce3df5074 os: move Plan 9 directory marshaling code to syscall
The API additions to syscall are in dir_plan9.go.

R=seed, rsc, rminnich, mirtchovski, dave
CC=golang-dev, lucio.dere
https://golang.org/cl/6157045
2012-11-26 15:26:46 -08:00
Robert Griesemer
4a1b814668 go/printer: don't use 'infinity' value when it might lead to int32 overflow
Fixes 386 build breakage.

R=rsc
CC=golang-dev
https://golang.org/cl/6844091
2012-11-26 14:20:05 -08:00
Brad Fitzpatrick
127d2bf785 net/http: fix Transport races & deadlocks
Thanks to Dustin Sallings for exposing the most frustrating
bug ever, and for providing repro cases (which formed the
basis of the new tests in this CL), and to Dave Cheney and
Dmitry Vyukov for help debugging and fixing.

This CL depends on submited pollster CLs ffd1e075c260 (Unix)
and 14b544194509 (Windows), as well as unsubmitted 6852085.
Some operating systems (OpenBSD, NetBSD, ?) may still require
more pollster work, fixing races (Issue 4434 and
http://goo.gl/JXB6W).

Tested on linux-amd64 and darwin-amd64, both with GOMAXPROCS 1
and 4 (all combinations of which previously failed differently)

Fixes #4191
Update #4434 (related fallout from this bug)

R=dave, bradfitz, dsallings, rsc, fullung
CC=golang-dev
https://golang.org/cl/6851061
2012-11-26 13:31:02 -08:00
Robert Griesemer
9a61c0412c go/printer: some internal cleanups
Cleanups introduced originally by now abandoned
https://golang.org/cl/6846078/ .

Includes additional test cases for 'if' and 'for'
statements.

No formatting changes.

R=rsc
CC=golang-dev
https://golang.org/cl/6855096
2012-11-26 13:20:30 -08:00
Robert Griesemer
2a982e8e25 go/printer: Permit declaration and statement lists as input.
Also: Can set base indentation in printer.Config: all code
is going to be indented by at least that amount (except for
raw string literals spanning multiple lines, since their
values must not change).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6847086
2012-11-26 13:14:04 -08:00
Robert Griesemer
d7b0271065 exp/types: fixed field/method lookup
also:

- composite literal checking close to complete
- cleaned up parameter, method, field checking
- don't let panics escape type checker
- more TODOs eliminated

R=rsc
CC=golang-dev
https://golang.org/cl/6816083
2012-11-26 12:49:04 -08:00
Anthony Martin
1de4d313dd crypto/tls: use 1/n-1 record splitting to protect against BEAST
This requires rebasing the block-mode test scripts.
I used GnuTLS version 3.1.4.

R=agl
CC=golang-dev
https://golang.org/cl/6844073
2012-11-26 10:56:39 -08:00
Dmitriy Vyukov
f4ed50c260 net: add deadline prolongation test
Currently the test exposes data races on deadline vars.

R=golang-dev, dave, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6845091
2012-11-26 22:28:39 +04:00
Shenghou Ma
2637777527 runtime: duplicate code for runtime.nanotime to avoid stack overflow in vDSO clock_gettime
Fixes #4402.

R=remyoudompheng, shivakumar.gn, random0x00, rsc
CC=golang-dev
https://golang.org/cl/6842063
2012-11-27 01:42:01 +08:00
Oling Cat
f80f23e748 runtime: re-format comments.
add necessary newlines.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6847067
2012-11-26 10:53:11 -05:00
Mikio Hara
e8cf49f701 net, cmd/fix: add IPv6 scoped addressing zone to INET, INET6 address structs
This CL starts to introduce IPv6 scoped addressing capability
into the net package.

The Public API changes are:
+pkg net, type IPAddr struct, Zone string
+pkg net, type IPNet struct, Zone string
+pkg net, type TCPAddr struct, Zone string
+pkg net, type UDPAddr struct, Zone string

Update #4234.

R=rsc, bradfitz, iant
CC=golang-dev
https://golang.org/cl/6849045
2012-11-27 00:45:42 +09:00
Mikio Hara
f02cf1997d runtime: regenerate defs-files for freebsd
R=minux.ma, jsing
CC=golang-dev
https://golang.org/cl/6855080
2012-11-26 21:29:13 +09:00
Shenghou Ma
62f54e1294 net/http: clarify docs of ParseForm and mention ParseForm in docs for FormValue
while we're at it, also fix a return value stutter in ParseForm.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6847074
2012-11-26 20:03:24 +08:00
Joel Sing
4047f300c9 runtime: implement SysUnused for netbsd
R=golang-dev, bradfitz, minux.ma, dave
CC=golang-dev
https://golang.org/cl/6842081
2012-11-26 22:34:01 +11:00
Joel Sing
c6afb781e2 runtime: implement SysUnused for openbsd
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6854079
2012-11-26 22:32:59 +11:00
Dave Cheney
73b3e2301e net: never return -1 bytes read from netFD.Read
If the a network read would block, and a packet arrived just before the timeout expired, then the number of bytes from the previous (blocking) read, -1, would be returned.

This change restores the previous logic, where n would be unconditionally set to 0 if err != nil, but was skipped due to a change in CL 6851096.

The test for this change is CL 6851061.

R=bradfitz, mikioh.mikioh, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/6852085
2012-11-26 10:59:43 +11:00
Brad Fitzpatrick
f97bb12bb0 net/http/httptest: protect against port reuse
Should make BSDs more reliable. (they seem to reuse ports
quicker than Linux)

Tested by hand with local modifications to force reuse on
Linux. (net/http tests failed before, pass now) Details in the
issue.

Fixes #4436

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6847101
2012-11-25 15:23:20 -08:00
Brad Fitzpatrick
c8fa7dcc25 bytes, strings: fix Reader WriteTo return value on 0 bytes copied
Fixes #4421

R=golang-dev, dave, minux.ma, mchaten, rsc
CC=golang-dev
https://golang.org/cl/6855083
2012-11-25 09:04:13 -08:00
Mikio Hara
1fbe3090d8 runtime: fix madvise for freebsd/amd64
Make use of carry clear condition instead of low or same.

R=minux.ma, jsing, dave
CC=golang-dev
https://golang.org/cl/6844080
2012-11-25 18:46:41 +09:00
Dmitriy Vyukov
74fcf82dd9 net: add unit tests for read/write deadlines
The tests verify that deadlines are "persistent",
read/write deadlines do not interfere, can be reset,
read deadline can be set with both SetDeadline()
and SetReadDeadline(), etc.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6850070
2012-11-25 13:27:32 +04:00
Dave Cheney
1e9ab9e792 time: add Now()/UnixNano() malloc tests
The fix for issue 4403 may include more calls to time.Now().UnixNano(). I was concerned that if this function allocated it would cause additional garbage on the heap. It turns out that it doesn't, which is a nice surprise.

Also add benchmark for Now().UnixNano()

R=bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/6849097
2012-11-25 11:29:06 +11:00
Alex Brainman
747dda9767 net: do not start io if deadline has passed
R=golang-dev, mikioh.mikioh, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6851098
2012-11-25 10:02:57 +11:00
Caine Tighe
7afcae6bab http/transport.go: trivial comment error.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6856078
2012-11-25 05:08:17 +08:00
Brad Fitzpatrick
5fa3aeb14d net: check read and write deadlines before doing syscalls
Otherwise a fast sender or receiver can make sockets always
readable or writable, preventing deadline checks from ever
occuring.

Update #4191 (fixes it with other CL, coming separately)
Fixes #4403

R=golang-dev, alex.brainman, dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6851096
2012-11-23 22:15:26 -08:00
John Graham-Cumming
314fd62434 runtime: implement runtime.SysUnused on FreeBSD
madvise was missing so implement it in assembler. This change
needs to be extended to the other BSD variantes (Net and Open)

Without this change the scavenger will attempt to pass memory back
to the operating system when it has become idle, but the memory is
not returned and for long running Go processes the total memory used
can grow until OOM occurs.

I have only been able to test the code on FreeBSD AMD64. The ARM
platforms needs testing.

R=golang-dev, mikioh.mikioh, dave, jgc, minux.ma
CC=golang-dev
https://golang.org/cl/6850081
2012-11-24 15:55:19 +11:00
Dave Cheney
d4775a7814 net/http/httptest: fix possible race on historyListener.history
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6845077
2012-11-24 15:50:43 +11:00
Dave Cheney
dd43bf807d net/http: use runtime.Stack instead of runtime/debug.Stack
Fixes #4060.

2012/11/21 19:51:34 http: panic serving 127.0.0.1:47139: Kaaarn!
goroutine 7 [running]:
net/http.func·004(0x7f330807ffb0, 0x7f330807f100)
	/home/dfc/go/src/pkg/net/http/server.go:615 +0xa7
----- stack segment boundary -----
main.(*httpHandler).ServeHTTP()
	/home/dfc/src/httppanic.go:16 +0x53
net/http.(*conn).serve(0xc200090240, 0x0)
	/home/dfc/go/src/pkg/net/http/server.go:695 +0x55d
created by net/http.(*Server).Serve
	/home/dfc/go/src/pkg/net/http/server.go:1119 +0x36d

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6846085
2012-11-22 08:18:45 +11:00
Shenghou Ma
42c8904fe1 all: fix the the typos
Fixes #4420.

R=golang-dev, rsc, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854080
2012-11-22 02:58:24 +08:00
Joel Sing
cd37fecffb runtime: update openbsd runtime to use new tfork syscall
Update OpenBSD runtime to use the new version of the sys___tfork
syscall and switch TLS initialisation from sys_arch to sys___set_tcb
(note that both of these syscalls are available in OpenBSD 5.2).

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6843058
2012-11-22 01:25:53 +11:00
Dave Cheney
d28133dc9f net: remove another unguarded sysfile == nil check
Putting aside the unguarded access to fd.sysfile, the condition will never be true as fd.incref above handles the closed condition.

R=mikioh.mikioh, dvyukov
CC=golang-dev
https://golang.org/cl/6845062
2012-11-21 15:04:22 +11:00
Shenghou Ma
7bce6f9386 net/http, net/http/httputil: fix TestChunkReaderAllocs failure when GOMAXPROCS > 1
R=fullung, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6846081
2012-11-21 02:18:34 +08:00
Ian Lance Taylor
4bf261f9e3 exp/types: don't test importing types if using gccgo
The exp/types packages does not support the gccgo export data
format.  At some point it should, but not yet.

R=gri, bradfitz, r, iant, dsymonds
CC=golang-dev
https://golang.org/cl/6854068
2012-11-19 21:56:24 -08:00
Alex Brainman
54b9c20151 net/http/cgi: another attempt to fix windows tests
Also enables TestDirWindows test on windows.

Fixes #4401.

R=golang-dev, bradfitz
CC=golang-dev, krautz
https://golang.org/cl/6847072
2012-11-20 16:24:12 +11:00
Brad Fitzpatrick
9466c27fec net/http: remove more garbage from chunk reading
Noticed this while closing tabs. Yesterday I thought I could
ignore this garbage and hope that a fix for issue 2205 handled
it, but I just realized that's the opposite case,
string->[]byte, whereas this is []byte->string.  I'm having a
hard time convincing myself that an Issue 2205-style fix with
static analysis and faking a string header would be safe in
all cases without violating the memory model (callee assumes
frozen memory; are there non-racy ways it could keep being
modified?)

R=dsymonds
CC=dave, gobot, golang-dev
https://golang.org/cl/6850067
2012-11-19 19:50:42 -08:00
Brad Fitzpatrick
d32d1e098a mime/multipart: transparently decode quoted-printable transfer encoding
Fixes #4411

R=dsymonds
CC=gobot, golang-dev
https://golang.org/cl/6854067
2012-11-19 19:50:19 -08:00
Robert Griesemer
c00bda1352 go/printer: simply ignore filename changes in position information
There's no good reason to make any printer state adjustments
simply because the file name in node position information has
changed. Eliminate the relevant code.

R=r
CC=golang-dev
https://golang.org/cl/6856054
2012-11-19 13:23:32 -08:00
Brad Fitzpatrick
e070aeae77 net/http/cgi: more windows perl test work
Don't rely on finding cmd.exe in a particular spot.

Fixes #4401

R=golang-dev, krautz
CC=golang-dev
https://golang.org/cl/6842066
2012-11-19 10:40:13 -08:00
Christian Himpel
ca8aac698f runtime: gdb support: use parse_and_eval to get the goroutine id
This enables to loop over some goroutines, e.g. to print the
backtrace of goroutines 1 to 9:

        set $i = 1
        while $i < 10
        printf "backtrace of goroutine %d:\n", $i
        goroutine $i++ bt
        end

R=lvd, lvd
CC=golang-dev
https://golang.org/cl/6843071
2012-11-19 10:22:47 -08:00
Brad Fitzpatrick
c8e7469fcd net/http/cgi: make test more robust for Windows perl
Update #4401

R=golang-dev, mattn.jp
CC=golang-dev
https://golang.org/cl/6853067
2012-11-19 08:25:51 -08:00
Dave Cheney
c9856e7d22 net: fix data race on fd.sysfd
Fixes #4369.

Remove the check for fd.sysfd < 0, the first line of fd.accept() tests if the fd is open correctly and will handle the fd being closed during accept.

R=dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/6843076
2012-11-19 06:53:58 +11:00
Dave Cheney
0bfece06d7 net: remove unused nil check
This is part 1 of a series of proposals to fix issue 4369.

In resolving issue 3507 it was decided not to nil out the inner conn.fd field to avoid a race. This implies the checks for fd == nil inside incref/decref are never true.

Removing this logic removes one source of errClosing error values, which affects issue 4373 and moves towards bradfitz's request that fd.accept() return io.EOF when closed concurrently.

Update #4369.
Update #4373.

R=mikioh.mikioh, bradfitz, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/6852057
2012-11-18 15:31:26 +11:00
Dave Cheney
4758f89ddb runtime/cgo: enable warnings and treat as errors
Enable warnings as errors during the cgo portion of runtime/cgo. iant requested that the list of flags match cmd/dist/build.c, but I would like to avoid the set of disabled warnings if possible.

ref: https://groups.google.com/d/topic/golang-nuts/TrCoVzIIG4M/discussion

requires: 6843061

R=minux.ma, iant
CC=golang-dev
https://golang.org/cl/6852055
2012-11-18 08:58:54 +11:00
Shenghou Ma
d1e06dab7c runtime: don't assume AT_RANDOM provide 4-byte aligned ptr
R=dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854056
2012-11-18 02:47:17 +08:00
Robert Griesemer
80dcc434a8 go/doc: fix identifier blank import handling for examples
Replacement CL for 6813061; thanks to minux for prototyping.

Fixes #4300.

R=minux.ma
CC=golang-dev
https://golang.org/cl/6782082
2012-11-17 10:40:11 -08:00
Shenghou Ma
38458ce3fe crypto/md5: speed up aligned writes and test/bench unaligned writes
Write() can safely use uint32 loads when input is aligned.
Also add test and benchmarks for unaligned writes.

Benchmark result obtained by Dave Cheney on ARMv5TE @ 1.2GHz:
benchmark                       old ns/op    new ns/op    delta
BenchmarkHash8Bytes                  4104         3417  -16.74%
BenchmarkHash1K                     22061        11208  -49.20%
BenchmarkHash8K                    146630        65148  -55.57%
BenchmarkHash8BytesUnaligned         4128         3436  -16.76%
BenchmarkHash1KUnaligned            22054        21473   -2.63%
BenchmarkHash8KUnaligned           146658       146909   +0.17%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkHash8Bytes                  1.95         2.34    1.20x
BenchmarkHash1K                     46.42        91.36    1.97x
BenchmarkHash8K                     55.87       125.74    2.25x
BenchmarkHash8BytesUnaligned         1.94         2.33    1.20x
BenchmarkHash1KUnaligned            46.43        47.69    1.03x
BenchmarkHash8KUnaligned            55.86        55.76    1.00x

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/6782072
2012-11-18 02:23:34 +08:00
Shenghou Ma
3513d84068 runtime/cgo: fix compilation on Windows with CFLAGS -Wall -Werror
also fix one out-of-date comment in cmd/ld/pe.c as well.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6843061
2012-11-18 02:06:08 +08:00
Dave Cheney
7ec76e25b6 archive/zip: handle extra data headers with no body
Fixes #4393.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6854058
2012-11-18 00:45:47 +11:00
Robin Eklind
4f250132f7 archive/zip, crypto/tls, net/http: Fix print format errors.
All of the errors were located using "go vet ./..." in "src/pkg".

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6856056
2012-11-16 17:24:43 -08:00
Brad Fitzpatrick
f3e6b20606 net/http: reduce allocations in chunk reading & writing
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6847063
2012-11-16 13:25:01 -08:00
Robert Griesemer
de58eb9091 go/printer: leave indentation alone when printing nodes from different files
ASTs may be created by various tools and built from nodes of
different files. An incorrectly constructed AST will likely
not print at all, but a (structurally) correct AST with bad
position information should still print structurally correct.

One heuristic used was to reset indentation when the filename
in the position information of nodes changed. However, this
can lead to wrong indentation for structurally correct ASTs.

Fix: Don't change the indentation in this case.

Related to issue 4300.

R=r
CC=golang-dev
https://golang.org/cl/6849066
2012-11-16 13:17:12 -08:00
Robert Griesemer
a42e8a8086 go/ast: FuncType.Params may be nil (per AST documentation)
ast.Walk needs to check for it or it will crash.

R=r
CC=golang-dev
https://golang.org/cl/6852062
2012-11-16 11:53:26 -08:00
Dmitriy Vyukov
8f82bff545 runtime: hide mheap from race detector
This significantly decreases amount of shadow memory
mapped by race detector.
I haven't tested on Windows, but on Linux it reduces
virtual memory size from 1351m to 330m for fmt.test.
Fixes #4379.

R=golang-dev, alex.brainman, iant
CC=golang-dev
https://golang.org/cl/6849057
2012-11-16 20:06:11 +04:00
Oling Cat
aa3d05acc9 runtime: remove extra parentheses.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6843069
2012-11-16 23:09:37 +11:00
Joel Sing
aaf3b71288 crypto/tls: add support for loading EC X.509 key pairs
Add support for loading X.509 key pairs that consist of a certificate
with an EC public key and its corresponding EC private key.

R=agl
CC=golang-dev
https://golang.org/cl/6776043
2012-11-16 19:33:59 +11:00
Dmitriy Vyukov
9b4aaa418f syscall: fix data races in LazyDLL/LazyProc
Reincarnation of https://golang.org/cl/6817086 (sent from another account).
It is ugly because sync.Once will cause allocation of a closure.
Fixes #4343.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/6856046
2012-11-16 12:06:48 +04:00
Marcel van Lohuizen
8b7ea6489c exp/locale/collate: changed implementation of Compare and CompareString to
compare incrementally. Also modified collation API to be more high-level
by removing the need for an explicit buffer to be passed as an argument.
This considerably speeds up Compare and CompareString.  This change also eliminates
the need to reinitialize the normalization buffer for each use of an iter. This
also significantly improves performance for Key and KeyString.

R=r, rsc
CC=golang-dev
https://golang.org/cl/6842050
2012-11-15 22:23:56 +01:00
Brad Fitzpatrick
0d0eff7165 os: add FileMode.IsRegular
API change.

R=golang-dev, r, iant, rsc
CC=golang-dev
https://golang.org/cl/6844048
2012-11-15 11:46:00 -08:00
Dmitriy Vyukov
27087022ce sync/atomic: fix race instrumentation
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6782075
2012-11-15 21:30:24 +04:00
Ian Lance Taylor
cc8bd8969f runtime/cgo: include <string.h> as needed so that strerror is declared
R=golang-dev, dave, jsing
CC=golang-dev
https://golang.org/cl/6847051
2012-11-14 22:04:03 -08:00
Robin Eklind
45b4867d0e strconv: Removed unnecessary use of goto. Made code easier to read.
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6855048
2012-11-14 09:42:48 -08:00
Joel Sing
63315c0af1 crypto/x509: add support for SEC1/EC private keys.
Add support for parsing SEC1 EC private keys and PKCS8 encapsulated
EC private key structures.

R=agl
CC=golang-dev
https://golang.org/cl/6767045
2012-11-15 03:39:00 +11:00
Joel Sing
8c96e6d740 debug/elf: fix offset for GNU version symbols
Since we no longer skip the first entry when reading a symbol table,
we no longer need to allow for the offset difference when processing
the GNU version symbols.

Unbreaks builds on Linux.

R=golang-dev, agl, iant
CC=golang-dev
https://golang.org/cl/6843057
2012-11-15 03:36:19 +11:00
Joel Sing
76689845e3 debug/elf: do not skip first symbol in the symbol table
Do not skip the first symbol in the symbol table. Any other indexes
into the symbol table (for example, indexes in relocation entries)
will now refer to the symbol following the one that was intended.

Add an object that contains debug relocations, which debug/dwarf
failed to decode correctly. Extend the relocation tests to cover
this case.

Note that the existing tests passed since the symbol following the
symbol that required relocation is also of type STT_SECTION.

Fixes #4107.

R=golang-dev, mikioh.mikioh, iant, iant
CC=golang-dev
https://golang.org/cl/6848044
2012-11-15 02:24:14 +11:00
Dmitriy Vyukov
063c13a34c runtime/race: more precise handling of finalizers
Currently race detector runtime just disables race detection in the finalizer goroutine.
It has false positives when a finalizer writes to shared memory -- the race with finalizer is reported in a normal goroutine that accesses the same memory.
After this change I am going to synchronize the finalizer goroutine with the rest of the world in racefingo(). This is closer to what happens in reality and so
does not have false positives.
And also add README file with instructions how to build the runtime.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6810095
2012-11-14 16:58:10 +04:00
Dmitriy Vyukov
51e89f59b2 runtime: add RaceRead/RaceWrite functions
It allows to catch e.g. a data race between atomic write and non-atomic write,
or Mutex.Lock() and mutex overwrite (e.g. mu = Mutex{}).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6817103
2012-11-14 16:51:23 +04:00
Andrew Gerrand
e33b9f7815 regexp: add simple package-level example
Update #4125

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6846045
2012-11-14 10:43:21 +01:00
Joel Sing
7f70bb5913 syscall: regenerate z-files for openbsd/386
Regenerate z-files for OpenBSD/386 on OpenBSD 5.2.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6844044
2012-11-14 19:06:12 +11:00
Brad Fitzpatrick
56bcef02fc net/http: add missing error checking reading trailers
This is a simplified version of earlier versions of this CL
and now only fixes obviously incorrect things, without
changing the locking on bodyEOFReader.

I'd like to see if this is sufficient before changing the
locking.

Update #4191

R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/6739055
2012-11-13 22:38:25 -08:00
Robert Griesemer
aa38801788 reflect: fix FieldByNameFunc
The existing algorithm did not properly propagate the type
count from one level to the next, and as a consequence it
missed collisions.

Properly propagate multiplicity (count) information to the
next level.

benchmark                old ns/op    new ns/op    delta
BenchmarkFieldByName1          182          180   -1.10%
BenchmarkFieldByName2         6273         6183   -1.43%
BenchmarkFieldByName3        49267        46784   -5.04%

Fixes #4355.

R=rsc
CC=golang-dev
https://golang.org/cl/6821094
2012-11-13 10:45:30 -08:00
Russ Cox
1120982590 reflect: add ArrayOf, ChanOf, MapOf, SliceOf
In order to add these, we need to be able to find references
to such types that already exist in the binary. To do that, introduce
a new linker section holding a list of the types corresponding to
arrays, chans, maps, and slices.

To offset the storage cost of this list, and to simplify the code,
remove the interface{} header from the representation of a
runtime type. It was used in early versions of the code but was
made obsolete by the kind field: a switch on kind is more efficient
than a type switch.

In the godoc binary, removing the interface{} header cuts two
words from each of about 10,000 types. Adding back the list of pointers
to array, chan, map, and slice types reintroduces one word for
each of about 500 types. On a 64-bit machine, then, this CL *removes*
a net 156 kB of read-only data from the binary.

This CL does not include the needed support for precise garbage
collection. I have created issue 4375 to track that.

This CL also does not set the 'algorithm' - specifically the equality
and copy functions - for a new array correctly, so I have unexported
ArrayOf for now. That is also part of issue 4375.

Fixes #2339.

R=r, remyoudompheng, mirtchovski, iant
CC=golang-dev
https://golang.org/cl/6572043
2012-11-13 13:06:29 -05:00
Russ Cox
9799a5a4fd runtime: allow up to 128 GB of allocated memory
Incorporates code from CL 6828055.

Fixes #2142.

R=golang-dev, iant, devon.odell
CC=golang-dev
https://golang.org/cl/6826088
2012-11-13 12:45:08 -05:00
Joel Sing
fc5e64cb8f syscall: regenerate z-files for openbsd/amd64
Regenerate z-files for OpenBSD/amd64 on OpenBSD 5.2.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6843045
2012-11-14 03:19:34 +11:00
Mikio Hara
306afc7725 net: consolidate common socket functions for Plan 9
This CL extends changeset 13126:fc4a62e14aba to Plan 9.

R=ality, golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6820124
2012-11-13 16:18:37 +09:00
Mikio Hara
677c6e6ee7 net: protocol specific listen functions return a proper local socket address
When a nil listener address is passed to some protocol specific
listen function, it will create an unnamed, unbound socket because
of the nil listener address. Other listener functions may return
invalid address error.

This CL allows to pass a nil listener address to all protocol
specific listen functions to fix above inconsistency. Also make it
possible to return a proper local socket address in case of a nil
listner address.

Fixes #4190.
Fixes #3847.

R=rsc, iant
CC=golang-dev
https://golang.org/cl/6525048
2012-11-13 12:56:28 +09:00
Mikio Hara
0ae80785e6 net: make LocalAddr on multicast UDPConn return a listening address
The package go.net/ipv4 allows to exist a single UDP listener
that join multiple different group addresses. That means that
LocalAddr on multicast UDPConn returns a first joined group
address is not desirable.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822108
2012-11-13 12:26:20 +09:00
Jeff R. Allen
7e7b89f7d0 net/textproto: faster header canonicalization with fewer allocations
By keeping a single copy of the strings that commonly show up
in headers, we can avoid one string allocation per header.

benchmark                  old ns/op    new ns/op    delta
BenchmarkReadMIMEHeader        19590        10824  -44.75%
BenchmarkUncommon               3168         1861  -41.26%

benchmark                 old allocs   new allocs    delta
BenchmarkReadMIMEHeader           32           25  -21.88%
BenchmarkUncommon                  5            5    0.00%

R=bradfitz, golang-dev, dave, rsc, jra
CC=golang-dev
https://golang.org/cl/6721055
2012-11-12 15:31:42 -08:00
Brad Fitzpatrick
73c67606e9 net/http: handle 413 responses more robustly
When HTTP bodies were too large and we didn't want to finish
reading them for DoS reasons, we previously found it necessary
to send a FIN and then pause before closing the connection
(which might send a RST) if we wanted the client to have a
better chance at receiving our error response. That was Issue 3595.

This issue adds the same fix to request headers which
are too large, which might fix the Windows flakiness
we observed on TestRequestLimit at:
http://build.golang.org/log/146a2a7d9b24441dc14602a1293918191d4e75f1

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6826084
2012-11-12 15:20:18 -08:00
David Symonds
80f4ff226f exp/types: avoid init race in check_test.go.
There was an init race between
	check_test.go:init
        universe.go:def
        use of Universe
and
	universe.go:init
        creation of Universe

The order in which init funcs are executed in a package is unspecified.
The test is not currently broken in the golang.org environment
because the go tool compiles the test with non-test sources before test sources,
but other environments may, say, sort the source files before compiling,
and thus trigger this race, causing a nil pointer panic.

R=gri
CC=golang-dev
https://golang.org/cl/6827076
2012-11-13 09:08:33 +11:00
Rick Arnold
c90739e41e encoding/json: skip unexpected null values
As discussed in issue 2540, nulls are allowed for any type in JSON so they should not result in an error during Unmarshal.
Fixes #2540.

R=rsc
CC=golang-dev
https://golang.org/cl/6759043
2012-11-12 15:35:11 -05:00
Roger Peppe
791fb978dd crypto/x509: implement EncryptPEMBlock
Arbitrary decisions: order of the arguments and the
fact it takes a block-type argument (rather than
leaving to user to fill it in later); I'm happy whatever
colour we want to paint it.

We also change DecryptPEMBlock so that it won't
panic when the IV has the wrong size.

R=agl, agl
CC=golang-dev
https://golang.org/cl/6820114
2012-11-12 15:31:23 +00:00
Roger Peppe
1e1733a9ac encoding/pem: write Proc-Type header first.
See RFC 1421, section 4.6.1.1

R=agl, agl
CC=golang-dev
https://golang.org/cl/6814104
2012-11-12 15:29:17 +00:00
David McLeish
20a1815833 archive/zip: Fix bounds check panic for ZIP files with a truncated extra header.
R=adg, dave
CC=gobot, golang-dev
https://golang.org/cl/6811080
2012-11-12 12:21:00 +01:00
Ian Lance Taylor
e9a3087e29 runtime, runtime/cgo: track memory allocated by non-Go code
Otherwise a poorly timed GC can collect the memory before it
is returned to the Go program.

R=golang-dev, dave, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/6819119
2012-11-10 11:19:06 -08:00