Summary
All socketpairs are stored in pipes, but the benchmark reaches exit(0) without calling evutil_closesocket() for either endpoint.
Affected code
- Repository commit:
477033f938fd47dfecde43c82257cd286d9fa38e
- File:
benchmark/ioevent/libevent/libevent_ioevent_bench.c
- Original scanner location: line 189
Evidence
Source: benchmark/ioevent/libevent/libevent_ioevent_bench.c lines 175-194
175:
176: events = calloc(num_pipes, sizeof(struct event));
177: pipes = calloc(num_pipes * 2, sizeof(evutil_socket_t));
178: if (events == NULL || pipes == NULL) {
179: perror("malloc");
180: exit(1);
181: }
182:
183: event_init();
184:
185: for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) {
186: #ifdef USE_PIPES
187: if (pipe(cp) == -1) {
188: #else
189: if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, cp) == -1) {
190: #endif
191: perror("pipe");
192: exit(1);
193: }
194: }
Source: benchmark/ioevent/libevent/libevent_ioevent_bench.c lines 196-208
196: long sum = 0;
197: for (i = 0; i < 25; i++) {
198: tv = run_once();
199: if (tv == NULL)
200: exit(1);
201: fprintf(stdout, "%ld\n",
202: tv->tv_sec * 1000000L + tv->tv_usec);
203: sum += tv->tv_sec * 1000000L + tv->tv_usec;
204: }
205: fprintf(stdout, "%s Average : %ld\n", argv[0], sum/25);
206:
207: exit(0);
208: }
Impact
The default run leaves 200 descriptors open, and -n can make the leak large enough to hit descriptor limits during setup or wrapper-driven repeated runs.
Summary
All socketpairs are stored in
pipes, but the benchmark reachesexit(0)without callingevutil_closesocket()for either endpoint.Affected code
477033f938fd47dfecde43c82257cd286d9fa38ebenchmark/ioevent/libevent/libevent_ioevent_bench.cEvidence
Source: benchmark/ioevent/libevent/libevent_ioevent_bench.c lines 175-194
Source: benchmark/ioevent/libevent/libevent_ioevent_bench.c lines 196-208
Impact
The default run leaves 200 descriptors open, and
-ncan make the leak large enough to hit descriptor limits during setup or wrapper-driven repeated runs.