Skip to content

Commit 2ed89c1

Browse files
committed
Archive debugging code related to python/cpython#103912 (comment)
1 parent 0e7ebbd commit 2ed89c1

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

pybind11/cpython-gh-103912/build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#! /usr/bin/bash
2+
if [ "$1" == "last_good" ]; then
3+
PYINST=segfault_20230520_last_good
4+
elif [ "$1" == "first_bad" ]; then
5+
PYINST=segfault_20230520_first_bad
6+
else
7+
echo "Invalid argument: '$1'"
8+
exit 1
9+
fi
10+
set -x
11+
g++ -o main_debugging.o -c -std=c++17 -O0 -g -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated -Wundef -Wnon-virtual-dtor -Wunused-result -Werror -I/usr/local/google/home/rwgk/forked/pybind11/include -I/usr/local/google/home/rwgk/usr_local_like/$PYINST/include/python3.12 main_debugging.cpp
12+
g++ -o main_debugging -L/usr/local/google/home/rwgk/usr_local_like/$PYINST/lib -rdynamic -O0 -g main_debugging.o -lpython3.12 -lpthread -ldl -lutil
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// https://github.com/python/cpython/pull/103912#issuecomment-1559558193
2+
3+
#include <pybind11/embed.h>
4+
#include <pybind11/pybind11.h>
5+
6+
namespace py = pybind11;
7+
8+
PYBIND11_EMBEDDED_MODULE(mi_debugging, m) {
9+
struct Base1 {};
10+
struct Base2 {};
11+
struct Base12 : Base1, Base2 {};
12+
13+
py::class_<Base1> b1(m, "Base1");
14+
py::class_<Base2> b2(m, "Base2");
15+
py::class_<Base12, Base1, Base2>(m, "Base12");
16+
}
17+
18+
int main() {
19+
py::initialize_interpreter();
20+
21+
py::module_::import("mi_debugging");
22+
23+
py::finalize_interpreter();
24+
25+
return 0;
26+
}

0 commit comments

Comments
 (0)