Skip to content

Segfault on empty IFC file #238

@ysangkok

Description

@ysangkok

I just spent a couple of hours trying to debugging this issue before I found out I had accidentally truncated my IFC file to length 0.

I think Init is supposed to return false if the IFC file is invalid.

0x0000555555994b7e in IfcParse::IfcFile::load (this=0x0, data=...) at /home/janus/IfcOpenShell/src/ifcparse/IfcParse.cpp:897
897		if (tokens->stream->Tell() != data.offset_in_file()) {
(gdb) up
#1  0x00005555559954de in IfcEntityInstanceData::load_ (this=0x7fffe8000a80) at /home/janus/IfcOpenShell/src/ifcparse/IfcParse.cpp:983
983		file->load(*this);
(gdb) 
#2  0x00005555559955e0 in IfcEntityInstanceData::getArgument (this=0x7fffe8000a80, i=0) at /home/janus/IfcOpenShell/src/ifcparse/IfcParse.cpp:1001
1001			load_();
(gdb) 
#3  0x000055555599c868 in IfcParse::FileSchema::schema_identifiers[abi:cxx11]() const (this=0x7fffe8000a80) at /home/janus/IfcOpenShell/src/ifcparse/../ifcparse/../ifcparse/IfcSpfHeader.h:105
105		std::vector<std::string> schema_identifiers() const { return *getArgument(0); }
(gdb) 
#4  0x0000555555996791 in IfcParse::IfcFile::Init (this=0x7fffe80008c0, s=0x7fffe8000af0) at /home/janus/IfcOpenShell/src/ifcparse/IfcParse.cpp:1155
1155			schemas = _header.file_schema().schema_identifiers();
(gdb) 
#5  0x0000555555996592 in IfcParse::IfcFile::Init (this=0x7fffe80008c0, fn="tifc") at /home/janus/IfcOpenShell/src/ifcparse/IfcParse.cpp:1128
1128		return IfcFile::Init(new IfcSpfStream(fn));
(gdb) 
#6  0x00005555555c5043 in <lambda()>::operator() (__closure=0x555555fda198) at FLTK/design.cxx:775
775	        if (!ctxp->file->Init(filename)) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions