Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 762517 - media-sound/audacity-2.4.2-r2: fatal crash on start when jackd is running
Summary: media-sound/audacity-2.4.2-r2: fatal crash on start when jackd is running
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Professional Audio Applications Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-30 04:01 UTC by Stuart Longland
Modified: 2021-01-07 11:22 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge-info.txt,8.79 KB, text/plain)
2020-12-30 04:03 UTC, Stuart Longland
Details
Clicking "rec" in Audacity (audacity-jack-rec.png,40.15 KB, image/png)
2020-12-30 22:49 UTC, Stuart Longland
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Longland 2020-12-30 04:01:55 UTC
Essentially, it's impossible to run `jackd` and `audacity` at the same time.  If `jackd` is running, the embedded PortAudio library tries to probe `jackd` then falls on its face.

RC=0 stuartl@rikishi ~ $ audacity /tmp/money-for-nothing.wav 

(audacity:213010): Gtk-WARNING **: 13:51:39.436: A floating object was finalized. This means that someone
called g_object_unref() on an object that had only a floating
reference; the initial floating reference is not owned by anyone
and must be removed with g_object_ref_sink().
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.3.2-r1/work/alsa-lib-1.2.3.2/src/pcm/pcm_dmix.c:1090:(snd_pcm_dmix_open) unable to open slave
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.3.2-r1/work/alsa-lib-1.2.3.2/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.3.2-r1/work/alsa-lib-1.2.3.2/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.3.2-r1/work/alsa-lib-1.2.3.2/src/pcm/pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.3.2-r1/work/alsa-lib-1.2.3.2/src/pcm/pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib /var/tmp/portage/media-plugins/alsa-plugins-1.2.2/work/alsa-plugins-1.2.2/a52/pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
ALSA lib /var/tmp/portage/media-plugins/alsa-plugins-1.2.2/work/alsa-plugins-1.2.2/usb_stream/pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib /var/tmp/portage/media-plugins/alsa-plugins-1.2.2/work/alsa-plugins-1.2.2/usb_stream/pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.3.2-r1/work/alsa-lib-1.2.3.2/src/pcm/pcm_shm.c:849:(_snd_pcm_shm_open) pcm is not defined
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.3.2-r1/work/alsa-lib-1.2.3.2/src/pcm/pcm_shm.c:849:(_snd_pcm_shm_open) pcm is not defined
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.3.2-r1/work/alsa-lib-1.2.3.2/src/pcm/pcm_dmix.c:1090:(snd_pcm_dmix_open) unable to open slave
Expression 'stream->playback.pcm' failed in '/var/tmp/portage/media-sound/audacity-2.4.2-r1/work/audacity-Audacity-2.4.2/lib-src/portaudio-v19/src/hostapi/alsa/pa_linux_alsa.c', line: 4628
Expression 'stream->playback.pcm' failed in '/var/tmp/portage/media-sound/audacity-2.4.2-r1/work/audacity-Audacity-2.4.2/lib-src/portaudio-v19/src/hostapi/alsa/pa_linux_alsa.c', line: 4628
[AVAudioResampleContext @ 0x55ef36548800] Value 160.000000 for parameter 'phase_shift' out of range [0 - 30]
Expression 'stream->playback.pcm' failed in '/var/tmp/portage/media-sound/audacity-2.4.2-r1/work/audacity-Audacity-2.4.2/lib-src/portaudio-v19/src/hostapi/alsa/pa_linux_alsa.c', line: 4628
Expression 'stream->playback.pcm' failed in '/var/tmp/portage/media-sound/audacity-2.4.2-r1/work/audacity-Audacity-2.4.2/lib-src/portaudio-v19/src/hostapi/alsa/pa_linux_alsa.c', line: 4628
Expression 'stream->playback.pcm' failed in '/var/tmp/portage/media-sound/audacity-2.4.2-r1/work/audacity-Audacity-2.4.2/lib-src/portaudio-v19/src/hostapi/alsa/pa_linux_alsa.c', line: 4628
audacity: ../common/JackGraphManager.cpp:48: void Jack::JackGraphManager::AssertPort(jack_port_id_t): Assertion `port_index < fPortMax' failed.
audacity: ../common/JackGraphManager.cpp:48: void Jack::JackGraphManager::AssertPort(jack_port_id_t): Assertion `port_index < fPortMax' failed.
Aborted

