Error Msg:
[ 3][t 4][1527568111.510852098][Binlog.cpp:340][!Td] Load: init encryption
[ 4][t 4][1527568111.553509712][SqliteDb.cpp:177][!Td] ENCRYPT
Thread 16 "node" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffde7fc700 (LWP 433)]
0x000000000135c256 in EVP_MD_CTX_clear_flags ()
Stack Trace:
(gdb) bt
#0 0x000000000135c256 in EVP_MD_CTX_clear_flags ()
#1 0x000000000134618e in EVP_DigestInit_ex ()
#2 0x0000000001365943 in HMAC_Init_ex ()
#3 0x00007fffe56e5cd5 in sqlcipher_openssl_hmac (
ctx=0x7fffc8087558,
hmac_key=0x7fffc80875c8 "²%Ѱ\246g\240\236+*\037\231\276\363u\2
1\377|\215\250]\312w\021\031\004Q\214\253ع", key_sz=32,
in=0x7fffc80187b8 "@D\360\242#\250\241\070}j=\251\207\367\267\
\332HN:\233\062\221\353/\211\224l#%\311\001\245\064\307{\353G[T\33
\\<p\003dF\034Ҋ\020\333U}+Л\030\221\263`\304\016K\303w\247\324E\2
1OK\375YL\205\307\067\345\367|\346]\361\t(9\004\324k\025!R1 \257$3
355\063\314\354\024\360\246Z}\002\340b\235J\376\355\275\202\324\36
>\301\065\346B\366\"\037\321\330\341$\332\027s\365\245m\342\340N'`
224d\f\260\245H\357O\003\272qp?\001Ж\205\236\022Z{\201lJө\200}\t?r
$\220\004\364\330@5\341\327\334\304C\266\233\204\067u\213\221\301\
05", <incomplete sequence \315>..., in_sz=976,
in2=0x7fffde7f7964 "\001", in2_sz=4,
out=0x7fffc8018b88 "\034\063`7\344\004\272\361\276?\321\326\357Ӵ\
36\b*\233\352\356\004\201j\230\346\377ҝ\212G#(\213\001\310\377\177
) at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:20407
#4 0x00007fffe56e48e1 in sqlcipher_page_hmac (
ctx=0x7fffc8087438, pgno=1,
in=0x7fffc80187b8 "@D\360\242#\250\241\070}j=\251\207\367\267\
\332HN:\233\062\221\353/\211\224l#%\311\001\245\064\307{\353G[T\33
\\<p\003dF\034Ҋ\020\333U}+Л\030\221\263`\304\016K\303w\247\324E\221OK\375YL\205\307\067\345\367|\346]\361\t(9\004\324k\025!R1 \2
7$3\355\063\314\354\024\360\246Z}\002\340b\235J\376\355\275\202\32
\367>\301\065\346B\366\"\037\321\330\341$\332\027s\365\245m\342\34
N'`\224d\f\260\245H\357O\003\272qp?\001Ж\205\236\022Z{\201lJө\200}
t?r?$\220\004\364\330@5\341\327\334\304C\266\233\204\067u\213\221\
01\205", <incomplete sequence \315>..., in_sz=976,
out=0x7fffc8018b88 "\034\063`7\344\004\272\361\276?\321\326\35
Ӵ\236\b*\233\352\356\004\201j\230\346\377ҝ\212G#(\213\001\310\377\
77") at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:19479
#5 0x00007fffe56e1c15 in sqlcipher_page_cipher (
ctx=0x7fffc80186f8, for_ctx=1, pgno=1, mode=1, page_sz=1008,
in=0x7fffc80a78e8 "\004",
out=0x7fffc80187b8 "@D\360\242#\250\241\070}j=\251\207\367\267
r\332HN:\233\062\221\353/\211\224l#%\311\001\245\064\307{\353G[T\3
5\\<p\003dF\034Ҋ\020\333U}+Л\030\221\263`\304\016K\303w\247\324E\
21OK\375YL\205\307\067\345\367|\346]\361\t(9\004\324k\025!R1 \257$
\355\063\314\354\024\360\246Z}\002\340b\235J\376\355\275\202\324\3
7>\301\065\346B\366\"\037\321\330\341$\332\027s\365\245m\342\340N'
\224d\f\260\245H\357O\003\272qp?\001Ж\205\236\022Z{\201lJө\200}\t?
?$\220\004\364\330@5\341\327\334\304C\266\233\204\067u\213\221\301
205", <incomplete sequence \315>...)
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:19559
#6 0x00007fffe56e1719 in sqlite3Codec (iCtx=0x7fffc80186f8,
data=0x7fffc80a78d8, pgno=1, mode=6)
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:18222
#7 0x00007fffe571156a in pager_write_pagelist (
pPager=0x7fffc8018bc8, pList=0x7fffc80a7d10)
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:54451
#8 0x00007fffe56ec950 in sqlite3PagerCommitPhaseOne (
pPager=0x7fffc8018bc8, zMaster=0x0, noSync=0)
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:56441
#9 0x00007fffe56ecd2d in sqlite3BtreeCommitPhaseOne (
p=0x7fffc8018748, zMaster=0x0)
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:65073
#10 0x00007fffe5716333 in vdbeCommit (db=0x7fffc8006de8,
p=0x7fffc80857f8)
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:75811
#11 0x00007fffe5715776 in sqlite3VdbeHalt (p=0x7fffc80857f8)
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:76213
#12 0x00007fffe571adc1 in sqlite3VdbeExec (p=0x7fffc80857f8)
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:81388
#13 0x00007fffe56ef2b6 in sqlite3Step (p=0x7fffc80857f8)
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:78802
#14 0x00007fffe56eef14 in sqlite3_step (pStmt=0x7fffc80857f8)
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:78863
#15 0x00007fffe56e3566 in sqlcipher_execSql (db=0x7fffc8006de8,
pzErrMsg=0x7fffde7f8b08,
zSql=0x7fffc8017428 "CREATE TABLE encrypted.encryption_dummy_table(id INT PRIMARY KEY)")
at /home/jsw/node-tdlib/td/sqlite/sqlite/sqlite3.c:18469
---Type <return> to continue, or q <return> to quit---
Building an N-API addon for node
What OpenSSL version is used?
Is it 100% reproducible?
1.1.0f 25 May 2017
and yes.
Could you check that there is no components in the resulting binary which are compiled against/depends on OpenSSL 1.0.*?
I see... it is linked against libssl.so.1.0.2 and libcrypto.so.1.0.2
But I am wondering what caused this mistake, as I have compiled a library linked to libssl.so.1.1 before. I don't remember I have made changes to CMakeLists related to OpenSSL.
Remove and recreate the symlink in /usr/lib does not solve this, configure still says (found version "1.0.2l")
looks like an issue of apt. fixed.
So what version of openssl should be used?
Use 1.1.0f
libssl-dev not libssl1.0-dev
Seems it's not very accurate answer. As I understood openssl version that is used to compile tdlib should exactly match version that node.js was complied with (could be found in process.versions).
Nope. My Node.js uses 1.1.0h and my addon is built against 1.1.0f.
Any version above 1.1.0 is ok I think.
And, try not to rely on FFI too much. They bring more weird SEGV than addon does.
@wfjsw In my case building node and tglib against the same version of openssl resolved an issue. Probably some versions that differ with just letter are compatible.
TDLib can be built with any reasonable OpenSSL version. It supports 1.1.*, 1.0.* and even some 0.9.*. OpenSSL is binary compatible only between versions that differs in the third number, so if some part of a binary is compiled against 1.1.*, all other parts should be also compiled against 1.1.*.
Can confirm that I was getting a segmentation fault on the ENCRYPT step, same as OP above. Checked my node's OpenSSL version with node -p process.versions and it was 1.1. Looking into my Makefile I could see that it was 1.0. Also running openssl version returned 1.0. So I followed these instructions to update my OpenSSL to version 1.1 from 1.0. Nuked the build folder, started the whole process over and it worked.
Most helpful comment
Could you check that there is no components in the resulting binary which are compiled against/depends on OpenSSL 1.0.*?