# New Ticket Created by Lloyd Fournier # Please include the string: [perl #132668] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=132668 >
I was trying to add RSA key generation using nativecall and OpenSSL but kept getting non-deterministic segfaults. golfed example: #nativessl.pl use NativeCall; sub gen-lib { $*VM.platform-library-name('ssl'.IO).Str } sub RSA_new(-->OpaquePointer) is native(&gen-lib) {...} sub RSA_generate_key_ex(OpaquePointer $rsa, int32 $bits, OpaquePointer $e, OpaquePointer $cb --> OpaquePointer) is native(&gen-lib) {...} sub BN_new(-->OpaquePointer) is native(&gen-lib) {...} sub BN_set_word(OpaquePointer $bn, uint32 $e --> int32) is native(&gen-lib) {...} sub BIO_s_mem(-->OpaquePointer) is native(&gen-lib) {...} sub PEM_write_bio_RSAPrivateKey(OpaquePointer $bio, OpaquePointer $rsa --> int32) is native(&gen-lib){...} sub BIO_new(OpaquePointer $method --> OpaquePointer) is native(&gen-lib){...}; { my uint32 $bits = 2048; my $bne = BN_new(); BN_set_word($bne, 3) || die; my $rsa = RSA_new(); RSA_generate_key_ex($rsa, $bits, $bne, Nil) || die; my $bio = BIO_new(BIO_s_mem()); PEM_write_bio_RSAPrivateKey($bio, $rsa); } bash-3.2$ while perl6 nativessl.pl; do echo "worked"; done Segmentation fault: 11 bash-3.2$ while perl6 nativessl.pl; do echo "worked"; done worked worked worked worked worked worked Segmentation fault: 11 bash-3.2$ while perl6 nativessl.pl; do echo "worked"; done worked worked worked worked Segmentation fault: 11 bash-3.2$