Skip to content

Commit

Permalink
Archive debugging code related to python/cpython#103912 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf W. Grosse-Kunstleve committed May 23, 2023
1 parent 0e7ebbd commit 2ed89c1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pybind11/cpython-gh-103912/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/bash
if [ "$1" == "last_good" ]; then
PYINST=segfault_20230520_last_good
elif [ "$1" == "first_bad" ]; then
PYINST=segfault_20230520_first_bad
else
echo "Invalid argument: '$1'"
exit 1
fi
set -x
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
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
26 changes: 26 additions & 0 deletions pybind11/cpython-gh-103912/main_debugging.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// https://github.com/python/cpython/pull/103912#issuecomment-1559558193

#include <pybind11/embed.h>
#include <pybind11/pybind11.h>

namespace py = pybind11;

PYBIND11_EMBEDDED_MODULE(mi_debugging, m) {
struct Base1 {};
struct Base2 {};
struct Base12 : Base1, Base2 {};

py::class_<Base1> b1(m, "Base1");
py::class_<Base2> b2(m, "Base2");
py::class_<Base12, Base1, Base2>(m, "Base12");
}

int main() {
py::initialize_interpreter();

py::module_::import("mi_debugging");

py::finalize_interpreter();

return 0;
}

0 comments on commit 2ed89c1

Please sign in to comment.