We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Running httpclient compiled in a DLL crashes after the first execution:
Traceback (most recent call last) C:\Test\lib.nim(7) fnNet C:\Nim\lib\pure\httpclient.nim(1074) getContent C:\Nim\lib\pure\httpclient.nim(1069) get C:\Nim\lib\pure\httpclient.nim(1045) request C:\Nim\lib\pure\httpclient.nim(1029) request C:\Nim\lib\pure\httpclient.nim(979) requestAux C:\Nim\lib\pure\httpcore.nim(180) hasKey C:\Nim\lib\pure\collections\tables.nim(880) hasKey SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Here is a minimal example to reproduce the crash:
#include "windows.h" typedef void (*DLLPROC)(); int main() { HINSTANCE dll; dll = LoadLibrary("lib.dll"); if (dll) { DLLPROC fnNet = (DLLPROC) GetProcAddress(dll, "fnNet"); if (fnNet) { for (int i = 0; i < 100; i++) { (*fnNet)(); } } FreeLibrary(dll); } }
import httpclient proc fnNet*() {.exportc, dynlib.} = var httpClient = newHttpClient() try: discard httpClient.getContent("http://google.com") echo "ok" except: echo getCurrentExceptionMsg()
Without try/except the traceback is:
Traceback (most recent call last) C:\Test\lib.nim(6) fnNet C:\Nim\lib\pure\httpclient.nim(1074) getContent C:\Nim\lib\pure\httpclient.nim(1069) get C:\Nim\lib\pure\httpclient.nim(1045) request C:\Nim\lib\pure\httpclient.nim(1029) request C:\Nim\lib\pure\httpclient.nim(1006) requestAux C:\Nim\lib\pure\httpclient.nim(814) parseResponse C:\Nim\lib\pure\httpcore.nim(158) add SIGSEGV: Illegal storage access. (Attempt to read from nil?)
I tested this with Nim 1.2 and 1.2.2.
The text was updated successfully, but these errors were encountered:
I think you have to initialize the Nim GC in the main C app if you're using refc, although I never did that so I don't remember how :P
Sorry, something went wrong.
It's not necessary to call NimMain directly. The OS calls DllMain when the DLL is loaded with LoadLibrary, and NimMain is called by DllMain:
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved) { if(fwdreason == DLL_PROCESS_ATTACH) { NimMain(); } return 1; }
No branches or pull requests
Running httpclient compiled in a DLL crashes after the first execution:
Here is a minimal example to reproduce the crash:
C code (EXE):
Nim code (DLL):
Without try/except the traceback is:
I tested this with Nim 1.2 and 1.2.2.
The text was updated successfully, but these errors were encountered: