dao icon indicating copy to clipboard operation
dao copied to clipboard

daomake - fix help generation by preventing sigsegv due to wrong library ordering

Open dumblob opened this issue 10 years ago • 2 comments

Currently during building, the environment variable LD_LIBRARY_PATH should ensure, that the newly compiled libraries are taken into account. Unfortunately, the GNU C dynamic linker uses a weird messy algorithm to determine the proper order and therefore, first the system libraries are searched and then the LD_LIBRARY_PATH. This can be prevented by adding another attirbute to the ELF header called DT_RUNPATH.

GCC provides the --enable-new-dtags option for this purpose. I don't know how about other compilers :(

For unix systems, the patch is straightforward - e.g. with sed -i -r 's|-Wl,-rpath=|-Wl,--enable-new-dtags,-rpath=|' tools/daomake/platforms/unix.dao.

The sigsegv when run in valgrind:

0$ LD_LIBRARY_PATH=/home/test/dao/src/dao/lib HELP_PATH=/home/dao/src/dao/modules/help/ valgrind /home/test/dao/src/dao/bin/dao --path="$HELP_PATH" -e "load help; help::set_language('en'); help::set_font('monospace'); help::export('','./doc/html/en')"
==2781== Memcheck, a memory error detector
==2781== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==2781== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==2781== Command: /home/test/dao/src/dao/bin/dao --path= -e load\ help;\ help::set_language('en');\ help::set_font('monospace');\ help::export('','./doc/html/en')
==2781== 
  0  0: GETCG       :      1 ,     24 ,      0 ;     1,  
  1  1: GETCL       :      0 ,      0 ,      1 ;     1,  
  2  1: GETCL       :      0 ,      1 ,      2 ;     1,  
  3  0: CALL        :      1 ,      1 ,      3 ;     1,  
  4  0: GETCG       :      1 ,     24 ,      4 ;     1,  
  5  1: GETCL       :      0 ,      2 ,      5 ;     1,  
  6  1: GETCL       :      0 ,      3 ,      6 ;     1,  
  7  0: CALL        :      5 ,      1 ,      7 ;     1,  
  8  0: GETCG       :      1 ,     24 ,      8 ;     1,  
  9  1: GETCL       :      0 ,      4 ,      9 ;     1,  
 10  1: GETCL       :      0 ,      5 ,     10 ;     1,  
 11  1: GETCL       :      0 ,      6 ,     11 ;     1,  
 12  0: CALL        :      9 ,      2 ,     12 ;     1,  
 13  0: RETURN      :     12 ,      1 ,      0 ;     1,  
number of segments: 3
  0:    1    2
  1:    5    6
  2:    9   11
  1 GETCL       :      0 ,      0 ,      1 ;     1,  
  2 GETCL       :      0 ,      1 ,      2 ;     1,  
  5 GETCL       :      0 ,      2 ,      5 ;     1,  
  6 GETCL       :      0 ,      3 ,      6 ;     1,  
  9 GETCL       :      0 ,      4 ,      9 ;     1,  
 10 GETCL       :      0 ,      5 ,     10 ;     1,  
 11 GETCL       :      0 ,      6 ,     11 ;     1,  
; ModuleID = 'DaoJIT'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

declare void @DaoValue_Copy({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*)

declare i32 @DaoValue_Move({ i8, i8, i8, i8, i32 }, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32, i32, i8 }*)

declare void @DaoJIT_MOVE_SS({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }**)

declare void @DaoJIT_LOAD({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }**)

declare void @DaoJIT_MOVE_PP({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }**)

declare void @DaoJIT_SETI_ARRAY_I({ i8, i8, i8, i8, i32 }*, i64, i32*)

declare void @DaoJIT_SETI_ARRAY_F({ i8, i8, i8, i8, i32 }*, double, i32*)

declare void @DaoJIT_SETI_ARRAY_C({ i8, i8, i8, i8, i32 }*, { double, double }, i32*)

