pbhogan/scrypt — Issue #2: Segfault
Author: qerub
Created: 2011-10-26 13:54:56+00:00
State: open

Hello,

I get hit by segfaults when I try your library:

```
/Users/qerub/.rvm/gems/ruby-1.8.7-p334/gems/scrypt-1.0.3/lib/scrypt.rb:79: [BUG] Segmentation fault
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin11.2.0]

zsh: abort rackup
```

Here's the top of the stack:

```
#0 0x00007fff932d1e03 in memmove$VARIANT$sse42 ()
#1 0x00007fff8f822026 in SHA256_Update ()
#2 0x00000001006606cf in PBKDF2_SHA256 (passwd=0x0, passwdlen=0, salt=, saltlen=, c=1, buf=0x101109ff0 "", dkLen=128) at sha256.c:386
#3 0x000000010065daa5 in crypto_scrypt (passwd=0x0, passwdlen=0, salt=0x0, saltlen=0, N=16, r=256, p=1, buf=0x0, buflen=0) at crypto_scrypt-ref.c:258
#4 0x000000010065e4b2 in scryptenc_cpuperf (opps=0x7fff5fbf5010) at scryptenc_cpuperf.c:149
#5 0x000000010065df19 in calibrate (maxmem=, maxmemfrac=, maxtime=0.20000000000000001, n=0x7fff5fbf5070, r=0x7fff5fbf507c, p=0x7fff5fbf5078) at scrypt_calibrate.c:41
#6 0x000000010065e311 in sc_calibrate (self=, maxmem=, maxmemfrac=4321026880, maxtime=4321026640) at scrypt_ext.c:25
#7 0x0000000100028d16 in rb_call0 (klass=4320999920, recv=4320999960, id=38857, oid=38857, argc=3, argv=0x7fff5fbf5380, body=0x1018d3978, flags=) at eval.c:5928
```

And the error as reported by GDB:

```
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x00007ffe8c3a0490
0x00007fff932d1e03 in memmove$VARIANT$sse42 ()
```

Let me know if you need any more information.

Regards,
Christoffer