Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault in sha1_compress() #13

Closed
Marcono1234 opened this issue Aug 8, 2021 · 2 comments
Closed

Segmentation fault in sha1_compress() #13

Marcono1234 opened this issue Aug 8, 2021 · 2 comments

Comments

@Marcono1234
Copy link

Marcono1234 commented Aug 8, 2021

Hello,
I am currently trying to build and run this project on Windows 10, but I am experiencing a segmentation fault in sha1_compress().
I am neither familiar with Rust nor with building and debugging of native applications, so maybe I made a mistake during some of the steps, any hints are appreciated.

  1. Initially running cargo build --release --no-default-features failed compiling sha1-asm with an error similar to what is described in MSVC support RustCrypto/asm-hashes#17. Therefore I uninstalled Rust with MSVC ABI and reinstalled it with GNU ABI.
  2. Then the build failed with
    error: failed to run custom build command for `sha1-asm v0.4.4`
    ...
    error occurred: Failed to find tool. Is `gcc.exe` installed? (see https://github.com/alexcrichton/cc-rs#compile-time-requirements for help)
    
  3. I followed that link, installed MSYS2 MinGW with gcc.
  4. The build still failed with the same error so I added C:\msys64\mingw64\bin (containing gcc) to the PATH environment variable.
  5. At some point I also got cannot find -lOpenCL, but that seems to be resolved now after I installed the NVIDIA Cuda Toolkit (and tinkered with the .cargo/config file?).
  6. cargo build --release and cargo install lucky_commit --locked (for commit 0000000) both now succeed.
  7. Running lucky_commit.exe within my local clone of this repository exits without any feedback.
    The exit code is -1073741819 (0xC0000005).
    Running it with too many arguments, e.g. lucky_commit.exe a b works correctly, it prints the usage help and has exit code 1.
  8. Using gdb.exe lucky_commit.exe from the MSYS terminal with export RUST_BACKTRACE=full shows:
    Thread 1 received signal SIGSEGV, Segmentation fault.
    0x00007ff63e52bc31 in sha1_compress ()
    (gdb) bt
    #0  0x00007ff63e52bc31 in sha1_compress ()
    #1  0x00007ff9979747b1 in ntdll!RtlFreeHeap ()
       from C:\WINDOWS\SYSTEM32\ntdll.dll
    #2  0x00007ff63e4bb68c in lucky_commit::HashSearchWorker::search ()
    #3  0x00007ff63e4a3106 in lucky_commit::run_lucky_commit ()
    #4  0x00007ff63e4a1d20 in lucky_commit::main ()
    #5  0x00007ff63e4daea6 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
    #6  0x00007ff63e4a7b87 in main ()
    

Do you have an idea what I might be doing wrong, or do you need more information?

@not-an-aardvark
Copy link
Owner

not-an-aardvark commented Aug 8, 2021

Hi, thanks for the detailed report. Unfortunately I'm not sure what the problem is, but my best guess is that the segfault is coming from the ASM sha1 hash implementation. It might be related to the MSVC issue you linked.

If you just want to get lucky-commit working, I think cargo install lucky_commit --features=sha-1/force-soft might work, since it causes the rust implementation of SHA1 to get used rather than the assembly implementation.

@Marcono1234
Copy link
Author

That works indeed, thanks a lot! And it is still extremely fast.

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

No branches or pull requests

2 participants