`Illegal hardware instruction` on MacOs 10.13.5 with Xdmf3Readers
I'm trying to provide a variant to the VTK Portfile on macports that can be used to enable HDF5 readers (and Xdmf).
The problem I'm encountering is that, even if VTK compiles correctly, when I run a snippet of code that uses the vtkXdmf3Reader
, the execution "crashes" with:
llegal hardware instruction
if the Xdmf links to HDF5 data file.
You find all the build logs and additional details on Macports PR.
As a MWE, you can use:
#include "vtkNew.h"
#include "vtkXdmf3Reader.h"
int main(int argc, char** argv) {
vtkNew<vtkXdmf3Reader> reader;
reader->SetFileName("scalar.xmf");
reader->DebugOn();
reader->Update();
}
Reading an actual xmf
file that uses HDF5 to store data as this one.
I cannot understand if it's a bug in VTK or Apple Clang. I also tried to use GCC7, but it seems that the standard library on new MacOS is a bit clobbered and I encounter other errors during the compilation.
This is the backtrace of the execution. The problem seems associated to destruction of the XdmfRectilinearGrid
object.
Hope you can give me help :)
(lldb) target create "rayleigh"
Current executable set to 'rayleigh' (x86_64).
(lldb) run
Process 87150 launched: '/Users/.../git/x/HG/examples/c++/rayleigh/build/rayleigh' (x86_64)
Debug: In /opt/local/var/macports/build/_Users_..._git_macports-ports_graphics_vtk/vtk/work/VTK-7.1.1/Common/Core/vtkObject.cxx, line 861
vtkXdmf3Reader (0x10551b3e0): Registered by vtkCompositeDataPipeline (0x10551c650), ReferenceCount = 2
Process 87150 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
frame #0: 0x0000000100ce683b libvtkxdmf3.dylib`XdmfRectilinearGrid::~XdmfRectilinearGrid() + 47
libvtkxdmf3.dylib`XdmfRectilinearGrid::~XdmfRectilinearGrid:
-> 0x100ce683b <+47>: ud2
0x100ce683d <+49>: nop
0x100ce683e <+0>: pushq %rbp
0x100ce683f <+1>: movq %rsp, %rbp
Target 0: (rayleigh) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
* frame #0: 0x0000000100ce683b libvtkxdmf3.dylib`XdmfRectilinearGrid::~XdmfRectilinearGrid() + 47
frame #1: 0x00007ffeefbfef20
frame #2: 0x0000000100ce6854 libvtkxdmf3.dylib`XdmfRectilinearGrid::~XdmfRectilinearGrid() + 22
frame #3: 0x0000000100ce68ab libvtkxdmf3.dylib`XdmfRectilinearGrid::~XdmfRectilinearGrid() + 15
frame #4: 0x00000001018161cd libXdmfCore.dylib`boost::detail::shared_count::~shared_count() + 45
frame #5: 0x00000001017e4d96 libXdmfCore.dylib`std::__1::__tree<std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> >, std::__1::__map_value_compare<_xmlNode*, std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> >, std::__1::less<_xmlNode*>, true>, std::__1::allocator<std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> > > >::destroy(std::__1::__tree_node<std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> >, void*>*) + 50
frame #6: 0x00000001017e4d8d libXdmfCore.dylib`std::__1::__tree<std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> >, std::__1::__map_value_compare<_xmlNode*, std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> >, std::__1::less<_xmlNode*>, true>, std::__1::allocator<std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> > > >::destroy(std::__1::__tree_node<std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> >, void*>*) + 41
frame #7: 0x00000001017e4d81 libXdmfCore.dylib`std::__1::__tree<std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> >, std::__1::__map_value_compare<_xmlNode*, std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> >, std::__1::less<_xmlNode*>, true>, std::__1::allocator<std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> > > >::destroy(std::__1::__tree_node<std::__1::__value_type<_xmlNode*, boost::shared_ptr<XdmfItem> >, void*>*) + 29
frame #8: 0x00000001017e44c7 libXdmfCore.dylib`XdmfCoreReader::XdmfCoreReaderImpl::closeFile() + 31
frame #9: 0x00000001017e459b libXdmfCore.dylib`XdmfCoreReader::readItems(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const + 65
frame #10: 0x00000001017e48c7 libXdmfCore.dylib`XdmfCoreReader::read(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const + 27
frame #11: 0x0000000100ce5912 libvtkxdmf3.dylib`XdmfReader::read(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const + 14
frame #12: 0x0000000100c3ea32 libvtkIOXdmf3-7.1.1.dylib`vtkXdmf3Reader::Internals::Init(char const*, bool) + 2224
frame #13: 0x0000000100c37ffe libvtkIOXdmf3-7.1.1.dylib`vtkXdmf3Reader::Internals::PrepareDocument(vtkXdmf3Reader*, char const*, bool) + 96
frame #14: 0x0000000100c37ecf libvtkIOXdmf3-7.1.1.dylib`vtkXdmf3Reader::RequestDataObject(vtkInformationVector*) + 57
frame #15: 0x000000010495400f libvtkCommonExecutionModel-7.1.1.dylib`vtkExecutive::CallAlgorithm(vtkInformation*, int, vtkInformationVector**, vtkInformationVector*) + 69
frame #16: 0x00000001049499fe libvtkCommonExecutionModel-7.1.1.dylib`vtkCompositeDataPipeline::ExecuteDataObject(vtkInformation*, vtkInformationVector**, vtkInformationVector*) + 304
frame #17: 0x000000010494e44e libvtkCommonExecutionModel-7.1.1.dylib`vtkDemandDrivenPipeline::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) + 166
frame #18: 0x000000010496b01d libvtkCommonExecutionModel-7.1.1.dylib`vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) + 543
frame #19: 0x000000010494e968 libvtkCommonExecutionModel-7.1.1.dylib`vtkDemandDrivenPipeline::UpdateInformation() + 48
frame #20: 0x000000010496b438 libvtkCommonExecutionModel-7.1.1.dylib`vtkStreamingDemandDrivenPipeline::Update(int, vtkInformationVector*) + 36
frame #21: 0x0000000100020d1f rayleigh`main(argc=1, argv=0x00007ffeefbff4e8) at rayleigh.cpp:10
frame #22: 0x00007fff64ec9015 libdyld.dylib`start + 1
frame #23: 0x00007fff64ec9015 libdyld.dylib`start + 1
(lldb) exit