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

FFI: segfault for conflicting names in C++ #3263

Open
joelberkeley opened this issue Apr 21, 2024 · 0 comments
Open

FFI: segfault for conflicting names in C++ #3263

joelberkeley opened this issue Apr 21, 2024 · 0 comments

Comments

@joelberkeley
Copy link
Contributor

joelberkeley commented Apr 21, 2024

This is a complex one. I'm not sure if it's a bug in Idris, Bazel (the build system), or my use of Bazel, but ohad asked me to raise an issue for visibility. If it's not useful, feel free to close.

In this mwe repo I create two functions to index into an int* in C++. They are identical except the names. One is my_index, the other index.

When I run this code, the call to index segfaults before it enters the C function. This might be because there is an existing POSIX function index. However, in my much larger project, I was not seeing an error until I made a large change to a lot of code but not that function (I did change build files, I'm not sure how relevant that is). Also, when I list targets in my shared lib with nm -D, I don't see a definition for index if I omit that function. Unfortunately nm doesn't give me the function signature.

Curiously, when making the mwe, I discovered I can't reproduce this with gcc/g++, as they complain about conflicting declarations of index.

@joelberkeley joelberkeley changed the title FFI: Conflicting names in C++ FFI: segfault for conflicting names in C++ Apr 21, 2024
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

1 participant