[BUG]: debug module::import("numpy.core.multiarray") crash
Open
Nobody has claimed this yet.
triage
- 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?
lastest
Problem description
I want to us pybind11 in c++ projects ,I just initial array_t object I get an error in module::import("numpy.core.multiarray"),and the error is not catch.

Reproducible example code
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "pocketfft_hdronly.h"
int main(int argc, char **argv)
{
FILE *fp;
fp = fopen("D://peakdetect//344.csv", "r");
std::vector<double>X;
std::vector<double>Y;
double xcoordinate = 0;
double ycoordinate = 0;
char headerx[10];;
char headery[10];
fseek(fp, 3, SEEK_CUR);
while (fscanf(fp, "%lf,%lf\n", //
&xcoordinate, &ycoordinate) != EOF) {
X.push_back(xcoordinate);
Y.push_back(ycoordinate);
}
fclose(fp);
auto in = py::array_t<double, py::array::c_style | py::array::forcecast>(X.size);
auto in_buffer = in.request();
std::memcpy(in_buffer.ptr, X.data(), X.size() * sizeof(double));
return 0;
}
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 shown C++ main using pybind11/numpy.h and the reported module::import("numpy.core.multiarray") path. Check the py::array_t construction and in.request() sequence, then capture the exact exception, Python/NumPy versions, and build environment. Done means a minimal reproducible case with a confirmed cause or resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, numpy, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100