Skip to content

Conversation

@lanthora
Copy link
Owner

@lanthora lanthora commented Nov 19, 2025

编译纯静态二进制后运行时大概率出错,怀疑是 musl 多线程同时加密解密时出现问题。尝试过每次使用 ctx 时 new, 并在使用后 free, 问题就会出现在 EVP_CIPHER_CTX_free。修改为全局锁后这个问题没有再出现。

coredumpctl info

Module /usr/bin/candy-service without build-id.
Stack trace of thread 1930:
#0  0x0000000000b7ab36 __restore_sigs (/usr/bin/candy-service + 0x77ab36)
#1  0x00000000005d6173 evp_cipher_free_int (/usr/bin/candy-service + 0x1d6173)
#2  0x00000000005d61f7 EVP_CIPHER_free (/usr/bin/candy-service + 0x1d61f7)
#3  0x00000000005d05f8 EVP_CIPHER_CTX_reset (/usr/bin/candy-service + 0x1d05f8)
#4  0x00000000005bfa86 _ZN5candy4Peer7encryptERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE (/usr/bin/candy-service + 0x1bfa86)
#5  0x00000000005c0415 _ZN5candy4Peer20sendHeartbeatMessageEv (/usr/bin/candy-service + 0x1c0415)
#6  0x00000000005c162f _ZN5candy4Peer4tickEv (/usr/bin/candy-service + 0x1c162f)
#7  0x00000000005bbc59 _ZN5candy11PeerManager4tickEv (/usr/bin/candy-service + 0x1bbc59)
#8  0x00000000005bbe09 _ZNSt6thread11_State_implINS_8_InvokerISt5tupleIJZN5candy11PeerManager15startTickThreadEvEUlvE_EEEEE6_M_runEv (/usr/bin/candy-service + 0x1bbe09)
#9  0x0000000000b5326d execute_native_thread_routine (/usr/bin/candy-service + 0x75326d)
#10 0x0000000000b81599 start (/usr/bin/candy-service + 0x781599)
ELF object binary architecture: AMD x86-64

@lanthora lanthora force-pushed the fix-openssl-crash branch 5 times, most recently from 6d4de2e to 45fd572 Compare November 20, 2025 06:33
@lanthora lanthora marked this pull request as ready for review November 20, 2025 06:43
@lanthora lanthora changed the title 修复 OpenSSL 多线程导致的崩溃 使用全局锁处理加密解密避免 OpenSSL 崩溃 Nov 20, 2025
@lanthora lanthora changed the title 使用全局锁处理加密解密避免 OpenSSL 崩溃 修复静态链接 OpenSSL 导致的崩溃 Nov 20, 2025
@lanthora lanthora merged commit 6290fef into master Nov 20, 2025
18 checks passed
@lanthora lanthora deleted the fix-openssl-crash branch November 20, 2025 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants