遇到core dump调试
Add "add_compile_options(-g -O0)" to CMakeLists.txt
ulimit -c unlimited
sudo sysctl -w kernel.core_pattern=/home/debug/coredump/core-%e.%p.%h.%t
gdb -c my_core_file
set solib-search-path {LIBPATH}
gdb -c
set solib-search-path /home/shen/commit/gazelle_plugin/native-sql-engine/cpp/build/
bt
#7 0x00007f02c79bbc0a in _mm256_load_si256 (__P=0x7f011c166530)
at /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/avxintrin.h:909
#8 sparkcolumnarplugin::columnartorow::ColumnarToRowConverter::Init (this=0x7f011c166ef0, rb=...)
at /home/shen/commit/gazelle_plugin/native-sql-engine/cpp/src/operators/columnar_to_row_converter_avx512.cc:148
#9 0x00007f02c71d1416 in Java_com_intel_oap_vectorized_ArrowColumnarToRowJniWrapper_nativeConvertColumnarToRow (
env=0x7f01d40291f8, schema_arr=0x7f02dfffdad8, num_rows=50, buf_addrs=0x7f02dfffdac8, buf_sizes=0x7f02dfffdac0,
memory_pool_id=139642742916288) at /home/shen/commit/gazelle_plugin/native-sql-engine/cpp/src/jni/jni_wrapper.cc:1368
#10 0x00007f03d9017b94 in ?? ()
#11 0x00007f011c1644c0 in ?? ()
#12 0x00007f02df9fb998 in ?? ()
#13 0x00007f02dfffda60 in ?? ()
#14 0x00007f02df9fc628 in ?? ()
#15 0x0000000000000000 in ?? ()
(gdb) frame 8
#8 sparkcolumnarplugin::columnartorow::ColumnarToRowConverter::Init (this=0x7f011c166ef0, rb=...)
at /home/shen/commit/gazelle_plugin/native-sql-engine/cpp/src/operators/columnar_to_row_converter_avx512.cc:148
148 offsetarray_1_8x = _mm256_load_si256((__m256i*)&offsetarray[j]);
(gdb) info locals
x8_8x = {34359738376, 34359738376, 34359738376, 34359738376}
length_data = 0x7f011c167220
binary_array = {> = {> = {}, _M_ptr = 0x7f011c167300, _M_refcount = {
_M_pi = 0x7f011c1672f0}}, }
offsetarray = 0x7f011c166530
x7_8x = {30064771079, 30064771079, 30064771079, 30064771079}
j = 0
offsetarray_1_8x = {139642742916528, 139642742919584, -536882160, 139642742919704}
array = {> = {> = {}, _M_ptr = 0x7f011c167300, _M_refcount = {
_M_pi = 0x7f011c1672f0}}, }
i = 0
fixed_size_per_row = 24
total_memory_size = 139650324748208
(gdb)
cp ./releases/libspark_columnar_jni.so ./ && jar uvf /home/shen/commit/gazelle_plugin/native-sql-engine/core/target/spark-columnar-core-1.4.0-SNAPSHOT-jar-with-dependencies.jar ./libspark_columnar_jni.so
# cat world.c
#include
void world(void)
{
printf("world.\n");
}
# cat hello.c
#include
void world(void);
void hello(void)
{
printf("hello\n");
world();
}
# cat test.c
void hello(void);
int main(void)
{
hello();
return 0;
}
# gcc -shared -fPIC world.c -o libworld.so
# gcc -shared -fPIC hello.c -o libhello.so -L ./ -lworld
# gcc test.c -o a.out -lhello -L .
/usr/bin/ld: warning: libworld.so, needed by ./libhello.so, not found (try using -rpath or -rpath-link)
# gcc test.c -o a.out -lhello -L . -Wl,-rpath .
# ./a.out
hello
world.
gcc -shared -fPIC world.c -o libworld.so
gcc -shared -fPIC hello.c -o libhello.so
gcc test.c -o a.out -L ./ -lhello -lworld
ldconfig 默认扫描当前目录的共享库
当应用程序运行时,可以被加载到。
ldconfig通常在系统启动时运行,而当用户安装了一个新的动态链接库时,就需要手工运行这个命令。
错误方式
ar -rc libsworld.a world.c
这样生成的libsworld.a 大小和 world大小的两倍
!
world.c/ 1586786089 0 0 100644 68 `
#include
void world(void)
{
printf("world.\n");
}
而且会报以下错误
error adding symbols: Archive has no index; run ranlib to add one
正确的方式
gcc -c world.c
ar -rc libworld.a world.o