Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

read from nil error when running test_sodium.nim #3

Open
bobgus opened this issue Dec 3, 2016 · 9 comments
Open

read from nil error when running test_sodium.nim #3

bobgus opened this issue Dec 3, 2016 · 9 comments

Comments

@bobgus
Copy link

bobgus commented Dec 3, 2016

When I compile and run the test_sodium.nim program from the libsodium nimble pkg directory:

nim c -r ~/.nimble/pkgs/libsodium-0.1.0/test_sodium.nim

I get an error:

...
...
[Suite] hashing
  [OK] generic hashing
  [OK] generic multipart hashing
Traceback (most recent call last)
test_sodium.nim(167)     test_sodium
sodium.nim(621)          finalize
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Error: execution of an external program failed: '/Users/bobgus/.nimble/pkgs/libsodium-0.1.0/test_sodium '

I'm not sure this is a bug, or just that something is missing when compiling and running out of the pkgs directory.

@bobgus bobgus closed this as completed Dec 3, 2016
@bobgus bobgus reopened this Dec 3, 2016
@bobgus
Copy link
Author

bobgus commented Dec 5, 2016

I took a look at the travis-cl.org link and he is getting the exact same
error.

The routine 'finalize' is having a problem. I put an echo statement in
the code

(and it appears that the nil problem is occurring at the end of
the calling list. No problem with finalize with earlier items in the list.) bogus - was looking at wrong test

I commented out that whole test and everything else runs to completion.

@FedericoCeratto
Copy link
Owner

@bobgus I temporarily disabled the failing tests and now Travis CI is successful. Not having an OS X at hand makes the troubleshooting tricky.

@bobgus
Copy link
Author

bobgus commented Dec 5, 2016

Yes, that is what I did. It certainly kills the errors.

Perhaps the real solution to the problem (if there really is one) is to wait for another version of nim, clang, or macOS.

@bobgus
Copy link
Author

bobgus commented Dec 5, 2016

The error does not show on Linux?

@bobgus
Copy link
Author

bobgus commented Dec 6, 2016

I was looking at the previous test - with the loop. The line 168 error is coming from the next test. Since the key string starts out with nil (see line 165), perhaps the error is the 'expected' error.

It could be a more graceful test by surrounding line 168 with a try: except: with appropriate filter and assert. It could also echo "nil in key string detected"..

@bobgus
Copy link
Author

bobgus commented Dec 6, 2016

The try: except: also needs to be in the libsodium/sodium.nim around line 621, something like:

    try:
      rc = crypto_generichash_final(s, h, h_len)
    except:
      raise

I get a strange complaint:

libsodium/sodium.nim(621, 5) Error: identifier expected, but found 'keyword try'

The cause of this error is not so obvious to me at the moment.

@FedericoCeratto
Copy link
Owner

@bobgus was the try/except under the "let" block? It should be outside

@bobgus
Copy link
Author

bobgus commented Dec 6, 2016

Yes, indented as if it were part of the "let" block.

I moved it out of the let and now things are working more rationally, but I haven't figured out everything. I am reading and learning more of your code. An educational opportunity...

@bobgus
Copy link
Author

bobgus commented Dec 6, 2016

I did uninstall/install of lib sodium.

I took off the skip and # from generic multipart hashing and the test works fine (my bogus flailing from before made it suspect)

  [OK] generic multipart hashing

The generic multipart hashing key = nil is still a problem.

Traceback (most recent call last)
test_sodium.nim(169)     test_sodium
sodium.nim(621)          finalize
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants