gdbを使えるようになりたい

デバッガは使えた方がいいですよ。ステップ実行とかね。まあ、ちゃんとしたソフトウェア開発っやったことないんで、いまいちピンとこないんですよね。でも、大事なことには変わりないです。頑張りましょう。

python3から、c++の共有ライブラリを呼び出すときにおこったバグの見つけ方

chatgptさんに聞きました。

The error message "munmap_chunk(): invalid pointer" typically indicates a memory corruption issue or a double-free error. It means that at some point during the program's execution, it is trying to deallocate memory that has already been freed or that was never allocated in the first place.

To identify the exact point where the issue occurs, you can follow these steps

1:Enable address sanitizer (ASAN) in your C++ code to help detect memory issues. You need to recompile your C++ library with ASAN flags (-fsanitize=address) and then rerun your Python script under GDB. ASAN will provide more detailed information about memory errors.

Modify your CMakeLists.txt to include ASAN flags:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address")

Then rebuild your C++ library.

2:
Run your Python script again under GDB with ASAN enabled:

gdb -ex r --args python3 crash.py