sourcey / libsourcey

C++14 evented IO libraries for high performance networking and media based applications
https://sourcey.com/libsourcey
GNU Lesser General Public License v2.1
1.32k stars 349 forks source link

webrtcstreamer free(): invalid pointer on client connect #157

Closed michaelfig closed 7 years ago

michaelfig commented 7 years ago

Hi,

I'm running the webrtcstreamer program, and when I connect to the nodejs app, I get the following in the web browser:

["symple:client: connecting",{"url":"https://symple.liveblockauctions.com:80","secure":true,"peer":{"user":"demo","name":"Demo User","group":"public","rooms":[]}}]
["symple:client: connected"]
["symple:client: announced",{"type":"response","status":200,"message":"Welcome Demo User","data":{"token":"","user":"demo","name":"Demo User","type":"","host":"::ffff:24.89.114.254","online":true,"id":"k1wgAychy1ZW2RKnAAAK"}}]
["symple:roster: adding",{"token":"","user":"demo","name":"Demo User","type":"","host":"::ffff:24.89.114.254","online":true,"id":"k1wgAychy1ZW2RKnAAAK"}]
["symple:client: sending",{"probe":true,"data":{"user":"demo","name":"Demo User","group":"public","rooms":[],"token":"","type":"","host":"::ffff:24.89.114.254","online":true,"id":"k1wgAychy1ZW2RKnAAAK"},"type":"presence","id":"zv1xyegb6qd","from":"demo|k1wgAychy1ZW2RKnAAAK"}]
["symple:roster: adding",{"host":"::ffff:127.0.0.1","id":"HxUtGEWXlT0eF6DdAAAL","name":"Video Server","online":true,"type":"","user":"videoserver"}]
["symple:client: sending",{"to":"HxUtGEWXlT0eF6DdAAAL","type":"presence","data":{"user":"demo","name":"Demo User","group":"public","rooms":[],"token":"","type":"","host":"::ffff:24.89.114.254","online":true,"id":"k1wgAychy1ZW2RKnAAAK"},"id":"07ny6tg0v718","from":"demo|k1wgAychy1ZW2RKnAAAK"}]
["symple:roster: removing","HxUtGEWXlT0eF6DdAAAL",{"host":"::ffff:127.0.0.1","id":"HxUtGEWXlT0eF6DdAAAL","name":"Video Server","online":true,"type":"","user":"videoserver"}]
["symple:client: got message from unknown peer",{"type":"presence","data":{"name":"Video Server","type":"","user":"videoserver","host":"::ffff:127.0.0.1","online":false,"id":"HxUtGEWXlT0eF6DdAAAL"},"from":"videoserver|HxUtGEWXlT0eF6DdAAAL"}]

webrtcstreamer dumps core, which when I get a backtrace, gives the following:

