Skip Menu |
Report information
Id: 132668
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: lloyd.fourn [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: Lloyd Fournier <lloyd.fourn [...] gmail.com>
Subject: [NATIVECALL][SEGV] OpenSSL PEM_write_bio_RSAPrivateKey
Date: Sat, 30 Dec 2017 04:34:33 +0000
To: "rakudobug [...] perl.org" <rakudobug [...] perl.org>
Download (untitled) / with headers
text/plain 1.3k
I was trying to add RSA key generation using nativecall and OpenSSL but kept getting non-deterministic segfaults. golfed example:

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$ 


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org