It used to work just fine, recent updates have broken it.

Reproducible: Always

Steps to Reproduce:
1. Start `jackd` (I do so via `qjackctl`, but direct should reproduce the issue too)
2. Attempt to start `audacity` (with or without command line arguments… I was trying to edit out the homophobic verses of "Dire Straits - Money For Nothing" at the time, but even without arguments it crashed the same way.)
Actual Results:  
It crashed: see above.

Expected Results:  
It should have worked as normal.

Same result regardless of the value of the `jack` USE-flag.  I tried building with USE=-jack to try and avoid that code path, `audacity` sees the JACK libs and builds against it anyway.  Tried re-building portaudio (Audacity seems to bundle its own) and Audacity.

Other software (e.g. Twinkle SIP client, PulseAudio) work fine with JACK.

RC=0 stuartl@rikishi ~ $ emerge -pv alsa-lib alsa-plugins audacity portaudio jack2

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] media-libs/alsa-lib-1.2.3.2-r1::gentoo  USE="doc python thread-safety -alisp -debug" ABI_X86="32 (64) (-x32)" PYTHON_SINGLE_TARGET="python3_8 -python3_6 -python3_7" 1,015 KiB
[ebuild   R    ] media-sound/jack2-1.9.16:2::gentoo  USE="alsa classic dbus doc libsamplerate opus pam readline sndfile -ieee1394 -metadata" ABI_X86="32 (64) (-x32)" PYTHON_SINGLE_TARGET="python3_8 -python3_6 -python3_7 -python3_9" 952 KiB
[ebuild   R    ] media-libs/portaudio-19.06.00-r1::gentoo  USE="alsa cxx doc jack -debug -oss -static-libs" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] media-plugins/alsa-plugins-1.2.2::gentoo  USE="ffmpeg jack libsamplerate mix pulseaudio speex usb_stream -arcam_av -debug -oss" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] media-sound/audacity-2.4.2-r1::gentoo  USE="alsa doc ffmpeg flac jack* ladspa mad ogg portmixer twolame vorbis vst -id3tag -lv2 -oss -portmidi -portsmf -sbsms -vamp" 0 KiB

Total: 5 packages (5 reinstalls), Size of downloads: 1,967 KiB
Comment 1 Stuart Longland 2020-12-30 04:03:12 UTC
Created attachment 680245 [details]
emerge --info
Comment 2 Stuart Longland 2020-12-30 04:07:49 UTC
My `.asoundrc`, in case it matters:

pcm.!default {
        type plug
        slave { pcm "jack" }
}

pcm.jack {
        type jack
        playback_ports {
                0 system:playback_1
                1 system:playback_2
        }
        capture_ports {
                0 system:capture_1
                1 system:capture_1
        }
}

pcm.shmtest {
        type shm                # Shared memory PCM
        server test      # Server name
}

server.test {
        host 127.0.0.1
        port 65432
}


