rust-portaudio icon indicating copy to clipboard operation
rust-portaudio copied to clipboard

Segmentation fault when running examples on Ubuntu 14.04

Open Paul-Andre opened this issue 9 years ago • 3 comments

When running the example non_blocking, I get:

ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
PortAudio:
version: 1899
version text: Ok("PortAudio V19-devel (built Feb 25 2014 21:08:14)")
host count: 2
default host: Some(
    HostApiInfo {
        struct_version: 1,
        host_type: ALSA,
        name: "ALSA",
        device_count: 8,
        default_input_device: Some(
            DeviceIndex(
                6
            )
        ),
        default_output_device: Some(
            DeviceIndex(
                6
            )
        )
    }
)
Default input device info: DeviceInfo {
    struct_version: 2,
    name: "default",
    host_api: 0,
    max_input_channels: 128,
    max_output_channels: 128,
    default_low_input_latency: 0.021333333333333333,
    default_low_output_latency: 0.021333333333333333,
    default_high_input_latency: 0.021333333333333333,
    default_high_output_latency: 0.021333333333333333,
    default_sample_rate: 48000
}
Default output device info: DeviceInfo {
    struct_version: 2,
    name: "default",
    host_api: 0,
    max_input_channels: 128,
    max_output_channels: 128,
    default_low_input_latency: 0.021333333333333333,
    default_low_output_latency: 0.021333333333333333,
    default_high_input_latency: 0.021333333333333333,
    default_high_output_latency: 0.021333333333333333,
    default_sample_rate: 48000
}
Segmentation fault (core dumped)

When doing a stacktrace with gdb:

(gdb) backtrace
#0  0xb7f977d4 in ?? () from /usr/lib/i386-linux-gnu/libportaudio.so.2
#1  0xb7f97d4c in Pa_IsFormatSupported ()
   from /usr/lib/i386-linux-gnu/libportaudio.so.2
#2  0x8001bd9a in portaudio::is_format_supported (maybe_input_parameters=..., 
    maybe_output_parameters=..., sample_rate=44100) at src/lib.rs:661
#3  0x80005f5b in non_blocking::PortAudio::is_duplex_format_supported<f32,f32>
    (self=0xbfffeed0, in_params=..., out_params=..., sample_rate=44100)
    at src/lib.rs:404
#4  0x80004a51 in non_blocking::run () at examples/non_blocking.rs:50
#5  0x80003653 in non_blocking::main () at examples/non_blocking.rs:18
#6  0x8002797b in sys_common::unwind::try::try_fn::h10144795978809605109 ()
#7  0x80025268 in __rust_try ()
#8  0x8002743a in rt::lang_start::he74f855a6a899d05rKz ()
#9  0x8000552e in main () at ../src/libcore/result.rs:29

A similar thing happens to blocking.rs, saw.rs, sine.rs, but not on devices.rs or hosts.rs.

I suspect that some struct passed to the C functions isn't correct.

Paul-Andre avatar May 17 '16 00:05 Paul-Andre

Hmm this might have something to do with not having the linux ALSA extension header bindings set up yet. We only have bindings to the general portaudio.h so far. #22 is the related issue.

Would you mind running the devices.rs and hosts.rs examples and posting their output to here?