declare void @DaoJIT_SETI_ARRAY_A({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_ADD_INTEGER_ARRAY({ i8, i8, i8, i8, i32 }*, i64, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_SUB_INTEGER_ARRAY({ i8, i8, i8, i8, i32 }*, i64, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_MUL_INTEGER_ARRAY({ i8, i8, i8, i8, i32 }*, i64, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_DIV_INTEGER_ARRAY({ i8, i8, i8, i8, i32 }*, i64, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_MOD_INTEGER_ARRAY({ i8, i8, i8, i8, i32 }*, i64, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_POW_INTEGER_ARRAY({ i8, i8, i8, i8, i32 }*, i64, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_ADD_FLOAT_ARRAY({ i8, i8, i8, i8, i32 }*, double, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_SUB_FLOAT_ARRAY({ i8, i8, i8, i8, i32 }*, double, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_MUL_FLOAT_ARRAY({ i8, i8, i8, i8, i32 }*, double, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_DIV_FLOAT_ARRAY({ i8, i8, i8, i8, i32 }*, double, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_MOD_FLOAT_ARRAY({ i8, i8, i8, i8, i32 }*, double, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_POW_FLOAT_ARRAY({ i8, i8, i8, i8, i32 }*, double, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_ADD_COMPLEX_ARRAY({ i8, i8, i8, i8, i32 }*, { double, double }, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_SUB_COMPLEX_ARRAY({ i8, i8, i8, i8, i32 }*, { double, double }, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_MUL_COMPLEX_ARRAY({ i8, i8, i8, i8, i32 }*, { double, double }, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_DIV_COMPLEX_ARRAY({ i8, i8, i8, i8, i32 }*, { double, double }, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_MOD_COMPLEX_ARRAY({ i8, i8, i8, i8, i32 }*, { double, double }, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_POW_COMPLEX_ARRAY({ i8, i8, i8, i8, i32 }*, { double, double }, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_ADD_ARRAY_INTEGER({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i64, i32*)

declare void @DaoJIT_SUB_ARRAY_INTEGER({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i64, i32*)

declare void @DaoJIT_MUL_ARRAY_INTEGER({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i64, i32*)

declare void @DaoJIT_DIV_ARRAY_INTEGER({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i64, i32*)

declare void @DaoJIT_MOD_ARRAY_INTEGER({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i64, i32*)

declare void @DaoJIT_POW_ARRAY_INTEGER({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i64, i32*)

declare void @DaoJIT_ADD_ARRAY_FLOAT({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, double, i32*)

declare void @DaoJIT_SUB_ARRAY_FLOAT({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, double, i32*)

declare void @DaoJIT_MUL_ARRAY_FLOAT({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, double, i32*)

declare void @DaoJIT_DIV_ARRAY_FLOAT({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, double, i32*)

declare void @DaoJIT_MOD_ARRAY_FLOAT({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, double, i32*)

declare void @DaoJIT_POW_ARRAY_FLOAT({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, double, i32*)

declare void @DaoJIT_ADD_ARRAY_COMPLEX({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { double, double }, i32*)

declare void @DaoJIT_SUB_ARRAY_COMPLEX({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { double, double }, i32*)

declare void @DaoJIT_MUL_ARRAY_COMPLEX({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { double, double }, i32*)

declare void @DaoJIT_DIV_ARRAY_COMPLEX({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { double, double }, i32*)

declare void @DaoJIT_MOD_ARRAY_COMPLEX({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { double, double }, i32*)

declare void @DaoJIT_POW_ARRAY_COMPLEX({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { double, double }, i32*)

declare void @DaoJIT_ADD_ARRAY_ARRAY({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_SUB_ARRAY_ARRAY({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_MUL_ARRAY_ARRAY({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_DIV_ARRAY_ARRAY({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_MOD_ARRAY_ARRAY({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_POW_ARRAY_ARRAY({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_ADD_SS({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }**)

declare void @DaoJIT_ADD_LT({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*)

declare void @DaoJIT_ADD_LE({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*)

declare void @DaoJIT_ADD_EQ({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*)

declare void @DaoJIT_ADD_NE({ i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*, { i8, i8, i8, i8, i32 }*)

declare i64 @DaoJIT_GETI_SI({ i8, i8, i8, i8, i32 }*, i64, i32*)

declare void @DaoJIT_SETI_SII(i64, i64, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_SETI_LI({ i8, i8, i8, i8, i32 }*, i64, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_SETI_TI({ i8, i8, i8, i8, i32 }*, i64, { i8, i8, i8, i8, i32 }*, i32*)

declare void @DaoJIT_SETF_TPP({ i8, i8, i8, i8, i32 }*, i64, { i8, i8, i8, i8, i32 }*, i32*)

declare i32 @DaoArray_Sliced(i8*)

declare double @pow(double, double)

declare void @daojit_debug(i8*)

declare double @abs(double)

declare double @acos(double)

declare double @asin(double)

declare double @atan(double)

declare double @ceil(double)

declare double @cos(double)

declare double @cosh(double)

declare double @exp(double)

declare double @floor(double)

declare double @log(double)

declare double @daojit_rand(double)

declare double @sin(double)

declare double @sinh(double)

declare double @sqrt(double)

declare double @tan(double)

declare double @tanh(double)

define i32 @__main___daojit_0x623f400_1({ [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, [0 x { i8, i8, i8, i8, i32 }*]* }*]* }* %JitCallData) {
Second:
  %0 = bitcast { [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, [0 x { i8, i8, i8, i8, i32 }*]* }*]* }* %JitCallData to [0 x { i8, i8, i8, i8, i32 }*]**
  %localValues = load [0 x { i8, i8, i8, i8, i32 }*]** %0
  %1 = getelementptr { [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, [0 x { i8, i8, i8, i8, i32 }*]* }*]* }* %JitCallData, i32 0, i32 1
  %routConsts = load [0 x { i8, i8, i8, i8, i32 }*]** %1
  %2 = alloca i32
  store i32 0, i32* %2
  %loref_1_ = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %localValues, i32 0, i32 1
  %3 = bitcast [0 x { i8, i8, i8, i8, i32 }*]* %routConsts to { i8, i8, i8, i8, i32 }**
  %locst_0_ = load { i8, i8, i8, i8, i32 }** %3
  %loref_2_ = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %localValues, i32 0, i32 2
  %4 = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %routConsts, i32 0, i32 1
  %locst_1_ = load { i8, i8, i8, i8, i32 }** %4
  call void @DaoJIT_MOVE_PP({ i8, i8, i8, i8, i32 }* %locst_0_, { i8, i8, i8, i8, i32 }** %loref_1_)
  call void @DaoJIT_MOVE_PP({ i8, i8, i8, i8, i32 }* %locst_1_, { i8, i8, i8, i8, i32 }** %loref_2_)
  ret i32 0
}

define i32 @__main___daojit_0x623f400_5({ [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, [0 x { i8, i8, i8, i8, i32 }*]* }*]* }* %JitCallData) {
Second:
  %0 = bitcast { [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, [0 x { i8, i8, i8, i8, i32 }*]* }*]* }* %JitCallData to [0 x { i8, i8, i8, i8, i32 }*]**
  %localValues = load [0 x { i8, i8, i8, i8, i32 }*]** %0
  %1 = getelementptr { [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, [0 x { i8, i8, i8, i8, i32 }*]* }*]* }* %JitCallData, i32 0, i32 1
  %routConsts = load [0 x { i8, i8, i8, i8, i32 }*]** %1
  %2 = alloca i32
  store i32 0, i32* %2
  %loref_5_ = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %localValues, i32 0, i32 5
  %3 = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %routConsts, i32 0, i32 2
  %locst_2_ = load { i8, i8, i8, i8, i32 }** %3
  %loref_6_ = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %localValues, i32 0, i32 6
  %4 = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %routConsts, i32 0, i32 3
  %locst_3_ = load { i8, i8, i8, i8, i32 }** %4
  call void @DaoJIT_MOVE_PP({ i8, i8, i8, i8, i32 }* %locst_2_, { i8, i8, i8, i8, i32 }** %loref_5_)
  call void @DaoJIT_MOVE_PP({ i8, i8, i8, i8, i32 }* %locst_3_, { i8, i8, i8, i8, i32 }** %loref_6_)
  ret i32 0
}

define i32 @__main___daojit_0x623f400_9({ [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, [0 x { i8, i8, i8, i8, i32 }*]* }*]* }* %JitCallData) {
Second:
  %0 = bitcast { [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, [0 x { i8, i8, i8, i8, i32 }*]* }*]* }* %JitCallData to [0 x { i8, i8, i8, i8, i32 }*]**
  %localValues = load [0 x { i8, i8, i8, i8, i32 }*]** %0
  %1 = getelementptr { [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32 }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, { i8, i8, i8, i8, i32 }* }*]*, [0 x { i8, i8, i8, i8, i32, i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, [0 x { i8, i8, i8, i8, i32 }*]* }*]* }* %JitCallData, i32 0, i32 1
  %routConsts = load [0 x { i8, i8, i8, i8, i32 }*]** %1
  %2 = alloca i32
  store i32 0, i32* %2
  %loref_9_ = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %localValues, i32 0, i32 9
  %3 = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %routConsts, i32 0, i32 4
  %locst_4_ = load { i8, i8, i8, i8, i32 }** %3
  %loref_10_ = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %localValues, i32 0, i32 10
  %4 = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %routConsts, i32 0, i32 5
  %locst_5_ = load { i8, i8, i8, i8, i32 }** %4
  %loref_11_ = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %localValues, i32 0, i32 11
  %5 = getelementptr [0 x { i8, i8, i8, i8, i32 }*]* %routConsts, i32 0, i32 6
  %locst_6_ = load { i8, i8, i8, i8, i32 }** %5
  call void @DaoJIT_MOVE_PP({ i8, i8, i8, i8, i32 }* %locst_4_, { i8, i8, i8, i8, i32 }** %loref_9_)
  call void @DaoJIT_MOVE_PP({ i8, i8, i8, i8, i32 }* %locst_5_, { i8, i8, i8, i8, i32 }** %loref_10_)
  call void @DaoJIT_MOVE_PP({ i8, i8, i8, i8, i32 }* %locst_6_, { i8, i8, i8, i8, i32 }** %loref_11_)
  ret i32 0
}
==2781== Invalid write of size 8
==2781==    at 0x56006F5: DaoProcess_Start (in /usr/lib/libdao.so)
==2781==    by 0x5608849: DaoProcess_Execute (in /usr/lib/libdao.so)
==2781==    by 0x55FDAEA: DaoProcess_Call (in /usr/lib/libdao.so)
==2781==    by 0x564C40E: DaoVmSpace_RunMain (in /usr/lib/libdao.so)
==2781==    by 0x40162D: main (daoMain.c:291)
==2781==  Address 0x8 is not stack'd, malloc'd or (recently) free'd
==2781== 
==2781== 
==2781== Process terminating with default action of signal 11 (SIGSEGV)
==2781==  Access not within mapped region at address 0x8
==2781==    at 0x56006F5: DaoProcess_Start (in /usr/lib/libdao.so)
==2781==    by 0x5608849: DaoProcess_Execute (in /usr/lib/libdao.so)
==2781==    by 0x55FDAEA: DaoProcess_Call (in /usr/lib/libdao.so)
==2781==    by 0x564C40E: DaoVmSpace_RunMain (in /usr/lib/libdao.so)
==2781==    by 0x40162D: main (daoMain.c:291)
==2781==  If you believe this happened as a result of a stack
==2781==  overflow in your program's main thread (unlikely but
==2781==  possible), you can try to increase the size of the
==2781==  main thread stack using the --main-stacksize= flag.
==2781==  The main thread stack size used in this run was 8388608.
==2781== 
==2781== HEAP SUMMARY:
==2781==     in use at exit: 847,190 bytes in 7,590 blocks
==2781==   total heap usage: 15,264 allocs, 7,674 frees, 1,669,421 bytes allocated
==2781== 
==2781== LEAK SUMMARY:
==2781==    definitely lost: 0 bytes in 0 blocks
==2781==    indirectly lost: 0 bytes in 0 blocks
==2781==      possibly lost: 54,338 bytes in 897 blocks
==2781==    still reachable: 792,852 bytes in 6,693 blocks
==2781==         suppressed: 0 bytes in 0 blocks
==2781== Rerun with --leak-check=full to see details of leaked memory
==2781== 
==2781== For counts of detected and suppressed errors, rerun with: -v
==2781== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)
139$

dumblob avatar Jun 16 '15 06:06 dumblob

This looks weird. No way should the JIT module be loaded here. Please try a clean build to see if it still happens. Please also try strace or (dtruss on mac) to check the paths of the loaded modules. Thanks.

daokoder avatar Jun 18 '15 14:06 daokoder

open() calls:

open("/usr/lib/tls/x86_64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libdao.so", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libreadline.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libncursesw.so.5", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
open("/usr/local/dao.conf", O_RDONLY)   = -1 ENOENT (No such file or directory)
open("./dao.conf", O_RDONLY)            = 3
open("/home/test/dao/lib/dao/modules/libdao_jit.so", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libffi.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/home/test/.history", O_RDONLY)  = 3
open("/home/test/dao/lib/dao/modules/libdao_help.so", O_RDONLY|O_CLOEXEC) = 3
open("/home/test/dao/modules/help/help_en/help_dao.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_feature.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_guide.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_data.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_type.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_type_number.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_type_enum.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_type_string.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_type_string_pattern.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_type_array.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_type_list.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_type_map.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_type_tuple.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_operator.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_control.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_routine.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_class.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_defer_error.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_concurrent.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_builtin.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_module.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_dao_grammar.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_daovm.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_daovm_interface.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_daovm_architecture.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_help.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_tool.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_module.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_module_core.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_module_macro.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_module_standard.dao", O_RDONLY) = 3
open("/home/test/dao/modules/help/help_en/help_misc.dao", O_RDONLY) = 3
open("/home/test/.history", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 3

I think it's pretty clear now what is going on. First the treacherous GNU C linker algorithm loads the old system library /usr/lib/libdao.so, then ./dao.conf is read (the one I'm using contains cpu =2 and jit =yes) which explains JIT and first then the libdao_help.so library is read from LD_LIBRARY_PATH.

By the way, I'm always compiling with newly fetched git directory, so there are no old files potentially causing harm.

dumblob avatar Jun 18 '15 19:06 dumblob