Commit ae026741 by Ian Lance Taylor

re PR go/61303 (gccgo: segfault, regression since 4.8.2)

	PR go/61303
    runtime: don't overallocate in select code
    
    If we've already allocated an fd_set, don't allocate another one.
    
    Also, don't bother to read from rdwake if it wasn't returned in select.
    
    Fixes https://gcc.gnu.org/PR61303.
    
    Reviewed-on: https://go-review.googlesource.com/17243

From-SVN: r230922
parent 1a5d8ff6
0d979f0b860cfd879754150e0ae5e1018b94d7c4 81eb6a3f425b2158c67ee32c0cc973a72ce9d6be
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -135,6 +135,8 @@ runtime_netpoll(bool block) ...@@ -135,6 +135,8 @@ runtime_netpoll(bool block)
byte b; byte b;
struct stat st; struct stat st;
allocatedfds = false;
retry: retry:
runtime_lock(&selectlock); runtime_lock(&selectlock);
...@@ -146,11 +148,13 @@ runtime_netpoll(bool block) ...@@ -146,11 +148,13 @@ runtime_netpoll(bool block)
} }
if(inuse) { if(inuse) {
if(!allocatedfds) {
prfds = runtime_SysAlloc(4 * sizeof fds, &mstats.other_sys); prfds = runtime_SysAlloc(4 * sizeof fds, &mstats.other_sys);
pwfds = prfds + 1; pwfds = prfds + 1;
pefds = pwfds + 1; pefds = pwfds + 1;
ptfds = pefds + 1; ptfds = pefds + 1;
allocatedfds = true; allocatedfds = true;
}
} else { } else {
prfds = &grfds; prfds = &grfds;
pwfds = &gwfds; pwfds = &gwfds;
...@@ -216,7 +220,7 @@ runtime_netpoll(bool block) ...@@ -216,7 +220,7 @@ runtime_netpoll(bool block)
mode = 'r' + 'w'; mode = 'r' + 'w';
--c; --c;
} }
if(i == rdwake) { if(i == rdwake && mode != 0) {
while(read(rdwake, &b, sizeof b) > 0) while(read(rdwake, &b, sizeof b) > 0)
; ;
continue; continue;
......
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