Hi Dmitry,
I've played with this a little bit, and I believe I've fixed it.
First of all, there is a problem with the way I am running JACK on my
system. This is causing the JACK error callback to be called within
PortAudio.
With your suggestion of turning off -O2 and adding -g3, I was able to get a
backtrace: http://pastebin.com/AknP0DFL
<http://pastebin.com/AknP0DFL>It doesn't make much sense that ALSA should be
the cause of this, so I added a 'continue;' in the BuildDeviceList loop for
ALSA right before it calls snd_ctl_open. This helped reveal where the memory
corruption is coming from: http://pastebin.com/s03VwRKF
<http://pastebin.com/s03VwRKF>The segfault is coming from JackErrorCallback.
If I put a return in that method before it copies the error message into the
jackErr_ variable, the program is able to continue indefinitely. As a test,
I PA_DEBUG'd the error message to ensure that it was not an invalid string.
The only reason I see that realloc would cause a segfault is if it was
passed a bad pointer in the first place. In the Terminate method of the JACK
hostapi, the last thing it does is free the jackErr_ variable, but it does
not reset it to NULL. If the JACK hostapi were re-initialized, then the
previously free'd pointer will still be there pointing to an invalid memory
location. I believe this is the root cause of the segfaults I am seeing. If
I set the jackErr_ variable to NULL after free'ing it, my test program is
able to run indefinitely without crashing. After removing my 'continue'
change to the ALSA hostapi, the problem remains solved.
Thanks,
RJ Ryan
On Mon, Sep 20, 2010 at 12:39 PM, Dmitry Kostjuchenko <
[email protected]> wrote:
> Hi RJ,
>
> Such crash could mean memory corruption, may be, in that area where PA is
> trying to open Jack/Alsa device and gets error by one of system APIs. Could
> you modify flags inside Makefile to input more debugging info during
> compile-time? by changing -g to -g3 and removing all -O, -O2 flags. May be
> then we could get a backtrace from gdb. I am not very much a linux expert
> but it would be great to try running crashing example under valgrind (
> http://www.cprogramming.com/debugging/valgrind.html) may be it could help
> to find the place of exception.
>
> Best regards,
> Dmitry.
>
> ----- Original Message ----- From: RJ Ryan
> To: Portaudio Mailing List
> Sent: Saturday, September 18, 2010 9:18 AM
> Subject: [Portaudio] Segfault using JACK while rapidly calling
> Pa_Initializefollowed by Pa_Terminate
>
>
>
> Hello all,
>
>
> Sorry if this ends up being a double-post. I can never remember which email
> address of mine is signed up to this list, and my first was held for
> moderator approval.
>
>
> While debugging a segfault-on-startup issue with Mixxx (
> https://bugs.launchpad.net/mixxx/+bug/505643) I think I have found an
> issue with the PortAudio JACK backend.
>
>
> The long and short of that bug is that while starting Mixxx we help the
> user configure their audio device. If a certain device does not open we
> present a help dialog which lets them jump to the preferences where they can
> reconfigure their output device. One of our users reported a segfault during
> this process while using JACK.
>
>
> I've found using r1539 (latest) of the PortAudio SVN, the following simple
> program segfaults while I have JACK running like so:
>
>
> pasuspender jackd -- -d alsa -d hw:0
>
>
> I use pasuspender to tell PulseAudio to release my ALSA devices.
>
>
> I am on x86_64 using Ubuntu 10.04 and I have enabled the ALSA, OSS, and
> JACK backends. I configured PortAudio like so:
>
>
> ./configure --with-alsa --with-jack --with-oss --enable-debug-output
>
>
> Here is the test program (adapted from patest_sine):
>
>
> PaError err;
> while(1) {
> fprintf(stderr, "Initialize\n");
> err = Pa_Initialize();
> if (err == paNoError) {
> fprintf(stderr, "Terminate\n");
> Pa_Terminate();
> } else {
> fprintf( stderr, "Error number: %d\n", err );
> fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
> }
> }
>
>
> When I run this, if I am not running JACK, the while loop continues
> indefinitely with no errors. The moment I start jackd, the program segfaults
> with this glibc error:
>
>
> *** glibc detected ***
> /home/rryan/Code/portaudio-trunk/bin/.libs/patest_sine: corrupted
> double-linked list: 0x00000000006258e0 ***
> Inconsistency detected by ld.so: dl-open.c: 221: dl_open_worker: Assertion
> `_dl_debug_initialize (0, args->nsid)->r_state == RT_CONSISTENT' failed!
>
>
> There is no backtrace available, I assume because the stack is corrupted. A
> copy of a GDB session with me running this is here:
> http://pastebin.ca/1943326
>
>
> There is one other failure mode. If I run the program without JACK running,
> then it works fine. The moment I start JACK as above, I get a different
> segfault: http://pastebin.ca/1943325
> Note the JACK API error immediately preceding the segfault.
>
>
> I hope this is enough information to go after this.
>
>
> Thanks very much,
> RJ Ryan
>
>
>
> _______________________________________________
> Portaudio mailing list
> [email protected]
> http://music.columbia.edu/mailman/listinfo/portaudio
> _______________________________________________
> Portaudio mailing list
> [email protected]
> http://music.columbia.edu/mailman/listinfo/portaudio
>
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel