Compilation error:../Common/Core/vtkOStreamWrapper.h:108: memory exhausted

I got a compilation error:

 vtkWrapHierarchy-9.1: In /home/user/workspace/VTK/Common/Core/vtkOStreamWrapper.h:108: memory exhausted.
make[2]: *** [Common/Core/CMakeFiles/vtkCommonCore-hierarchy.dir/build.make:281: lib/x86_64-linux-gnu/vtk/hierarchy/VTK/vtkCommonCore-hierarchy.txt] Error 1
make[1]: *** [CMakeFiles/Makefile2:4211: Common/Core/CMakeFiles/vtkCommonCore-hierarchy.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

The line 108 of vtkOStreamWrapper is like this:

  // Accept std::string without a declaration.
    template <template <typename, typename, typename> class S> ---------------- line 108
    vtkOStreamWrapper& operator<<(const S<char, std::char_traits<char>, std::allocator<char>>& s)
    {
      return *this << reinterpret_cast<std_string const&>(s);
    }

1, Any suggestiont to fix this problem?

After some digging,I found

Common/Core/CMakeFiles/vtkCommonCore-hierarchy.dir/build.make:281

is this:

cd /home/alex/workspace/VTK/Debug/Common/Core && ../../bin/vtkWrapHierarchy-9.1 @/home/alex/workspace/vtk/Debug/Common/Core/CMakeFiles/vtkCommonCore-hierarchy.Debug.args -o /home/alex/workspace/vtk/Debug/lib/x86_64-linux-gnu/vtk/hierarchy/vtk/vtkCommonCore-hierarchy.txt /home/alex/workspace/vtk/Debug/Common/Core/CMakeFiles/vtkCommonCore-hierarchy.data @/home/alex/workspace/vtk/Debug/Common/Core/CMakeFiles/vtkCommonCore-hierarchy.depends.args

After running this line,same error got printed out as above.

2,Does this only print already generated compilation error?Or above error is actually generated by this line?

You are out of memory

Thanks,but systemo monitor says ‘NO’,10 GB memory left during compilation,no usage peaks.

Does it fails again on the same location if you rerun ?

Yes

Looks like a @ben.boeckel question then

It seems like there’s a rogue pointer around and it finally found a NUL way off into the weeds. Could you run the failing it under valgrind to see if it detects anything?

Cc: @dgobbi

I’ve never seen this error before or heard any reports about it. But you can probably work around it by using an #if to tell vtkWrapHierarchy to ignore that part of the header file,

+#if !defined(__VTK_WRAP__)
   // Accept std::string without a declaration.
   template <template <typename, typename, typename> class S>
   vtkOStreamWrapper& operator<<(const S<char, std::char_traits<char>, std::allocator<char>>& s)
   {
     return *this << reinterpret_cast<std_string const&>(s);
   }
+#endif

The vtkWrapHierarchy program has an embedded C++ parser, and for some reason it is failing to parse this operator<< template on your system. Which is strange, because it succeeds without any errors on my system and everyone else’s. My best guess is this: for your build of VTK, an extra header file is being included somewhere that #defines a macro for std_string or S or for one of the other identifiers that is used in the operator<< definition.

Edit: I ran the vtkWrapHierarchy command line under valgrind and it didn’t detect any issues.

valgrind --tool=memcheck bin/vtkWrapHierarchy-9.2 @Common/Core/CMakeFiles/vtkCommonCore-hierarchy.RelWithDebInfo.args -o /tmp/vtk-9.2/hierarchy/VTK/vtkCommonCore-hierarchy.txt Common/Core/CMakeFiles/vtkCommonCore-hierarchy.data @Common/Core/CMakeFiles/vtkCommonCore-hierarchy.depends.args

Admittedly, this was for VTK 9.2 rather than 9.1.

1 Like