2.1.x 34c68ba8: freebsd 7.x: segfault/internal error in select()
I'm getting a segfault on exit after logging this to syslog: Exiting due to internal error: Failed in select: Invalid argument kernel: pid 87513 (radiusd), uid 133: exited on signal 11 select(2) indicates that EINVAL is returned when the timeout is invalid (being negative or too large). I modified the error message to include the value of "when" in lib/event.c. I then got: Exiting due to internal error: Failed in select: Invalid argument: wake 4sec, 1000000usec I suspected that tv_usec needs to be < USEC, so I kluged the code to subtract 1 from when.tv_usec if it's >= USEC. So far, I haven't had any more crashes. Commit d8084182 seems to be when this code was changed last, and I didn't have this problem before on 2.1.x. https://github.com/alandekok/freeradius-server/commit/d8084182bbec453712a96a... -- Russell A Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield
On 06/20/2011 04:56 PM, Russell Jackson wrote:
I'm getting a segfault on exit after logging this to syslog:
Exiting due to internal error: Failed in select: Invalid argument kernel: pid 87513 (radiusd), uid 133: exited on signal 11
select(2) indicates that EINVAL is returned when the timeout is invalid (being negative or too large). I modified the error message to include the value of "when" in lib/event.c. I then got:
Exiting due to internal error: Failed in select: Invalid argument: wake 4sec, 1000000usec
I suspected that tv_usec needs to be < USEC, so I kluged the code to subtract 1 from when.tv_usec if it's >= USEC. So far, I haven't had any more crashes.
Commit d8084182 seems to be when this code was changed last, and I didn't have this problem before on 2.1.x.
https://github.com/alandekok/freeradius-server/commit/d8084182bbec453712a96a...
Actually, after looking more closely, the segfault seems to happen whenever the server exits for any reason (including SIGTERM). I'll try to get a backtrace. -- Russell A Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield
On 06/20/2011 05:03 PM, Russell Jackson wrote:
On 06/20/2011 04:56 PM, Russell Jackson wrote:
I'm getting a segfault on exit after logging this to syslog:
Exiting due to internal error: Failed in select: Invalid argument kernel: pid 87513 (radiusd), uid 133: exited on signal 11
Actually, after looking more closely, the segfault seems to happen whenever the server exits for any reason (including SIGTERM). I'll try to get a backtrace.
Here's is the backtrace (attached) I get after starting radiusd up in gdb and sending SIGTERM to it. -- Russell A Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield
On 06/20/2011 04:56 PM, Russell Jackson wrote:
I'm getting a segfault on exit after logging this to syslog:
Exiting due to internal error: Failed in select: Invalid argument kernel: pid 87513 (radiusd), uid 133: exited on signal 11
select(2) indicates that EINVAL is returned when the timeout is invalid (being negative or too large). I modified the error message to include the value of "when" in lib/event.c. I then got:
Exiting due to internal error: Failed in select: Invalid argument: wake 4sec, 1000000usec
I suspected that tv_usec needs to be < USEC, so I kluged the code to subtract 1 from when.tv_usec if it's >= USEC. So far, I haven't had any more crashes.
Here's said kludge. diff --git a/src/lib/event.c b/src/lib/event.c index ab937a5..a9c361b 100644 --- a/src/lib/event.c +++ b/src/lib/event.c @@ -374,6 +374,17 @@ int fr_event_loop(fr_event_list_t *el) when.tv_sec = 0; when.tv_usec = 0; } + + /* + * Make sure time interval is within bounds + */ + if (when.tv_sec < 0) when.tv_sec = 0; + + if (when.tv_usec < 0) { + when.tv_usec = 0; + } else if (when.tv_usec >= USEC) { + when.tv_usec = USEC - 1; + } wake = &when; } else { @@ -388,8 +399,8 @@ int fr_event_loop(fr_event_list_t *el) read_fds = master_fds; rcode = select(maxfd + 1, &read_fds, NULL, NULL, wake); if ((rcode < 0) && (errno != EINTR)) { - fr_strerror_printf("Failed in select: %s", - strerror(errno)); + fr_strerror_printf("Failed in select: %s: wake %dsec, %dusec", + strerror(errno), wake->tv_sec, wake->tv_usec); el->dispatch = 0; return -1; } -- Russell A Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield
Russell Jackson wrote:
I'm getting a segfault on exit after logging this to syslog: ... I suspected that tv_usec needs to be < USEC, so I kluged the code to subtract 1 from when.tv_usec if it's >= USEC. So far, I haven't had any more crashes.
Commit d8084182 seems to be when this code was changed last, and I didn't have this problem before on 2.1.x.
Arg. It would have been nice to catch this before 2.1.11. I've pushed a fix. Can people please *try* the v2.1.x branch? Alan DeKok.
On 06/21/2011 12:07 AM, Alan DeKok wrote:
Russell Jackson wrote:
I'm getting a segfault on exit after logging this to syslog: ... I suspected that tv_usec needs to be< USEC, so I kluged the code to subtract 1 from when.tv_usec if it's>= USEC. So far, I haven't had any more crashes.
Commit d8084182 seems to be when this code was changed last, and I didn't have this problem before on 2.1.x.
Arg. It would have been nice to catch this before 2.1.11.
I've pushed a fix.
Can people please *try* the v2.1.x branch?
I've been running the tip of v2.1.x for a few days now with the fix, and it's running stably. I still get the segfault on exit however. -- Russell A. Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield
participants (2)
-
Alan DeKok -
Russell Jackson