grishka / libtgvoip

VoIP library for Telegram clients
The Unlicense
387 stars 156 forks source link

Assertion `requestedBytes<=sizeof(remainingData)' failed #48

Closed mymedia2 closed 6 years ago

mymedia2 commented 6 years ago

Hi,

The following crash occurs at the beginning of a call. What can cause this error?

telegram-desktop: /build/libtgvoip/os/linux/AudioOutputPulse.cpp:282: void tgvoip::audio::AudioOutputPulse::StreamWriteCallback(pa_stream*, size_t): Assertion `requestedBytes<=sizeof(remainingData)' failed.

Stacktrace:

#0  0x00007f9c017a4e7b in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
        set = {__val = {18446744067266838239, 140305709940016, 2, 140308016686727, 140307919110144, 140305709940016, 140305709940117, 140305709940016, 140305709940016, 140305709940223, 140305709940316, 140305709940016, 140305709940316, 0, 0, 0}}
        pid = <optimized out>
        tid = <optimized out>
#1  0x00007f9c017a6231 in __GI_abort () at abort.c:79
        save_stage = 1
        act = {__sigaction_handler = {sa_handler = 0x7f9b78003d30, sa_sigaction = 0x7f9b78003d30}, sa_mask = {__val = {0, 140305709924384, 0, 0, 0, 140306448110776, 0, 140306448110608, 140308017792896, 21474836480, 140308017777992, 0, 5361793661716653056, 140308017762964, 0, 140308017777992}}, sa_flags = -1759447064, sa_restorer = 0x55819720f818}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007f9c0179d9da in __assert_fail_base (fmt=0x7f9c018f0d48 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55819720f818 "requestedBytes<=sizeof(remainingData)", file=file@entry=0x55819720f7e8 "/build/libtgvoip/os/linux/AudioOutputPulse.cpp", line=line@entry=282, function=function@entry=0x55819720f920 <tgvoip::audio::AudioOutputPulse::StreamWriteCallback(pa_stream*, unsigned long)::__PRETTY_FUNCTION__> "void tgvoip::audio::AudioOutputPulse::StreamWriteCallback(pa_stream*, size_t)") at assert.c:92
        str = 0x7f9b78003d30 ""
        total = 4096
#3  0x00007f9c0179da52 in __GI___assert_fail (assertion=0x55819720f818 "requestedBytes<=sizeof(remainingData)", file=0x55819720f7e8 "/build/libtgvoip/os/linux/AudioOutputPulse.cpp", line=282, function=0x55819720f920 <tgvoip::audio::AudioOutputPulse::StreamWriteCallback(pa_stream*, unsigned long)::__PRETTY_FUNCTION__> "void tgvoip::audio::AudioOutputPulse::StreamWriteCallback(pa_stream*, size_t)") at assert.c:101
#4  0x0000558196f5c95b in  ()
#5  0x00007f9be3139567 in create_stream_complete (s=0x7f9b9401eaa0) at pulse/stream.c:970
        s = 0x7f9b9401eaa0
        requested_bytes = 16896
        __func__ = "pa_create_stream_callback"
        __PRETTY_FUNCTION__ = "pa_create_stream_callback"
#6  0x00007f9be3139567 in pa_create_stream_callback (pd=pd@entry=0x7f9b780017f0, command=command@entry=2, tag=tag@entry=2, t=t@entry=0x7f9bd80028d0, userdata=userdata@entry=0x7f9b9401eaa0) at pulse/stream.c:1176
        s = 0x7f9b9401eaa0
        requested_bytes = 16896
        __func__ = "pa_create_stream_callback"
        __PRETTY_FUNCTION__ = "pa_create_stream_callback"
#7  0x00007f9be2ec65d1 in run_action (pd=0x7f9b780017f0, r=0x7f9b9c000ee0, command=2, ts=0x7f9bd80028d0) at pulsecore/pdispatch.c:288
        callback = 0x7f9be31391b0 <pa_create_stream_callback>
        userdata = 0x7f9b9401eaa0
        tag = 2
#8  0x00007f9be2ec694b in pa_pdispatch_run (pd=0x7f9b780017f0, packet=packet@entry=0x7f9b9c000db0, ancil_data=ancil_data@entry=0x7f9b78000e58, userdata=userdata@entry=0x7f9b9401d470) at pulsecore/pdispatch.c:341
        r = <optimized out>
        tag = 2
        command = 2
        ts = 0x7f9bd80028d0
        ret = -1
        pdata = <optimized out>
        plen = 254
        __func__ = "pa_pdispatch_run"
        __PRETTY_FUNCTION__ = "pa_pdispatch_run"
