avast / retdec

RetDec is a retargetable machine-code decompiler based on LLVM.
https://retdec.com/
MIT License
8.04k stars 951 forks source link

Could not acquire a cryptographic context: Unknown error (0x7F) #73

Closed lab313ru closed 6 years ago

lab313ru commented 6 years ago

File: https://www.emu-land.net/consoles/psx/emuls/linux?act=dlmfile&id=1047&fid=2 This is Playstation 1 emulator for Linux. OS: Windows 10 x64.

s3rvac commented 6 years ago

Hi. Could you please provide more context so we can investigate this?

lab313ru commented 6 years ago

1) I'm using b32 release for Windows; 2) MSYS2 32; 3) This error happens only for that file; 4) No additional params: just "decompile.sh pSX" 5) I've deleted every file, but now I'm started x64 version of the decompiler, and it stucked up, I guess, at this state: -> running CopyPropagationOptimizer ( 151.32s ). So, you should try it to repeat my results.

s3rvac commented 6 years ago

Thank you. Could you please also provide the complete output (log) from the decompilation which failed with Could not acquire a cryptographic context: Unknown error? Or do you at least know in which decompilation tool/phase it failed?

it stucked up, I guess, at this state: -> running CopyPropagationOptimizer ( 151.32s ).

This phase often takes long time to finish, so you will either have to wait until it finishes or try to decompile only a part of the input binary file (as described e.g. here).

s3rvac commented 6 years ago

I was able to reproduce this issue (32b RetDec release, 64b MSYS2):

Warning: out of memory; trying to recover
Running phase: variable renaming [readable] ( 406.23s )
LLVM ERROR: Could not acquire a cryptographic context: The specified procedure could not be found.  (0x7F)

I strongly believe that this error is caused by insufficient memory.

lab313ru commented 6 years ago
I strongly believe that this error is caused by insufficient memory.

I guess so... Because 64b version never printed this text out.

s3rvac commented 6 years ago

Yes, the 64b version decompiles the file without any memory errors. 32b applications cannot allocate more than 2 or 4 GB of memory, depending on whether they were linked with /LARGEADDRESSAWARE. I suggest using the 64b version of the decompiler as there is not much we can do with the 32b version.

s3rvac commented 6 years ago

In commit 6003462ab9dd0e86b128a30aa96328a7d45170be, I have added the /LARGEADDRESSAWARE link flag to 32b builds of bin2llvmir and llvmir2hll so they can access up to 4 GB of virtual memory. I am closing this issue as there is probably nothing more we can do. When on 64b Windows, I recommend using the 64b build.