Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contextbar crashes with alsa backend #3485

Closed
Chiitoo opened this issue Sep 19, 2020 · 18 comments
Closed

Contextbar crashes with alsa backend #3485

Chiitoo opened this issue Sep 19, 2020 · 18 comments
Labels
Linux Affects Linux

Comments

@Chiitoo
Copy link
Contributor

Chiitoo commented Sep 19, 2020

After bd512da [1], a segmentation fault will occur when adding an ALSA source.

Platform

Operating system and version: Gentoo Linux
OBS Studio version: git master

Expected Behavior

No segmentation fault occurs.

Current Behavior

Segmentation fault occurs.

Thread 1 "obs" received signal SIGSEGV, Segmentation fault.
0x00007ffff5f5d849 in obs_module_get_locale_string (mod=0x0, lookup_string=lookup_string@entry=0x55555575fa48 "Device", translated_string=translated_string@entry=0x7fffffff7fb0)
    at /[...]/libobs/obs-module.c:66
66      /[...]/libobs/obs-module.c: No such file or directory.
(gdb) bt
#0  0x00007ffff5f5d849 in obs_module_get_locale_string (mod=0x0, lookup_string=lookup_string@entry=0x55555575fa48 "Device", 
    translated_string=translated_string@entry=0x7fffffff7fb0) at /[...]/libobs/obs-module.c:66
#1  0x00007ffff5f5d894 in obs_module_get_locale_text (mod=<optimized out>, text=text@entry=0x55555575fa48 "Device")
    at /[...]/libobs/obs-module.c:77
#2  0x000055555570c4a9 in AudioCaptureToolbar::Init (this=0x555556c6d940)
    at /[...]/UI/context-bar-controls.cpp:201
#3  0x0000555555610ac0 in OBSBasic::UpdateContextBar (this=0x555555929450)
    at /[...]/UI/window-basic-main.cpp:2916
#4  0x00005555556ed393 in SourceTreeItem::Select (this=<optimized out>) at /[...]/UI/source-tree.cpp:531
#5  0x00005555555cb895 in SourceTreeItem::qt_static_metacall (_o=_o@entry=0x555556b3ee20, _id=_id@entry=7, _a=_a@entry=0x7fffffff8200, _c=QMetaObject::InvokeMetaMethod)
    at UI/obs_autogen/EWIEGA46WW/moc_source-tree.cpp:182
#6  0x00005555555cb932 in SourceTreeItem::qt_static_metacall (_o=_o@entry=0x555556b3ee20, _c=_c@entry=QMetaObject::InvokeMetaMethod, _id=_id@entry=7, _a=_a@entry=0x7fffffff8200)
    at UI/obs_autogen/EWIEGA46WW/moc_source-tree.cpp:171
#7  0x00007ffff56ac82b in QMetaMethod::invoke (this=<optimized out>, object=0x555556b3ee20, connectionType=Qt::DirectConnection, returnValue=..., val0=..., val1=..., val2=..., 
    val3=..., val4=..., val5=..., val6=..., val7=..., val8=..., val9=...)
    at /[...]/src/corelib/kernel/qmetaobject.cpp:2303
#8  0x00007ffff56ae148 in QMetaObject::invokeMethod (obj=obj@entry=0x555556b3ee20, member=member@entry=0x555555761606 "Select", type=type@entry=Qt::AutoConnection, ret=..., 
    val0=..., val1=..., val2=..., val3=..., val4=..., val5=..., val6=..., val7=..., val8=..., val9=...)
    at /[...]/src/corelib/kernel/qmetaobject.cpp:1515
#9  0x00005555556ead5e in QMetaObject::invokeMethod (val9=..., val8=..., val7=..., val6=..., val5=..., val4=..., val3=..., val2=..., val1=..., val0=..., 
    member=0x555555761606 "Select", obj=0x555556b3ee20) at /usr/include/qt5/QtCore/qobjectdefs.h:460
#10 operator() (__closure=0x0, cd=<optimized out>, data=0x555556b3ee20) at /[...]/UI/source-tree.cpp:223

Steps to Reproduce

  1. Run OBS Studio.
  2. Add 'Audio Capture Device (ALSA)'.
  3. Select 'OK'.
  4. Observe the segmentation fault doing its thing.

Additional information