Core was generated by `./webrtcstreamer'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007f4293937428 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:54
54  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0x7f427939a700 (LWP 28332))]
(gdb) bt
#0  0x00007f4293937428 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007f429393902a in __GI_abort () at abort.c:89
#2  0x00007f42939797ea in __libc_message (do_abort=do_abort@entry=2, 
    fmt=fmt@entry=0x7f4293a922e0 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007f4293981e0a in malloc_printerr (ar_ptr=<optimized out>, 
    ptr=<optimized out>, str=0x7f4293a8f0b2 "free(): invalid pointer", 
    action=3) at malloc.c:5004
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0)
    at malloc.c:3865
#5  0x00007f429398598c in __GI___libc_free (mem=<optimized out>)
    at malloc.c:2966
#6  0x00007f42954820a6 in std::default_delete<cricket::VideoFormat>::operator()(cricket::VideoFormat*) const ()
   from /home/ubuntu/libsourcey/build/webrtc/libscy_webrtc.so.1.0
#7  0x00007f4295481711 in std::unique_ptr<cricket::VideoFormat, std::default_delete<cricket::VideoFormat> >::reset(cricket::VideoFormat*) ()
   from /home/ubuntu/libsourcey/build/webrtc/libscy_webrtc.so.1.0
#8  0x00007f4295480484 in cricket::VideoCapturer::SetCaptureFormat(cricket::VideoFormat const*) ()
   from /home/ubuntu/libsourcey/build/webrtc/libscy_webrtc.so.1.0
#9  0x00007f4295480bf4 in scy::wrtc::VideoPacketSource::Start(cricket::VideoFormat const&) () from /home/ubuntu/libsourcey/build/webrtc/libscy_webrtc.so.1.0
#10 0x00007f4295524e10 in cricket::VideoCapturer::StartCapturing(cricket::VideoFormat const&) () from /home/ubuntu/libsourcey/build/webrtc/libscy_webrtc.so.1.0
#11 0x00007f429565c5d2 in rtc::FunctorMessageHandler<bool, rtc::MethodFunctor<cricket::VideoCapturer, bool (cricket::VideoCapturer::*)(cricket::VideoFormat const&), bool, cricket::VideoFormat const&> >::OnMessage(rtc::Message*) ()
   from /home/ubuntu/libsourcey/build/webrtc/libscy_webrtc.so.1.0
#12 0x00007f429553d470 in rtc::Thread::ReceiveSendsFromThread(rtc::Thread const*) () from /home/ubuntu/libsourcey/build/webrtc/libscy_webrtc.so.1.0
#13 0x00007f42955593c1 in rtc::MessageQueue::Get(rtc::Message*, int, bool) ()
   from /home/ubuntu/libsourcey/build/webrtc/libscy_webrtc.so.1.0
#14 0x00007f429553cfa6 in rtc::Thread::Run() ()
   from /home/ubuntu/libsourcey/build/webrtc/libscy_webrtc.so.1.0
#15 0x00007f429553cd13 in rtc::Thread::PreRun(void*) ()
   from /home/ubuntu/libsourcey/build/webrtc/libscy_webrtc.so.1.0
#16 0x00007f4293cd26ba in start_thread (arg=0x7f427939a700)
    at pthread_create.c:333
#17 0x00007f4293a0882d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
(gdb) quit

Any help would be appreciated!

Thanks, Michael.

auscaster commented 7 years ago

Hi Michael

I just built and ran the demo but wasn't able to reproduce your error.

I'm using the following command to build libsourcey:

cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_SHARED_LIBS=OFF \
         -DBUILD_MODULES=ON -DBUILD_APPLICATIONS=ON \
         -DBUILD_TESTS=OFF -DBUILD_SAMPLES=OFF -DBUILD_SAMPLES_webrtc=ON \
         -DWITH_FFMPEG=ON -DWITH_WEBRTC=ON -DENABLE_LOGGING=ON \
         -DBUILD_MODULE_base=ON -DBUILD_MODULE_av=ON \
         -DBUILD_MODULE_crypto=ON -DBUILD_MODULE_http=ON \
         -DBUILD_MODULE_json=ON -DBUILD_MODULE_net=ON \
         -DBUILD_MODULE_socketio=ON -DBUILD_MODULE_symple=ON \
         -DBUILD_MODULE_util=ON -DBUILD_MODULE_webrtc=ON \
         -DWEBRTC_ROOT_DIR=/home/kam/sourcey/webrtcbuilds/out/webrtc-17657-02ba69d-linux-x64

And the relevant platform information:

--   Platform:
--     Host:                        Linux 3.13.0-105-generic x86_64
--     CMake:                       3.2.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               DEBUG
-- 
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ Compiler:                /usr/bin/c++ (ver 6.2.0)

If you can provide any extra information to help me reproduce the error that would be a big help.

michaelfig commented 7 years ago

Using your build command for libsourcey, I don't get the errors anymore. Maybe this is some issue due to mixing static and shared libraries, or something.

Now I just have to configure my TURN server, but I'm back on familiar ground.

Thanks for your help, Michael.

auscaster commented 7 years ago

Great :)

On 28 June 2017 at 04:04, Michael FIG notifications@github.com wrote:

Using your build command for libsourcey, I don't get the errors anymore. Maybe this is some issue due to mixing static and shared libraries, or something.

Now I just have to configure my TURN server, but I'm back on familiar ground.

Thanks for your help, Michael.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sourcey/libsourcey/issues/157#issuecomment-311536120, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGKDBTq-rmK0D4bTrxiDCq-_QPWf9-fks5sIbTHgaJpZM4Nx6G4 .

michaelfig commented 6 years ago

Found the issue: I needed -DCMAKE_BUILD_TYPE=Debug when building my project, or the Release version of libwebrtc_full.a was used, which caused this runtime error.

Scorpionchiques commented 5 years ago

It also works with -DCMAKE_BUILD_TYPE=Release. It seems like I have the same issue when CMAKE_BUILD_TYPE is not specified.