https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104523

            Bug ID: 104523
           Summary: G++ crash when compiling a simple module that includes
                    pybind11/stl.h
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juanjo at juanjoalvarez dot net
  Target Milestone: ---

// Info
Version of GCC: gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0
System type; Ubuntu 21.10 AMD64.

// Steps to reproduce

I have a very simple to reproduce segmentation fault on the compiler when using
C++20 modules.

Steps to reproduce:

1. Install PyBind11 header files (it's a header only lib). If you have Python
the simplest way to do it is to "pip install pybind11". Then get the include
path, it usually will be at (python site-packages dir)/pybind11/include.

2. Install Python development header files (usually called pythonx.y-dev on
most distros).

3. Compile the file below with (update the include paths):

c++ -std=c++20 -fmodules-ts \
  -I/home/juanjux/.local/lib/python3.9/site-packages/pybind11/include \
  -I/home/juanjux/.pyenv/versions/3.9.7/include/python3.9 \
  -c -o build/PyBind11Module.o PyBind11Module.cpp



// File PyBind11Module.cpp start -->

module;
#include <pybind11/stl.h>
export module PyBind11Module;

// <--- File end

Result on my system:

PyBind11Module.cpp:5:9: internal compiler error: Segmentation fault
    5 | export module PyBind11Module;
      |         ^~~~~~
0xb0c67e crash_signal
        ../../src/gcc/toplev.c:327
0x7f517144d51f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x9ca50d node_template_info
        ../../src/gcc/cp/module.cc:3895
0x9f0f5d get_originating_module_decl(tree_node*)
        ../../src/gcc/cp/module.cc:18327
0x9ded59 trees_out::decl_value(tree_node*, depset*)
        ../../src/gcc/cp/module.cc:7523
0x9df5c9 trees_out::decl_node(tree_node*, walk_kind)
        ../../src/gcc/cp/module.cc:8247
0x9e012a trees_out::tree_node(tree_node*)
        ../../src/gcc/cp/module.cc:9085
0x9ead9a module_state::write_cluster(elf_out*, depset**, unsigned int,
depset::hash&, unsigned int*, unsigned int*)
        ../../src/gcc/cp/module.cc:14633
0xa08f7a module_state::write(elf_out*, cpp_reader*)
        ../../src/gcc/cp/module.cc:17736
0x638d8a finish_module_processing(cpp_reader*)
        ../../src/gcc/cp/module.cc:19859
0xfa265e c_parse_final_cleanups()
        ../../src/gcc/cp/decl2.c:5175
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.

Reply via email to