(Yes, there's some stuff I need to remove, notably the "shm" stuff.  I was trying to figure out what the "shm" server did.)

ALSA playback devices:
RC=0 stuartl@rikishi ~ $ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
pipewire
    PipeWire Sound Server
pulse
    PulseAudio Sound Server
speex
    Plugin using Speex DSP (resample, agc, denoise, echo, dereverb)
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
sysdefault:CARD=PCH
    HDA Intel PCH, ALC269VC Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    Front output / input
surround21:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VC Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
hdmi:CARD=PCH,DEV=0
    HDA Intel PCH, HDMI 0
    HDMI Audio Output
hdmi:CARD=PCH,DEV=1
    HDA Intel PCH, HDMI 1
    HDMI Audio Output
usbstream:CARD=PCH
    HDA Intel PCH
    USB Stream Output
sysdefault:CARD=ATHG1WL
    ATH-G1WL, USB Audio
    Default Audio Device
front:CARD=ATHG1WL,DEV=0
    ATH-G1WL, USB Audio
    Front output / input
surround21:CARD=ATHG1WL,DEV=0
    ATH-G1WL, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=ATHG1WL,DEV=0
    ATH-G1WL, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=ATHG1WL,DEV=0
    ATH-G1WL, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=ATHG1WL,DEV=0
    ATH-G1WL, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=ATHG1WL,DEV=0
    ATH-G1WL, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=ATHG1WL,DEV=0
    ATH-G1WL, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=ATHG1WL,DEV=0
    ATH-G1WL, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=ATHG1WL
    ATH-G1WL
    USB Stream Output
sysdefault:CARD=CODEC
    USB Audio CODEC, USB Audio
    Default Audio Device
front:CARD=CODEC,DEV=0
    USB Audio CODEC, USB Audio
    Front output / input
surround21:CARD=CODEC,DEV=0
    USB Audio CODEC, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=CODEC,DEV=0
    USB Audio CODEC, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=CODEC,DEV=0
    USB Audio CODEC, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=CODEC,DEV=0
    USB Audio CODEC, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=CODEC,DEV=0
    USB Audio CODEC, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=CODEC,DEV=0
    USB Audio CODEC, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=CODEC,DEV=0
    USB Audio CODEC, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=CODEC
    USB Audio CODEC
    USB Stream Output

hw:ATHG1WL (AudioTechnica ATH-GW1L USB headset) is the device being used with JACK.
Comment 3 Ionen Wolkens gentoo-dev 2020-12-30 08:30:36 UTC
Tried myself while jackd is running (jack2) with your .asoundrc.

With USE="jack alsa" it did spit out similar warnings but still started
fine (no assert messages), and with "jack -alsa" cleanly worked and using
jackd directly.

I don't use usbstream though, maybe related.
Comment 4 Stuart Longland 2020-12-30 08:35:05 UTC
To the best of my knowledge, I'm not using `usbstream` either. (Why would I when there's `snd-usb-audio`?)

I haven't tried with `alsa` disabled, I guess I'll try that next.
Comment 5 Stuart Longland 2020-12-30 22:49:51 UTC
Created attachment 680332 [details]
Clicking "rec" in Audacity

Well the good news is with USE="-alsa jack", it does start… however, clicking "Record" has me confused!
Comment 6 Stuart Longland 2021-01-07 10:58:46 UTC
So, a bit of digging around:

audacity: ../common/JackGraphManager.cpp:48: void Jack::JackGraphManager::AssertPort(jack_port_id_t): Assertion `port_index < fPortMax' failed.
audacity: ../common/JackGraphManager.cpp:48: void Jack::JackGraphManager::AssertPort(jack_port_id_t): Assertion `port_index < fPortMax' failed.

Those two lines are emitted from this file:

jack2-1.9.16/common/JackGraphManager.cpp:
    44  void JackGraphManager::AssertPort(jack_port_id_t port_index)
    45  {
    46      if (port_index >= fPortMax) {
    47          jack_log("JackGraphManager::AssertPort port_index = %ld", port_index);
    48          assert(port_index < fPortMax);
    49      }
    50  }

Clearly, fPortMax is smaller than expected, or port_index is above the set maximum.  Question is, where do these values come from?

fPortMax is set by the constructor:
    66  JackGraphManager::JackGraphManager(int port_max)
    67  {
    68      assert(port_max <= PORT_NUM_MAX);
    69
    70      for (int i = 0; i < port_max; i++) {
    71          fPortArray[i].Release();
    72      }
    73
    74      fPortMax = port_max;
    75  }
… which is called here:
    52  JackGraphManager* JackGraphManager::Allocate(int port_max)
    53  {
    54      // Using "Placement" new
    55      void* shared_ptr = JackShmMem::operator new(sizeof(JackGraphManager) + port_max * sizeof(JackPort));
    56      return new(shared_ptr) JackGraphManager(port_max);
    57  }

