segmentation fault on loading model

When loading a step file I get a segmentation fault. I've got the following debugging information. I'm afraid I cannot share the step file due to the sensitive nature of the design, but I'd love to assist on investigating this issue further. Any pointers would be appreciated since my knowledge of the opencascase codebase is still very limited.

My first assumption is that the member styleContext of StepVisual_ContextDependentOverRidingStyledItem is invalid, but the question is, why?

[2023-11-23 19:03:07.753151] [0x00007ffff3157780] [info]    opencascade version 7.7.0

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5bc66e0 in NCollection_Array1<StepVisual_StyleContextSelect>::Length (this=0x10) at /home/martijn/Downloads/opencascade-7.7.0/src/NCollection/NCollection_Array1.hxx:239
239   { return (myUpperBound-myLowerBound+1); }
(gdb) bt full
#0  0x00007ffff5bc66e0 in NCollection_Array1<StepVisual_StyleContextSelect>::Length (this=0x10) at /home/martijn/Downloads/opencascade-7.7.0/src/NCollection/NCollection_Array1.hxx:239
No locals.
#1  0x00007ffff5bc641e in StepVisual_ContextDependentOverRidingStyledItem::NbStyleContext (this=0x5555562e6380)
    at /home/martijn/Downloads/opencascade-7.7.0/src/StepVisual/StepVisual_ContextDependentOverRidingStyledItem.cxx:55
No locals.
#2  0x00007ffff5beeba4 in RWStepVisual_RWContextDependentOverRidingStyledItem::Share (this=0x7fffffffcd5f, ent=..., iter=...)
    at /home/martijn/Downloads/opencascade-7.7.0/src/RWStepVisual/RWStepVisual_RWContextDependentOverRidingStyledItem.cxx:147
        nbElem1 = 1
        nbElem4 = 32767
#3  0x00007ffff7b2299a in RWStepAP214_GeneralModule::FillSharedCase (this=0x555555790930, CN=78, ent=..., iter=...)
    at /home/martijn/Downloads/opencascade-7.7.0/src/RWStepAP214/RWStepAP214_GeneralModule.cxx:1864
        anent = {entity = 0x5555562e6380}
        tool = {<No data fields>}
#4  0x00007ffff54d56c6 in Interface_GeneralModule::FillShared (this=0x555555790930, casenum=78, ent=..., iter=...) at /home/martijn/Downloads/opencascade-7.7.0/src/Interface/Interface_GeneralModule.cxx:32
No locals.
#5  0x00007ffff54d80ce in Interface_Graph::Shareds (this=0x555555813150, ent=...) at /home/martijn/Downloads/opencascade-7.7.0/src/Interface/Interface_Graph.cxx:433
        iter = {_vptr.Interface_EntityIterator = 0x7ffff569f4f0 <vtable for Interface_EntityIterator+16>, thecurr = {entity = 0x5555558dbae0}, thelist = {entity = 0x555555811db0}}
        num = 459
        aCurEnt = {entity = 0x5555562e6380}
        module = {entity = 0x555555790930}
        CN = 78
#6  0x00007ffff54d81df in Interface_Graph::GetShareds (this=0x555555813150, ent=...) at /home/martijn/Downloads/opencascade-7.7.0/src/Interface/Interface_Graph.cxx:440
        aseq = {entity = 0x555555812fa0}
        iter = {_vptr.Interface_EntityIterator = 0x7ffff569f4f0 <vtable for Interface_EntityIterator+16>, thecurr = {entity = 0x5555558dbae0}, thelist = {entity = 0x555555811db0}}
#7  0x00007ffff54d6e71 in Interface_Graph::Evaluate (this=0x555555813150) at /home/martijn/Downloads/opencascade-7.7.0/src/Interface/Interface_Graph.cxx:156
        ent = {entity = 0x5555562e6380}
        iter = {_vptr.Interface_EntityIterator = 0x7ffff569f4f0 <vtable for Interface_EntityIterator+16>, thecurr = {entity = 0x0}, thelist = {entity = 0x0}}
--Type <RET> for more, q to quit, c to continue without paging--
        n = 143758
        i = 459