I only have OS X available to me at the moment, but I'm hoping to use rust-portaudio w/ ALSA for some embedded audio stuff mid-next month which is when I was planning on having a go at this. It shouldn't be too tricky to run rust-bindgen on the necessary header and set it up (I'm happy for someone else to beat me to it).

mitchmindtree avatar May 19 '16 05:05 mitchmindtree

I can't get into the computer on which I've initially done that, but on another computer, also running Ubuntu 14.04, but running Pulseaudio, I get the same error and I get:

When running non_blocking using cargo:

     Running `target/debug/examples/non_blocking`
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
jack_client_new: deprecated
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
jack_client_new: deprecated
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
PortAudio:
version: 1899
version text: Ok("PortAudio V19-devel (built Feb 25 2014 21:08:14)")
host count: 2
default host: Some(
    HostApiInfo {
        struct_version: 1,
        host_type: ALSA,
        name: "ALSA",
        device_count: 8,
        default_input_device: Some(
            DeviceIndex(
                7
            )
        ),
        default_output_device: Some(
            DeviceIndex(
                7
            )
        )
    }
)
Default input device info: DeviceInfo {
    struct_version: 2,
    name: "default",
    host_api: 0,
    max_input_channels: 32,
    max_output_channels: 32,
    default_low_input_latency: 0.008707482993197279,
    default_low_output_latency: 0.008707482993197279,
    default_high_input_latency: 0.034829931972789115,
    default_high_output_latency: 0.034829931972789115,
    default_sample_rate: 44100
}
Default output device info: DeviceInfo {
    struct_version: 2,
    name: "default",
    host_api: 0,
    max_input_channels: 32,
    max_output_channels: 32,
    default_low_input_latency: 0.008707482993197279,
    default_low_output_latency: 0.008707482993197279,
    default_high_input_latency: 0.034829931972789115,
    default_high_output_latency: 0.034829931972789115,
    default_sample_rate: 44100
}
An unknown error occurred

When running devices.rs:

Running `target/debug/examples/devices`
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
jack_client_new: deprecated
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
jack_client_new: deprecated
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Number of devices = 6
Defualt input device: Ok(DeviceIndex(5))
Defualt output device: Ok(DeviceIndex(5))
All devices:
--------------------------------------- DeviceIndex(0)
DeviceInfo {
    struct_version: 2,
    name: "HDA Intel: ALC1200 Digital (hw:0,1)",
    host_api: 0,
    max_input_channels: 2,
    max_output_channels: 2,
    default_low_input_latency: 0.005804988662131519,
    default_low_output_latency: 0.008707482993197279,
    default_high_input_latency: 0.034829931972789115,
    default_high_output_latency: 0.034829931972789115,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 2 channel input:
    44100hz
    48000hz
    96000hz
Supported standard sample rates for half-duplex 16-bit 2 channel output:
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz
Supported standard sample rates for full-duplex 16-bit 2 channel input, 2 channel output:
    44100hz
    48000hz
    96000hz
--------------------------------------- DeviceIndex(1)
DeviceInfo {
    struct_version: 2,
    name: "HDA Intel: ALC1200 Alt Analog (hw:0,2)",
    host_api: 0,
    max_input_channels: 2,
    max_output_channels: 0,
    default_low_input_latency: 0.005804988662131519,
    default_low_output_latency: -1,
    default_high_input_latency: 0.034829931972789115,
    default_high_output_latency: -1,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 2 channel input:
    44100hz
    48000hz
    96000hz
Supported standard sample rates for half-duplex 16-bit 0 channel output:
Supported standard sample rates for full-duplex 16-bit 2 channel input, 0 channel output:
--------------------------------------- DeviceIndex(2)
DeviceInfo {
    struct_version: 2,
    name: "iec958",
    host_api: 0,
    max_input_channels: 0,
    max_output_channels: 2,
    default_low_input_latency: -1,
    default_low_output_latency: 0.005804988662131519,
    default_high_input_latency: -1,
    default_high_output_latency: 0.034829931972789115,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 0 channel input:
Supported standard sample rates for half-duplex 16-bit 2 channel output:
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz
Supported standard sample rates for full-duplex 16-bit 0 channel input, 2 channel output:
--------------------------------------- DeviceIndex(3)
DeviceInfo {
    struct_version: 2,
    name: "spdif",
    host_api: 0,
    max_input_channels: 2,
    max_output_channels: 2,
    default_low_input_latency: 0.005804988662131519,
    default_low_output_latency: 0.008707482993197279,
    default_high_input_latency: 0.034829931972789115,
    default_high_output_latency: 0.034829931972789115,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 2 channel input:
    44100hz
    48000hz
    96000hz
Supported standard sample rates for half-duplex 16-bit 2 channel output:
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz
Supported standard sample rates for full-duplex 16-bit 2 channel input, 2 channel output:
    44100hz
    48000hz
    96000hz
--------------------------------------- DeviceIndex(4)
DeviceInfo {
    struct_version: 2,
    name: "pulse",
    host_api: 0,
    max_input_channels: 32,
    max_output_channels: 32,
    default_low_input_latency: 0.008707482993197279,
    default_low_output_latency: 0.008707482993197279,
    default_high_input_latency: 0.034829931972789115,
    default_high_output_latency: 0.034829931972789115,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 32 channel input:
    8000hz
    9600hz
    11025hz
    12000hz
    16000hz
    22050hz
    24000hz
    32000hz
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz
Supported standard sample rates for half-duplex 16-bit 32 channel output:
    8000hz
    9600hz
    11025hz
    12000hz
    16000hz
    22050hz
    24000hz
    32000hz
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz
Supported standard sample rates for full-duplex 16-bit 32 channel input, 32 channel output:
    8000hz
    9600hz
    11025hz
    12000hz
    16000hz
    22050hz
    24000hz
    32000hz
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz
--------------------------------------- DeviceIndex(5)
DeviceInfo {
    struct_version: 2,
    name: "default",
    host_api: 0,
    max_input_channels: 32,
    max_output_channels: 32,
    default_low_input_latency: 0.008707482993197279,
    default_low_output_latency: 0.008707482993197279,
    default_high_input_latency: 0.034829931972789115,
    default_high_output_latency: 0.034829931972789115,
    default_sample_rate: 44100
}
Supported standard sample rates for half-duplex 16-bit 32 channel input:
    8000hz
    9600hz
    11025hz
    12000hz
    16000hz
    22050hz
    24000hz
    32000hz
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz
Supported standard sample rates for half-duplex 16-bit 32 channel output:
    8000hz
    9600hz
    11025hz
    12000hz
    16000hz
    22050hz
    24000hz
    32000hz
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz
Supported standard sample rates for full-duplex 16-bit 32 channel input, 32 channel output:
    8000hz
    9600hz
    11025hz
    12000hz
    16000hz
    22050hz
    24000hz
    32000hz
    44100hz
    48000hz
    88200hz
    96000hz
    192000hz

When running hosts.rs:

     Running `target/debug/examples/hosts`
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
jack_client_new: deprecated
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
jack_client_new: deprecated
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Default Host API: Ok(0)
All Host APIs:
(
    0,
    HostApiInfo {
        struct_version: 1,
        host_type: ALSA,
        name: "ALSA",
        device_count: 8,
        default_input_device: Some(
            DeviceIndex(
                7
            )
        ),
        default_output_device: Some(
            DeviceIndex(
                7
            )
        )
    }
)
(
    1,
    HostApiInfo {
        struct_version: 1,
        host_type: OSS,
        name: "OSS",
        device_count: 0,
        default_input_device: None,
        default_output_device: None
    }
)

Paul-Andre avatar May 21 '16 02:05 Paul-Andre

fyi, i was seeing this with debian bullseye as well, however, it seems to be resolved with portaudio 19.6.0-1.1

khimaros avatar May 28 '21 07:05 khimaros