[BUG]: C function named "uncompress" will not be executed
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
master
Problem description
There are three files. all.h defined a C function named "uncompress", and the function is implemented in all.c
- all.h
- extern "C" {
#endif
extern int uncompress(const char* f,char* f1);
#ifdef __cplusplus
}
- all.c
#include "all.h"
extern int uncompress(const char *file, char *uncfile){
return 1;
}
and a pybind11 interface test.cpp
- test.cpp
#include <pybind11/pybind11.h>
#include "all.h"
namespace py = pybind11;
PYBIND11_MODULE(libtest, m) {
m.doc() = "test"; // optional module docstring
m.def("uncompress",&uncompress,"test");
}
After compiling it to a library libtest.so, and call it in test.py by
import libtest
libtest.uncompress("a","b")
It will return -3 and gdb even can't entry this function. I debugged this problem, and found that it called a function uncompress@plt at address 0x7fe0ac66f3a8, but our function uncompress is at 0x7fe0ac735e15. That's very weird. The detail of them are
-exec info symbol 0x7fe0ac66f3a8
uncompress@plt in section .plt.got of libtest.so
-exec info symbol 0x7fe0ac735e15
uncompress in section .text of librtkbind.so
Seems there is a duplicate name function. I know I can change the name in my code, but I use the rtklib, they won't change. So how can I do?
Reproducible example code
There is a simple demo in https://github.com/ebhrz/pybind_issue.git, but the pybind11 header directory should be changed in the CMakeLists.txt.
Is this a regression? Put the last known working version here if it is.
Not a regression
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the linked demo and reviewing CMakeLists.txt, all.h, all.c, test.cpp, and test.py. Inspect why the call resolves to uncompress@plt instead of the implementation shown in all.c. Done means the reported behavior is explained and a supported fix or clear guidance lets the intended function be called without renaming it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100