This may or may not require a specific '.asoundrc' (I'll try to test it out soon (tm)).

@kkartaltepe
Copy link
Collaborator

Cannot replicate, given the crash it looks like a bad install.

@Programatic
Copy link
Contributor

I also can not replicate

@Chiitoo
Copy link
Contributor Author

Chiitoo commented Sep 19, 2020

Could you try with the following '.asoundrc' (edited for your hardware of course).

pcm.!default
{
        type asym
        playback.pcm "loopAndReal"
        capture.pcm "loopRecord"

        hint
        {
                show on
        }
}

pcm.loopRecord
{
        type hw
        card "Loopback"
        device 1
        subdevice 0
}

pcm.loopAndReal
{
        type plug
        slave.pcm "binder"
        route_policy "duplicate"
}

pcm.binder
{
        type multi
        slaves.a.pcm "generic"
        slaves.a.channels 2
        slaves.b.pcm "looper"
        slaves.b.channels 2

        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
}

pcm.looper
{
        type dmix
        ipc_key 1024
        ipc_key_add_uid 0
        ipc_perm 0666

        slave
        {
                pcm "hw:Loopback,0,0"
                rate 48000
                period_size 2048
                buffer_size 8192
                format s32_le
        }
}

pcm.generic
{
        type dmix
        ipc_key 1028
        ipc_key_add_uid 0
        ipc_perm 0666

        slave
        {
                pcm "hw:0"
                rate 48000
                period_size 2048
                buffer_size 8192
                format s32_le
        }
}

@kkartaltepe
Copy link
Collaborator

This crash has nothing related to your configuration in it.

@Chiitoo
Copy link
Contributor Author

Chiitoo commented Sep 19, 2020

What do you suggest it is related to then, aside from bad install?

I can reproduce this with the mentioned commig as much as I want to, and building with the commit before it, things just work.

Perhaps there is more to my set up that I haven't noticed yet. I'll try clearing all the configuration files and such, maybe even try a fresh user, but it may take a while for me to get to it.

Thanks so far!

@kkartaltepe
Copy link
Collaborator

It crashes in looking up translations for the UI

@kkartaltepe
Copy link
Collaborator

Closing this out since someone else could not replicate it either.

@Chiitoo
Copy link
Contributor Author

Chiitoo commented Sep 19, 2020

For those who might stumble upon this: I changed 'linux-pulseaudio' to 'linux-alsa' in https://github.com/obsproject/obs-studio/blob/master/UI/context-bar-controls.cpp#L189 and things work again here.

(Obviously not an actual fix, but it works.)

@kkartaltepe
Copy link
Collaborator

if you compiled without PA support that might be the issue.

@Chiitoo
Copy link
Contributor Author

Chiitoo commented Sep 20, 2020

Yes I do do that.

@Chiitoo
Copy link
Contributor Author

Chiitoo commented Sep 20, 2020

Does this mean PulseAudio is now mandatory?

@kkartaltepe kkartaltepe changed the title Segmentation Fault When Adding ALSA Audio Source Contextbar crashes with alsa backend Sep 20, 2020
@kkartaltepe kkartaltepe reopened this Sep 20, 2020
@kkartaltepe
Copy link
Collaborator

I think someone we have previously fixed issues to allow you to use alsa as the only backend. reopened for now.

@WizardCM WizardCM added the Linux Affects Linux label Sep 20, 2020
@skinkie
Copy link

skinkie commented Oct 29, 2020

I have the same issue but I want to put something else forward. The crash is caused by the fact that mod = NULL when a non-existing backend is selected, and then crashes. So the least that should be done (even before fixing the pulseaudio vs alsa issue) is assuring that mod is actually set.

@Chiitoo
Copy link
Contributor Author

Chiitoo commented Nov 28, 2020

I wonder if anyone enables both, ALSA and PulseAudio at the same time.

Not sure if it's a silly way to go about this, but I've been testing stuff like this now:

#if !defined(DISABLE_ALSA)
    obs_module_t *mod =
        get_os_module("win-wasapi", "mac-capture", "linux-alsa");
#else
    obs_module_t *mod =
        get_os_module("win-wasapi", "mac-capture", "linux-pulseaudio");
#endif

This of course only allows for one of them at a time, while I believe it's possible to build OBS Studio with both enabled.

Can't quite think of a way to add another back-end without larger changes right now.

It is also possible to build without either, but I guess in that case one will not have the sources to add and as such, won't be affected... except for when sources have been added in the past.

To prevent the crash in case mod is empty-like, I've been using this:

if (!mod)
    return;

Not sure if that's equally silly.

Chiitoo added a commit to Chiitoo/obs-studio that referenced this issue Dec 31, 2020
This commit prevents a crash in for example Linux configurations
where PulseAudio is disabled, which leads into 'mod' being 'null',
which in turn leads into a segmentation fault when an ALSA source
is selected.

Closes obsproject#3485
Chiitoo added a commit to Chiitoo/obs-studio that referenced this issue Jan 4, 2021
This commit prevents a crash in, for example, Linux configurations
where PulseAudio is disabled, which leads into 'mod' being 'null',
which in turn leads into a segmentation fault when an ALSA source
is selected.

Closes obsproject#3485
@jp9000 jp9000 closed this as completed in 41367bb Jan 12, 2021
@skinkie
Copy link

skinkie commented Jan 12, 2021

@jp9000 this does not add alsa as option.

@kkartaltepe
Copy link
Collaborator

This bug is for the crash on the builds without pulseaudio support.

@Chiitoo
Copy link
Contributor Author

Chiitoo commented Jan 12, 2021

Right, the toolbar will just be blank with ALSA only, but since I still don't quite have that part figured out better, it can be sorted later (or by someone else, should they get to it before I do).

At least the crash should no longer happen, which indeed is what this was mainly about.

@skinkie
Copy link

skinkie commented Jan 12, 2021

But be realistic. The actual bug was: there is no alsa backend, therefore it crashes. Not: the alsa backend returns a null pointer.

1div0 pushed a commit to 1div0/obs-studio that referenced this issue Apr 22, 2021
This commit prevents a crash in, for example, Linux configurations
where PulseAudio is disabled, which leads into 'mod' being 'null',
which in turn leads into a segmentation fault when an ALSA source
is selected.

Closes obsproject#3485
tommyvct pushed a commit to tommyvct/obs-studio that referenced this issue May 22, 2021
This commit prevents a crash in, for example, Linux configurations
where PulseAudio is disabled, which leads into 'mod' being 'null',
which in turn leads into a segmentation fault when an ALSA source
is selected.

Closes obsproject#3485
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux Affects Linux
Projects
None yet
Development

No branches or pull requests

5 participants