open-webrtc-toolkit / owt-client-native

Open WebRTC Toolkit client SDK for native Windows/Linux/iOS applications.
https://01.org/open-webrtc-toolkit
Apache License 2.0
384 stars 180 forks source link

build_linux.py clang verison of libowt.a cause memory issue #692

Open chenhequn opened 1 year ago

chenhequn commented 1 year ago

I changed scripts/build_linux.py to build with clang, but when I include libowt.a, app crash.

{
 # Disable usage of GTK.
     'rtc_use_gtk=false',
     # When is_clang is false, we're not using sysroot in tree.
-    'use_sysroot=false',
+    #'use_sysroot=false',
     # For Linux build we expect application built with gcc/g++. Set SDK to use
     # the same toolchain.
-    'is_clang=false',
+    #'is_clang=false',
     # Upstream only officially supports clang, so we need to suppress warnings
     # to avoid gcc/g++ specific build errors.
     'treat_warnings_as_errors=false',
}

Thread 2 "conf_sample" received signal SIGABRT, Aborted. [Switching to Thread 0x7ffff5fa6700 (LWP 6510)] __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt

0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51

1 0x00007ffff65fb7f1 in __GI_abort () at abort.c:79

2 0x00007ffff7bc396b in ?? () from /usr/lib/x86_64-linux-gnu/libc++abi.so.1

3 0x00007ffff7bac9cf in ?? () from /usr/lib/x86_64-linux-gnu/libc++abi.so.1

4 0x00007ffff7bc2b23 in ?? () from /usr/lib/x86_64-linux-gnu/libc++abi.so.1

5 0x00007ffff7bc5966 in ?? () from /usr/lib/x86_64-linux-gnu/libc++abi.so.1

6 0x00007ffff7bc58ed in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libc++abi.so.1

7 0x00007ffff7bc5518 in operator new(unsigned long) () from /usr/lib/x86_64-linux-gnu/libc++abi.so.1

chenhequn commented 1 year ago

@jianjunz Is there any solution?

chenhequn commented 1 year ago

using CMAKE_CXX_FLAGS -O0, the error is in sdputils.cc:14, which is a static const map:

13 0x00000000004704bd in __cxx_global_var_init () at ../../talk/owt/sdk/base/sdputils.cc:14

(gdb) bt

0 __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:282

1 0x00000000004e65d7 in std::__1::char_traits::copy (s1=0x2627448 "", s2=0x400003100000006 <error: Cannot access memory at address 0x400003100000006>, __n=1)

at ../../buildtools/third_party/libc++/trunk/include/__string:225

2 0x00000000004e6214 in std::1::basic_string<char, std::__1::char_traits, std::1::allocator >::__init (this=0x2627448,

__s=0x400003100000006 <error: Cannot access memory at address 0x400003100000006>, __sz=1) at ../../buildtools/third_party/libc++/trunk/include/string:1792

3 0x00000000004e605a in std::1::basic_string<char, std::__1::char_traits, std::1::allocator >::basic_string (this=0x2627448, __str=...)

at ../../buildtools/third_party/libc++/trunk/include/string:1838
__last=0x7fffffffe0d0) at ../../buildtools/third_party/libc++/trunk/include/unordered_map:1624

12 0x00000000005014ca in std::1::unordered_map<owt::base::AudioCodec, std::__1::basic_string<char, std::1::char_traits, std::1::allocator > const, owt::base::EnumClassHash, std::1::equal_to, std::1::allocator<std::1::pair<owt::base::AudioCodec const, std::1::basic_string<char, std::__1::char_traits, std::1::allocator > const> > >::unordered_map (

this=0x24ff3f0 <owt::base::audio_codec_names>, __il=<incomplete type>) at ../../buildtools/third_party/libc++/trunk/include/unordered_map:1565

13 0x00000000004704bd in __cxx_global_var_init () at ../../talk/owt/sdk/base/sdputils.cc:14

14 0x00000000004706c9 in _GLOBAL__sub_I_sdputils.cc ()

jianjunz commented 1 year ago

If is_clang=true and use_sysroot=true, it uses a prebuilt clang binary, which could be different from your system's clang.

chenhequn commented 1 year ago

I need to build libwebrtc.a as a plugin to integrated with Unreal. how to build with system's clang?