Commit 53e139c7 authored by Ian Lance Taylor's avatar Ian Lance Taylor

runtime: put lockorder before pollorder in Select memory block.

Otherwise lockorder may be misaligned, since lockorder is a
list of pointers and pollorder is a list of uint16.
Discovered running gccgo (which uses a modified copy of this
code) on SPARC.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5655054
parent f91cc3bd
...@@ -586,6 +586,10 @@ newselect(int32 size, Select **selp) ...@@ -586,6 +586,10 @@ newselect(int32 size, Select **selp)
if(size > 1) if(size > 1)
n = size-1; n = size-1;
// allocate all the memory we need in a single allocation
// start with Select with size cases
// then lockorder with size entries
// then pollorder with size entries
sel = runtime·mal(sizeof(*sel) + sel = runtime·mal(sizeof(*sel) +
n*sizeof(sel->scase[0]) + n*sizeof(sel->scase[0]) +
size*sizeof(sel->lockorder[0]) + size*sizeof(sel->lockorder[0]) +
...@@ -593,8 +597,8 @@ newselect(int32 size, Select **selp) ...@@ -593,8 +597,8 @@ newselect(int32 size, Select **selp)
sel->tcase = size; sel->tcase = size;
sel->ncase = 0; sel->ncase = 0;
sel->pollorder = (void*)(sel->scase + size); sel->lockorder = (void*)(sel->scase + size);
sel->lockorder = (void*)(sel->pollorder + size); sel->pollorder = (void*)(sel->lockorder + size);
*selp = sel; *selp = sel;
if(debug) if(debug)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment