Skip to content

Commit fd53083

Browse files
committed
osx: Fix a possible segfault in uv__io_poll
In our build infrastructure, I've seen a lot of segfaults recently that were all only happening on OSX. Upon inspecting the coredumps, it appearded that all segfaults happened at the same instruction, and upon translating the assembly back to the source, I found that an array could be indexed with a -1 index before the index was checked to be not -1. I'm not 100% sure that this will fix our problems, but this check certainly appears fishy to me. XXX: this needs testing
1 parent 5e6e6be commit fd53083

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/unix/kqueue.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,10 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
167167
for (i = 0; i < nfds; i++) {
168168
ev = events + i;
169169
fd = ev->ident;
170-
w = loop->watchers[fd];
171-
172170
/* Skip invalidated events, see uv__platform_invalidate_fd */
173171
if (fd == -1)
174172
continue;
173+
w = loop->watchers[fd];
175174

176175
if (w == NULL) {
177176
/* File descriptor that we've stopped watching, disarm it. */

0 commit comments

Comments
 (0)