]> Cypherpunks repositories - gostls13.git/commit
runtime: initialize hash algs before typemap
authorDavid Crawshaw <crawshaw@golang.org>
Thu, 4 Aug 2016 17:09:29 +0000 (13:09 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Thu, 4 Aug 2016 17:39:05 +0000 (17:39 +0000)
commitf135c326402aaa757aa96aad283a91873d4ae124
tree791ec57eeaaba484bbd211c000a97eb4b9cc8465
parent50edddb7383a0e4aef990a085777f958c5d8a2b8
runtime: initialize hash algs before typemap

When compiling with -buildmode=shared, a map[int32]*_type is created for
each extra module mapping duplicate types back to a canonical object.
This is done in the function typelinksinit, which is called before the
init function that sets up the hash functions for the map
implementation. The result is typemap becomes unusable after
runtime initialization.

The fix in this CL is to move algorithm init before typelinksinit in
the runtime setup process. (For 1.8, we may want to turn typemap into
a sorted slice of types and use binary search.)

Manually tested on GOOS=linux with:

GOHOSTARCH=386 GOARCH=386 ./make.bash && \
go install -buildmode=shared std && \
cd ../test && \
go run run.go -linkshared

Fixes #16590

Change-Id: Idc08c50cc70d20028276fbf564509d2cd5405210
Reviewed-on: https://go-review.googlesource.com/25469
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/alg.go
src/runtime/proc.go