MantisBT - Community
View Issue Details
0027070Community[OCCT] OCCT:Data Exchangepublic2016-01-10 20:422018-06-29 21:21
Epy 
bugmaster 
normalcrash 
closedfixed 
x86-64Lubuntu15.10 x64
[OCCT] 6.8.0 
[OCCT] 7.3.0[OCCT] 7.3.0 
bugs step bug27070
0027070: Data Exchange - Segfault when transferring HLR-created shapes via STEPControl_Writer
I created the following small program to explore the outlines and hidden lines created by HLR. The program segfaults on all of the commented lines. I used the program with another STEP file which was also created by OCCT libraries.



#include <STEPControl_Reader.hxx>
#include <TopoDS_Shape.hxx>
#include <HLRBRep_Algo.hxx>
#include <gp_Ax2.hxx>
#include <gp_Dir.hxx>
#include <HLRAlgo_Projector.hxx>
#include <HLRBRep_HLRToShape.hxx>
#include <STEPControl_Writer.hxx>

int main(int argc, char **argv)
{
    if (argc < 2)
        return 1;

    STEPControl_Reader scr;
    scr.ReadFile(argv[1]);
    scr.TransferRoots();

    Handle(HLRBRep_Algo) hlr = new HLRBRep_Algo;
    hlr->Add(scr.OneShape());

    gp_Ax2 a1(gp::Origin(), gp_Dir(0, 1, 0));
    HLRAlgo_Projector proj(a1);
    hlr->Projector(proj);
    hlr->Update();
    hlr->Hide();
    HLRBRep_HLRToShape shapes(hlr);

    STEPControl_Writer scw;
    scw.Transfer(shapes.VCompound(), STEPControl_AsIs);
    // scw.Transfer(shapes.Rg1LineVCompound(), STEPControl_AsIs);
    // scw.Transfer(shapes.RgNLineVCompound(), STEPControl_AsIs);
    // scw.Transfer(shapes.OutLineVCompound(), STEPControl_AsIs);
    // scw.Transfer(shapes.IsoLineVCompound(), STEPControl_AsIs);
    scw.Transfer(shapes.HCompound(), STEPControl_AsIs);
    // scw.Transfer(shapes.Rg1LineHCompound(), STEPControl_AsIs);
    // scw.Transfer(shapes.RgNLineHCompound(), STEPControl_AsIs);
    // scw.Transfer(shapes.OutLineHCompound(), STEPControl_AsIs);
    // scw.Transfer(shapes.IsoLineHCompound(), STEPControl_AsIs);
    scw.Write("Ex7_HLRDump.stp");

    return 0;
}
pload XSDRAW
dall
stepwrite a a
No tags attached.
cxx Ex7_HLRDump.cxx (1,326) 2016-01-10 20:42
https://tracker.dev.opencascade.org/
? Ex1_ExtrudeAndCut.stp (22,551) 2016-01-10 20:42
https://tracker.dev.opencascade.org/
Issue History
2016-01-10 20:42EpyNew Issue
2016-01-10 20:42EpyAssigned To => msv
2016-01-10 20:42EpyFile Added: Ex7_HLRDump.cxx
2016-01-10 20:42EpyFile Added: Ex1_ExtrudeAndCut.stp
2016-01-11 00:43msvNote Added: 0049764
2016-01-11 00:43msvAssigned Tomsv => Epy
2016-01-11 00:43msvStatusnew => feedback
2016-01-11 00:43msvResolutionopen => no change required
2016-01-11 01:02EpyNote Added: 0049765
2016-01-11 10:03msvNote Added: 0049766
2016-01-11 10:03msvAssigned ToEpy => gka
2016-01-11 10:04msvCategoryOCCT:Modeling Algorithms => OCCT:Data Exchange
2017-08-14 16:16abvTarget Version => 7.3.0
2018-03-08 09:56gitNote Added: 0074365
2018-03-08 09:58abvNote Added: 0074366
2018-03-08 09:58abvStatusfeedback => resolved
2018-03-08 09:58abvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=18691#r18691
2018-03-08 13:58kgvSummarySegfault when transferring HLR-created shapes via STEPControl_Writer => Data Exchange - Segfault when transferring HLR-created shapes via STEPControl_Writer
2018-03-09 12:13abvResolutionno change required => fixed
2018-03-14 10:19abvNote Added: 0074460
2018-03-14 15:07gkaAssigned Togka => bugmaster
2018-03-14 15:07gkaStatusresolved => reviewed
2018-03-14 16:19bugmasterTest case number => bugs step bug27070
2018-03-14 16:23bugmasterNote Added: 0074480
2018-03-14 16:23bugmasterStatusreviewed => tested
2018-03-18 13:21bugmasterChangeset attached => occt master 0a0eec80
2018-03-18 13:21bugmasterStatustested => verified
2018-03-19 10:05gitNote Added: 0074591
2018-06-29 21:16aivFixed in Version => 7.3.0
2018-06-29 21:21aivStatusverified => closed

Notes
(0049764)
msv   
2016-01-11 00:43   
The sample program is incorrect, as it does not check the shapes for null before passing them for transferring.
(0049765)
Epy   
2016-01-11 01:02   
Very well, but it seems strange that STEPControl_Writer::Transfer() does not check to see if the input shape is null first.
(0049766)
msv   
2016-01-11 10:03   
Dear gka, what is your opinion? Do we need to implement protection against null shapes in Transfer method?
(0074365)
git   
2018-03-08 09:56   
Branch CR27070 has been created by abv.

SHA-1: 9fe3015bc4741de506eb9ecb52696c0091f34ff4


Detailed log of new commits:

Author: abv
Date: Thu Mar 8 09:56:01 2018 +0300

    0027070: Segfault when transferring HLR-created shapes via STEPControl_Writer
    
    Added protection against null shape on writing: status IFSelect_RetVoid will be returned in such case (instead of access violation)
(0074366)
abv   
2018-03-08 09:58   
Fix (protection against null shape) is pushed to CR27070, please review
(0074460)
abv   
2018-03-14 10:19   
The tests passed OK indeed, see Jenkins job CR27070-master-abv
(0074480)
bugmaster   
2018-03-14 16:23   
Combination -
OCCT branch : CR27070 SHA - 9fe3015bc4741de506eb9ecb52696c0091f34ff4
Products branch : master SHA - 4fd289ec73d35d02f23f3990c73b3acac9a60574
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian70-64:
OCCT
Total CPU difference: 18226.24999999965 / 18338.37999999957 [-0.61%]
Products
Total CPU difference: 7463.559999999991 / 7461.340000000009 [+0.03%]
Windows-64-VC10:
OCCT
Total CPU difference: 17843.83118279852 / 17653.338361698563 [+1.08%]
Products
Total CPU difference: 8007.858932099991 / 7990.761222500007 [+0.21%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
(0074591)
git   
2018-03-19 10:05   
Branch CR27070 has been deleted by kgv.

SHA-1: 9fe3015bc4741de506eb9ecb52696c0091f34ff4