-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Regression] SIGSEGV on 1.6.2 on C function call, works on 1.0.0 up to 1.6.0 #19378
Comments
Isn't this a duplicate of #19342 ? |
I think so, too. type
CXCursor* {.bycopy.} = object
kind*: byte
xdata*: cint
data*: array[3, pointer] is passed by reference but shouldn't. |
The SIGSEGV happens in cland_getTranslationUnitCursor(unit) function, specifically here https://github.com/llvm/llvm-project/blob/ef32c611aa214dea855364efd7ba451ec5ec3f74/clang/tools/libclang/CIndex.cpp#L4208 See PMunch/futhark#11 for some backlog |
It may be related: #19385 Sorry, I cannot test this issue locally, I don't get clang installed (I use windows and it is a hassle to use/install clang). |
In the repository you find two Dockerfiles, one for Ubuntu and one for Alpine-linux. Both should work on Docker for windows, too (untested though) Both replicate the problem |
I see, thanks |
Closing as a duplicate of #19342, as I said in https://forum.nim-lang.org/t/8796 that's the actual cause, not sure why you opened a separate issue. The crash happens in the libclang function - yes, but that's only because Nim passes an invalid number of arguments to it because it applies NRVO to a bycopy object. From the generated C code you can see that the N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
index__futhest_22 = clang_createIndex(((int) 0), ((int) 0));
unit__futhest_23 = clang_parseTranslationUnit(index__futhest_22, "src/header.h", ((NCSTRING*) NIM_NIL), ((int) 0), NIM_NIL, ((unsigned int) 0), ((unsigned int) 0));
{
if (!!(!((unit__futhest_23 == 0)))) goto LA3_;
failedAssertImpl__systemZassertions_56(((NimStringDesc*) &TM__FOvY5sgE9cCQaUMA1Y2m1uQ_2));
}
LA3_: ;
clang_getTranslationUnitCursor(unit__futhest_23, (&cursor__futhest_29));
clang_disposeTranslationUnit(unit__futhest_23);
echoBinSafe(TM__FOvY5sgE9cCQaUMA1Y2m1uQ_3, 1);
} |
I've been impatient, you're right. Thanks for the explanation. |
Forum post:
https://forum.nim-lang.org/t/8796
Repo with minimal test case and C version to compare
https://github.com/arkanoid87/futhest
Re-posting forum thread here:
I've been scratching my head solving a SIGSEGV on my machine when using futhark. I've reduced the problem to a self contained Nim and C files with no external nim packages involved, just plain C linkage.
The C program compiles and runs correctly, the Nim program goes SIGSEGV while calling C function, but they should be 1:1
You can find dockerfiles for reproducible builds and Makefile here: https://github.com/arkanoid87/futhest.
shared header.h
futhest.c
C Output:
futhest.nim
Nim output:
Additional Information
The text was updated successfully, but these errors were encountered: