owt-client-native icon indicating copy to clipboard operation
owt-client-native copied to clipboard

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

Open chenhequn opened this issue 2 years ago • 4 comments

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 avatar Feb 28 '23 07:02 chenhequn

@jianjunz Is there any solution?

chenhequn avatar Feb 28 '23 07:02 chenhequn

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_toowt::base::AudioCodec, 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=) 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 ()

chenhequn avatar Feb 28 '23 12:02 chenhequn

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

jianjunz avatar Mar 02 '23 02:03 jianjunz

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

chenhequn avatar Mar 02 '23 08:03 chenhequn