haskell-crypto / cryptonite

lowlevel set of cryptographic primitives for haskell
Other
226 stars 139 forks source link

Segfault when running compiled with optimization: 0 #334

Closed sordina closed 2 years ago

sordina commented 4 years ago

I'll try to create a minimal reproduction, but I'll first create an issue in case this is known.

When building with

My application (and ghcide) crash with segfaults. Examining the core-dump I've found that cryptonite is where the fault is triggered:

Thread 14 Crashed:
0   graphql-websockets      0x000000010ca2954f gfmul_generic + 47
1   graphql-websockets      0x000000010ca20e47 ghash_add + 71
2   graphql-websockets      0x000000010ca26918 cryptonite_aesni_gcm_encrypt256 + 2648
3   graphql-websockets      0x000000010ca36a80 cryptonite_aes_gcm_encrypt + 96
4   graphql-websockets      0x000000010c9fca25 Lc2p3M_info + 197

I found this issue running a websockets connection with runClient from: https://hackage.haskell.org/package/websockets-0.12.7.1/docs/Network-WebSockets-Client.html

It's very possible that this isn't directly a cryptonite issue, but I thought I'd create an issue here to keep track of narrowing down the root-cause. Please let me know if you think it isn't valid and I'll happily move the issue elsewhere!

sordina commented 4 years ago

Simple reproduction is proving harder than anticipated.

robx commented 3 years ago

Oh seems this is the bug I've been tracing. My environment:

Then, the following segfaults with the same stack trace.

$ cabal run -O0 test-cryptonite -- -p AE1