#8  0x00007ffff54d6826 in Interface_Graph::Interface_Graph (this=0x555555813150, amodel=..., theModeStat=false) at /home/martijn/Downloads/opencascade-7.7.0/src/Interface/Interface_Graph.cxx:83
No locals.
#9  0x00007ffff54dbf7f in Interface_HGraph::Interface_HGraph (this=0x555555813140, amodel=..., theModeStat=false) at /home/martijn/Downloads/opencascade-7.7.0/src/Interface/Interface_HGraph.cxx:51
No locals.
#10 0x00007ffff556cc0f in IFSelect_WorkSession::ComputeGraph (this=0x55555573aea0, enforce=false) at /home/martijn/Downloads/opencascade-7.7.0/src/IFSelect/IFSelect_WorkSession.cxx:451
        nb = 21845
#11 0x00007ffff556b73f in IFSelect_WorkSession::SetModel (this=0x55555573aea0, model=..., clearpointed=true) at /home/martijn/Downloads/opencascade-7.7.0/src/IFSelect/IFSelect_WorkSession.cxx:178
No locals.
#12 0x00007ffff556b999 in IFSelect_WorkSession::ReadFile (this=0x55555573aea0, filename=0x555555727f80 "input/XXXX.stp")
    at /home/martijn/Downloads/opencascade-7.7.0/src/IFSelect/IFSelect_WorkSession.cxx:215
        model = {entity = 0x5555558024c0}
        status = IFSelect_RetDone
#13 0x00007ffff559a91a in XSControl_Reader::ReadFile (this=0x7fffffffd468, filename=0x555555727f80 "input/XXXX.stp")
    at /home/martijn/Downloads/opencascade-7.7.0/src/XSControl/XSControl_Reader.cxx:125
        stat = 32767
#14 0x00007ffff7e98f93 in STEPCAFControl_Reader::ReadFile (this=0x7fffffffd460, theFileName=0x555555727f80 "input/XXXX.stp")
    at /home/martijn/Downloads/opencascade-7.7.0/src/STEPCAFControl/STEPCAFControl_Reader.cxx:343
No locals.
Dmitrii Pasukhin's picture

We be able to make workaround for this case.

But you need to find a STEP string with this kind of problem and share with us only a part of the file.

I need to see the ENTITY context_dependent_over_riding_styled_item - STEP Merged AP Library ( in your file.

I interested in last parameter it should be presented as a list. Could you share any specific representation of this list? I mean if you have a lot of one-style entity, i not needed all of the, Only different one.

Workaround be able to be created w/o this sample. but it will be better if you will share a problem enity with us.

Best regards, Dmitrii.

Martijn Berntsen's picture

I've found these two lines:


looking through the code I find this piece in RWStepVisual_RWContextDependentOverRidingStyledItem.cxx:

Handle(StepVisual_HArray1OfStyleContextSelect) aStyleContext;
StepVisual_StyleContextSelect aStyleContextItem;
Standard_Integer nsub5;
if (data->ReadSubList (num,5,"style_context",ach,nsub5)) {
  Standard_Integer nb5 = data->NbParams(nsub5);
  aStyleContext = new StepVisual_HArray1OfStyleContextSelect (1, nb5);
  for (Standard_Integer i5 = 1; i5 <= nb5; i5 ++) {
    //szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed
    if (data->ReadEntity (nsub5,i5,"style_context",ach,aStyleContextItem))

//--- Initialisation of the read entity ---

ent->Init(aName, aStyles, aItem, aOverRiddenStyle, aStyleContext);

It looks like 'data->ReadSubList' returns a false value, leaving 'aStyleContext' uninitialized. I'm not sure why this 'if' statement is put around 'data->ReadSubList' here, would it not make more sense to just initializing the list with 0 items?

here is some more information about the step file:

/* Generated by software containing ST-Developer
 * from STEP Tools, Inc. ( 

/* description */ ('',
'CAx-IF Rec.Pracs.---Representation and Presentation of Product Manufa
cturing Information (PMI)---4.0---2014-10-13'),
/* implementation_level */ '2;1');

/* name */ 'XXXX.stp',
/* time_stamp */ '2023-11-15T07:28:39+01:00',
/* author */ ('XXXX'),
/* organization */ (''),
/* preprocessor_version */ 'ST-DEVELOPER v19.2',
/* originating_system */ 'Autodesk Inventor 2023',
/* authorisation */ '');
Dmitrii Pasukhin's picture


"()" is out-of-ISO. In this case we will create a workaround. In your case you can do it just a little update a code that you send.

Best regards, Dmitrii.

Dmitrii Pasukhin's picture

This work around will be included into 7.8.0 (but not RC, only final release)

Best regards, Dmitrii.

Martijn Berntsen's picture

That's great, thanks for your assistance