2007-08-12 19:45:20

by Jim Carter

[permalink] [raw]
Subject: [Bluez-devel] a2dpd_ipc.c infinite loop stomped

Versions:
SuSE 10.2, kernel 2.6.18
bluez-utils 3.7
plugz from CVS on 2007-08-05

If ~/.a2dprc is configured with the various cmds nonexecutable, e.g.
cmdplay=nonexistent --play
then upon the corresponding AVRCP event (such as when the headphone
connects), a2dpd will fork a process that uses 100% of CPU time and
drives Pulseaudio crazy (also 100% CPU, on a dual core machine),
eventually killing it.

The reason is this: In a2dpd_ipc.c, subroutine async_run_process
forks and the child execs (execvp) the command, which fails, so
execvp returns. The child then does a DBG printout (if enabled) and
returns from the subroutine back to the main loop where the parent is
also executing. Things go downhill from there.

The attached patch makes the child exit in this case. I also "improved"
some of the error messages so you can recognize spurious whitespace.
I wish I could give an unconditional error printout, i.e. not only if
debug printout is turned on, but I didn't see a relevant macro.

James F. Carter Voice 310 825 2897 FAX 310 206 6673
UCLA-Mathnet; 6115 MSA; 405 Hilgard Ave.; Los Angeles, CA, USA 90095-1555
Email: [email protected] http://www.math.ucla.edu/~jimc (q.v. for PGP key)


--- plugz/alsa-plugins/a2dpd/a2dpd_ipc.c.orig 2007-05-23 06:14:41.000000000 -0700
+++ plugz/alsa-plugins/a2dpd/a2dpd_ipc.c 2007-08-12 11:33:48.000000000 -0700
@@ -433,8 +433,8 @@
char* argv[8];
int i = 0, status = 0;
strncpy(command, cmd, sizeof(command));
- DBG("Command is %s", command);
command[sizeof(command)-1]= '\0';
+ DBG("Command is '%s'", command);
memset(argv, 0, sizeof(argv));
argv[0] = command;

@@ -451,7 +451,7 @@
}

for(i=0; i < ARRAY_SIZE(argv); i++) {
- DBG("argv[%d] = %s", i, argv[i]?argv[i]:"NULL");
+ DBG("argv[%d] = '%s'", i, argv[i]?argv[i]:"NULL");
if(!argv[i]) break;
}

@@ -466,12 +466,12 @@

// Replace children with new process
i = execvp(command, argv);
- DBG("execlp failed %s=%d (errno=%d:%s)", cmd, i, errno, strerror(errno));
- break;
+ DBG("execvp failed (%d), command='%s' (errno=%d:%s)", i, cmd, errno, strerror(errno));
+ exit(EXIT_FAILURE);
case -1:
// failed
- DBG("Fork %s failed", cmd);
- break;
+ DBG("Fork failed, command='%s' (errno=%d:%s)", cmd, errno, strerror(errno));
+ exit(EXIT_FAILURE);
default:
DBG("Forked %s", cmd);
// Parent wait for completion if asked

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel