[odb-users] Bug in odb compiler using gcc-8 and boost headers

Dennis Proft dp-odb at dproft.de
Tue Oct 2 09:32:47 EDT 2018


i'm currently working on a project using odb together with boost on a
debian testing machine (exakt versions of involved packages are attached
below). I found a bug in the odb compiler, which crashes with an
"internal compiler error: Segmentation fault" (for complete output see
below) at a more or less random position in a header file. I tried the
2.4.0-version of odb from debian-testing and the beta 2.5.0-b.9 from a
fresh build2-build.

The error only occurs as soon as i include some boost headers (in my
example i used #include <boost/algorithm/string/split.hpp>). Otherwise
it compiles the cxx and hxx files fine. Using gdb i traced the error to
be a null pointer dereference in the function
parser::impl::collect(tree_node*) in odb-2.5.0-b.9/odb/parser.cxx:879.

I fixed it by inserting a check for the null pointer and simply
returning from the function because it looks like it ran into a dead end
during some tree traversal. Below, i included my "simple patch", but i'm
not sure if there are negative side effects. In my case it works.

Best regards,

-- details --
$ g++ --version
g++ (Debian 8.2.0-7) 8.2.0

$ dpkg -l | grep gcc-8
ii  gcc-8                                              8.2.0-7
ii  gcc-8-base:amd64                                   8.2.0-7
ii  gcc-8-multilib                                     8.2.0-7
ii  gcc-8-plugin-dev                                   8.2.0-7

$ dpkg -l | grep libboost-dev
ii  libboost-dev:amd64                       

(odb compiled using build2 and debug symbols ("b configure
$ /usr/local/bin/odb --version
ODB object-relational mapping (ORM) compiler for C++ 2.5.0-b.9

(Minimal example)
$ cat t.hpp
#include <boost/algorithm/string/split.hpp>

$ LANG=C /usr/local/bin/odb -d mysql t.hpp
*** WARNING *** there are active plugins, do not report this as a bug
unless you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_START_UNIT                | odb
PLUGIN_PRAGMAS                   | odb
PLUGIN_OVERRIDE_GATE             | odb
during IPA pass: *free_lang_data
In file included from /usr/local/include/odb/container-traits.hxx:211,
                 from <standard-odb-epilogue>:4:
/usr/local/include/odb/std-deque-traits.hxx:66:1: internal compiler
error: Segmentation fault
0x7fb12a03dbc6 parser::impl::collect(tree_node*)
0x7fb12a03de1f parser::impl::collect(tree_node*)
0x7fb12a041918 parser::impl::parse(tree_node*,
cutl::fs::basic_path<char> const&)
0x7fb12a041cab parser::parse(tree_node*, cutl::fs::basic_path<char> const&)
0x7fb12a036c1e gate_callback
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-8/README.Bugs> for instructions.

$ cat nullptr.diff
--- odb-gcc-8/odb-2.5.0-b.9/odb/parser.cxx	2018-05-26 17:16:34.000000000
+++ odb-gcc-X/odb-2.5.0-b.9/odb/parser.cxx	2018-09-26 22:40:47.577509308
@@ -876,6 +876,7 @@
 collect (tree ns)
   cp_binding_level* level = NAMESPACE_LEVEL (ns);
+  if (level == nullptr) return;
   tree decl = level->names;

   // Collect declarations.

More information about the odb-users mailing list