This seems to have just one caller, jack2-1.9.16/common/JackServer.cpp line 56:
    43  //----------------
    44  // Server control 
    45  //----------------
    46  JackServer::JackServer(bool sync, bool temporary, int timeout, bool rt, int priority, int port_max, bool verbose, jack_timer_type_t clock, char self_connect_mode, const char* server_name)
    47  {
    48      if (rt) {
    49          jack_info("JACK server starting in realtime mode with priority %ld", priority);
    50      } else {
    51          jack_info("JACK server starting in non-realtime mode");
    52      }
    53
    54      jack_info("self-connect-mode is \"%s\"", jack_get_self_connect_mode_description(self_connect_mode));
    55
    56      fGraphManager = JackGraphManager::Allocate(port_max);

… which is called in jack2-1.9.16/common/JackServerGlobals.cpp (line 55):
    41  int JackServerGlobals::Start(const char* server_name,
    42                               jack_driver_desc_t* driver_desc,
    43                               JSList* driver_params,
    44                               int sync,
    45                               int temporary,
    46                               int time_out_ms,
    47                               int rt,
    48                               int priority,
    49                               int port_max,
    50                               int verbose,
    51                               jack_timer_type_t clock,
    52                               char self_connect_mode)
    53  {
    54      jack_log("Jackdmp: sync = %ld timeout = %ld rt = %ld priority = %ld verbose = %ld ", sync, time_out_ms, rt, priority, verbose);
    55      new JackServer(sync, temporary, time_out_ms, rt, priority, port_max, verbose, clock, self_connect_mode, server_name); 

So, it could be a command line argument that previously didn't give problems, but is now tickling things the wrong way.  I'm not sure though whether it is something `qjackctl` is passing `jackd` when it starts it (curiously, I can't even *see* `jackd` in the process tree even though it is clearly running) or whether Audacity is the guilty party at this point.

PulseAudio also works via Jack, and there, I don't have problems.  I have a week-daily session with work colleagues on Slack using jackd, and that works without a hitch.  It's just Audacity that gives me problems, I'll have to see if it's Audacity itself or its version of PortAudio (since it seems to bring its own).
Comment 7 Stuart Longland 2021-01-07 11:05:56 UTC
<?xml version="1.0"?>
<!--
JACK settings, as persisted by D-Bus object.
You probably don't want to edit this because
it will be overwritten next time jackdbus saves.
-->
<!-- Thu Jan  7 21:01:53 2021 -->
<jack>
 <engine>
  <option name="driver">alsa</option>
  <option name="realtime">true</option>
  <option name="realtime-priority">10</option>
  <option name="verbose">false</option>
  <option name="clock-source">0</option>
  <option name="port-max">2048</option>
  <option name="sync">false</option>
  <option name="self-connect-mode"> </option>
 </engine>
 <drivers>
  <driver name="alsarawmidi">
  </driver>
  <driver name="alsa">
   <option name="device">hw:ATHG1WL</option>
   <option name="capture">hw:ATHG1WL</option>
   <option name="playback">hw:ATHG1WL</option>
   <option name="rate">48000</option>
   <option name="period">1024</option>
   <option name="nperiods">3</option>
   <option name="hwmeter">false</option>
   <option name="duplex">true</option>
   <option name="softmode">false</option>
   <option name="monitor">false</option>
   <option name="dither">n</option>
   <option name="shorts">true</option>
  </driver>
  <driver name="proxy">
  </driver>
  <driver name="netone">
  </driver>
  <driver name="net">
  </driver>
  <driver name="loopback">
  </driver>
  <driver name="dummy">
   <option name="rate">48000</option>
   <option name="period">1024</option>
   <option name="wait">21333</option>
  </driver>
 </drivers>
 <internals>
  <internal name="audioadapter">
  </internal>
  <internal name="netadapter">
  </internal>
  <internal name="profiler">
  </internal>
  <internal name="netmanager">
  </internal>
 </internals>
</jack>

^ My /home/stuartl/.config/jack/conf.xml… suggests fPortMax is being set to 2048… that ought to be enough I think!
Comment 8 Stuart Longland 2021-01-07 11:22:11 UTC
Okay… I got Audacity to start properly.

- I could not find `jackd`, but did note that `jackdbus` was running.  So, I killed it.  (initially with -TERM, then -QUIT, finally -KILL when it didn't take the hint).
- `pulseaudio` took great umbrage to this, spinning CPU wildly and gobbling RAM like crazy.  So it too, got the `kill` treatment.
- `pulseaudio` re-spawns.
- I restart JACK via `qjackctl` for good measure.

Now, Audacity starts, and seems to work.  I think it might be a case of "turn it off, and back on again"… I shall keep an eye on this.