#9  0x00007f9be311a38e in pstream_packet_callback (p=<optimized out>, packet=0x7f9b9c000db0, ancil_data=0x7f9b78000e58, userdata=0x7f9b9401d470) at pulse/context.c:349
        c = 0x7f9b9401d470
        __func__ = "pstream_packet_callback"
        __PRETTY_FUNCTION__ = "pstream_packet_callback"
#10 0x00007f9be2ec959f in do_read (p=p@entry=0x7f9b78000bc0, re=re@entry=0x7f9b78000d88) at pulsecore/pstream.c:1012
        d = <optimized out>
        l = <optimized out>
        r = <optimized out>
        release_memblock = 0x0
        __func__ = "do_read"
        __PRETTY_FUNCTION__ = "do_read"
#11 0x00007f9be2ecc05b in do_pstream_read_write (p=0x7f9b78000bc0) at pulsecore/pstream.c:248
        __func__ = "do_pstream_read_write"
        __PRETTY_FUNCTION__ = "do_pstream_read_write"
#12 0x00007f9be2ecc3f9 in srb_callback (srb=<optimized out>, userdata=0x7f9b78000bc0) at pulsecore/pstream.c:287
        p = 0x7f9b78000bc0
        __func__ = "srb_callback"
        __PRETTY_FUNCTION__ = "srb_callback"
#13 0x00007f9be2eccc7f in srbchannel_rwloop (sr=0x7f9b78003520) at pulsecore/srbchannel.c:190
#14 0x00007f9be312f358 in dispatch_pollfds (m=0x7f9b94018420) at pulse/mainloop.c:655
        e = 0x7f9b780035f0
        r = 0
        k = 1
        dispatched = 0
        __func__ = "pa_mainloop_dispatch"
        __PRETTY_FUNCTION__ = "pa_mainloop_dispatch"
#15 0x00007f9be312f358 in pa_mainloop_dispatch (m=m@entry=0x7f9b94018420) at pulse/mainloop.c:898
        dispatched = 0
        __func__ = "pa_mainloop_dispatch"
        __PRETTY_FUNCTION__ = "pa_mainloop_dispatch"
#16 0x00007f9be312f72e in pa_mainloop_iterate (m=0x7f9b94018420, block=<optimized out>, retval=0x0) at pulse/mainloop.c:929
        r = 1
#17 0x00007f9be312f7b0 in pa_mainloop_run (m=0x7f9b94018420, retval=retval@entry=0x0) at pulse/mainloop.c:944
        r = <optimized out>
#18 0x00007f9be313d619 in thread (userdata=0x7f9b940183e0) at pulse/thread-mainloop.c:100
        m = 0x7f9b940183e0
        mask = {__val = {18446744067267100671, 18446744073709551615 <repeats 15 times>}}
        prev_mask = {__val = {0 <repeats 16 times>}}
        sa = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
#19 0x00007f9be2edcc08 in internal_thread_func (userdata=0x7f9b9401dd40) at pulsecore/thread-posix.c:81
        t = 0x7f9b9401dd40
#20 0x00007f9c0245d5aa in start_thread (arg=0x7f9ba3ffe700) at pthread_create.c:463
        pd = 0x7f9ba3ffe700
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140306448115456, -2014747426996165198, 140306892341150, 140306892341151, 140306892341152, 0, 1962841682978465202, 1959674316377744818}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#21 0x00007f9c01866cbf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

libtgvoip version: 2.1.1 Telegram Desktop version: 1.3.10

grishka commented 6 years ago

PulseAudio buffer sizes likely. Do you have any other active audio streams when this happens? Did it crash like this in the previous versions or it only started in 2.1.1?

mymedia2 commented 6 years ago

Really! I was just listening music. But a strange speech-dispatcher process was running, and after killall speech-dispatcher the problem disappears or is hardly non-reproducible. To be clear, I use Ubuntu 16.04 (this is a host system), and I run Telegram inside chroot jail with Debian Unstable.

In older versions of libtgvoip I got the next error.

Assertion '!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m)' failed at pulse/thread-mainloop.c:187, function pa_threaded_mainloop_unlock(). Aborting.

Theoretically, the issue may have been linked with that speech-dispatcher...

grishka commented 6 years ago

In older versions of libtgvoip I got the next error.

So at least it gets further now lol

I wonder if PulseAudio would be okay with me disregarding the requestedBytes value and always writing at most 60ms of audio at a time.

grishka commented 6 years ago

Should be fixed in 2.2.2 btw. I'll close this issue as soon as tdesktop beta with 2.2.2 comes out.

grishka commented 6 years ago

Actually, it did come out a while ago now