Open lihf8515 opened 3 years ago
Stumbled over this issue too and at me the program crashed without any exception.
I did some investigation and I could get it working when compiling with -d:nimDisableCertificateValidation
and creating the SslContext
without setting cert/key parameter (for sure, this is not a solution).
Furthermore I experienced also the crash when compiling with --opt:speed
parameter (also in debug build).
I guess the issue is regarding to c compiler optimization flags.
It crashes at this function call (SSL_CTX_use_certificate_chain_file
): https://github.com/nim-lang/Nim/blob/devel/lib/pure/net.nim#L551
I'm using Nim 1.4.6 and openssl version 1.0.2u.
Nim Compiler Version 1.4.6 [Linux: amd64]
Compiled at 2021-04-16
Copyright (c) 2006-2020 by Andreas Rumpf
Some testings resulted in, that all gcc optimization levels (-O1
to -O3
) crash the application, in constellation with OpenSSL and 32 bit build.
In my case it's caused by the -fomit-frame-pointer
optimization flag which is set in all optimization levels.
Workaround: Add --passC:-fno-omit-frame-pointer
when compiling your application.
In Windows,I wanted to use SSL to send the request, so I wrote the following simple little example. I compile with debug mode, and the program runs normally. But when I compile in Release mode, I can't run the program properly.
Example
Current Output
nim -v
In addition, I compiled with the following version, which runs normally in either Debug mode or Release mode. It seems that only the Nim 32bit version has a problem. Nim Compiler Version 1.4.0 [Windows: amd64] Nim Compiler Version 1.4.0 [Linux: AMD64]