When motion has an issue with a library (in my case, ffmpeg wasn't built with the right useflag and thus, didn't have the codec motion wanted), it tries to log the error message from the library. In motion.c:motion_log() ... /* If errno_flag is set, add on the library error message */ if (errno_flag) { strcat(buf, ": "); n += 2; /* * this is bad - apparently gcc/libc wants to use the non-standard GNU * version of strerror_r, which doesn't actually put the message into * my buffer :-(. I have put in a 'hack' to get around this. */ #if (defined(BSD)) strerror_r(errno_save, buf + n, sizeof(buf) - n); /* 2 for the ': ' */ #else strcat(buf, strerror_r(errno_save, msg_buf, sizeof(msg_buf))); #endif } ... He's right, glibc provides two distinct implementations of strerror_r(). Unfortunately, it looks like glibc 2.4 changed the one provided by default. According to 'man 3 strerror': "If no feature test macros are explicitly defined, then (since glibc 2.4) _POSIX_SOURCE is defined by default with the value 200112L, so that the XSI-compliant version of strerror_r() is provided by default." It doesn't appear as though motion is setting any feature_test macros, so this seems to result in the XSI-flavor being used on newer glibc (as is standard in gentoo). This variant returns 0 on success, not a string as the code is expecting. Thus, the code ends up: strcat(buf, 0) and that doesn't work out too well. The attached patch corrects the problem for gentoo, but it's not generic across all glibc versions. Reproducible: Always Steps to Reproduce: 1. Configure motion to use ffmpeg and give it an invalid/unsupported codec (ffmpeg_video_codec mpeg1 works since newer ffmpeg doesn't support mpeg1) 2. run 'motion -n' 3. Make some motion in front of camera. Actual Results: motion will segfault in strcat() called from motion_log(). Expected Results: No segfault, just a log message indicating the problem.
Created attachment 181607 [details, diff] Remove glibc special-case code since it's not applicable for newer glibc This is not a perfect patch since it won't support versions of glibc <2.4.
*** Bug 262370 has been marked as a duplicate of this bug. ***
This should be fixed in 3.2.11.1 (added today to Portage, sync in a hour or so if you want.) There's more conditionals for this part of code now.
(In reply to comment #3) > This should be fixed in 3.2.11.1 (added today to Portage, sync in a hour or so > if you want.) I agree. The code looks better and it appears to be working properly as well. Thanks for the update.