pybind / pybind/pybind11

[BUG]: debug module::import("numpy.core.multiarray") crash

Open
#4,476 1 comment 0 reactions 0 assignees View on GitHub

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
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.
image

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.