DiscussionsIssue archiveOCCT:Modeling Data

Archived issue #0025706

SIGSEGV after making existing BSplineCurve rational

CommunityOCCT:Modeling Dataclosed22 public notes

Search issues

Description

when a non-rational BSplineCurve of Degree 2 is made rational by changing a weight, rebuilding the cache fails resulting in a SIGSEGV when creating an edge.

It seems that Geom_BSplineCurve::ValidateCache does not account for a curve becoming rational. BSplCLib::BuildCache modifies the cacheweights which have not been initialized.

Steps to reproduce

bugs moddata_3 bug25706_1
bugs moddata_3 bug25706_2
bugs moddata_3 bug25706_3

Additional information

original report: http://forum.freecadweb.org/viewtopic.php?f=22&t=9312&p=75625#p75616

#0 0x00007fff7b804dad in TColStd_Array1OfReal::ChangeValue (this=0x10,
    Index=1) at occt/inc/TCollection_Array1.lxx:144
#0000001 0x00007fff7b804cb2 in TColStd_Array1OfReal::operator() (this=0x10, Index=1)
    at occt/inc/TColStd_Array1OfReal.hxx:68
#0000002 0x00007fff79fae298 in BSplCLib::BuildCache (U=0, SpanDomain=1, Periodic=0,
    Degree=2, FlatKnots=..., Poles=..., Weights=..., CachePoles=...,
    CacheWeights=...)
    at occt/inc/BSplCLib_CurveComputation.gxx:1071
#3 0x00007fff7a406a2a in Geom_BSplineCurve::ValidateCache (this=0x3833550,
    Parameter=0)
    at occt/src/Geom/Geom_BSplineCurve.cxx:1263
#4 0x00007fff7a408b06 in Geom_BSplineCurve::D0 (this=0x3833550, U=0, P=...)
    at occt/src/Geom/Geom_BSplineCurve_1.cxx:191
#5 0x00007fff7a431751 in Geom_Curve::Value (this=0x3833550, U=0)
    at occt/src/Geom/Geom_Curve.cxx:57
#6 0x00007fff77aef1fc in BRepLib_MakeEdge::Init (this=0x7fffffffae08, CC=...,
    VV1=..., VV2=..., pp1=0, pp2=1)
    at occt/src/BRepLib/BRepLib_MakeEdge.cxx:816
#0000007 0x00007fff77aee929 in BRepLib_MakeEdge::Init (this=0x7fffffffae08, C=...,
    p1=0, p2=1)
    at occt/src/BRepLib/BRepLib_MakeEdge.cxx:666
#0000008 0x00007fff77aedfc3 in BRepLib_MakeEdge::BRepLib_MakeEdge (this=
    0x7fffffffae08, L=..., p1=0, p2=1)
    at occt/src/BRepLib/BRepLib_MakeEdge.cxx:498
#0000009 0x00007fff77b2b1a9 in BRepBuilderAPI_MakeEdge::BRepBuilderAPI_MakeEdge (
    this=0x7fffffffadd0, L=..., p1=0, p2=1)
    at occt/src/BRepBuilderAPI/BRepBuilderAPI_MakeEdge.cxx:412

Public activity

22 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: azv
Date: Wed Jan 14 10:00:06 2015 +0300

    0025706: SIGSEGV after making existing BSplineCurve rational
    
    1. Eliminated exception after conversion non-rational B-spline to rational
    2. Implemented DRAW command setweight to change weights of B-spline
    3. Test cases were added
02Commenter 2
Branch CR25706 is ready for review
03Commenter 3
- I think it is better to maintain cacheweights array in ValidateCache method.

- In the function of draw command setweight, please generate error (in cout) if index2 is not given but the object is of type surface, otherwise the user will get exception.
Also, generate error message at the end if the object is not of expected type, otherwise the user will not understand what happened.

- Split the long literal string:
"setweight curve/surf index1 [index2] weight\n changes a weight of a pole of B-spline curve/surface (index2 is useful for surfaces only)"
=>
"setweight curve/surf index1 [index2] weight"
"\n\t\tchanges a weight of a pole of B-spline curve/surface (index2 is useful for surfaces only)"
04Commenter 4
In the test scripts, you set the variable 2dviewer. In order it to work, it is needed to have a draw variable named "result". It is according to the logic of the file tests\bugs\end:
if { [isdraw result] } {
  if { [info exists 2dviewer] } {
...
05Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: azv
Date: Wed Jan 14 10:00:06 2015 +0300

    0025706: SIGSEGV after making existing BSplineCurve rational
    
    1. Eliminated exception after conversion non-rational B-spline to rational
    2. Implemented DRAW command setweight to change weights of B-spline
    3. Test cases were added
06Commenter 6
Branch CR25706_1 is ready for review
07Commenter 7
Please in setweight command redirect error message to cout instead of di. The user must see the error message unconditionally.
08Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
09Commenter 9
Reviewed.
10Commenter 2
Branch [archived branch] has been created by Commenter 3.

[revision removed]


Detailed log of new commits:

Author: azv
Date: Wed Jan 14 10:00:06 2015 +0300

    0025706: SIGSEGV after making existing BSplineCurve rational
    
    1. Eliminated exception after conversion non-rational B-spline to rational
    2. Implemented DRAW command setweight to change weights of B-spline
    3. Test cases were added

Author: azv
Date: Wed Jan 14 17:26:30 2015 +0300

    0025582: SIGSEGV in thrusections of circle segments
    
    1. Implemented using of trimmed circular curve
    2. Added test case

Author: azv
Date: Tue Jan 13 17:44:38 2015 +0300

    0025578: SIGSEGV in BRepSweep_Rotation in case of singularities
    
    Eliminating degenerated edges

Author: azv
Date: Fri Jan 16 10:32:51 2015 +0300

    0025711: Get rid of static variable islambdadefined in AppParCurves_BSpGradient.gxx
11Commenter 3
Branch CR25706_2 contains commits from issues 25711, 25578, 25582, 25706.
12Commenter 3
Dear Commenter 1,
Branch CR25706_2 (contains CR25711, CR25578, CR25582, CR25706_1) from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested in Release mode.
[revision removed]

Number of compiler warnings:

occt component :
Linux: 18 (18 on master)
Windows: 0 (0 on master)

products component :
Linux: 11 (11 on master)
Windows: 1 (1 on master)

Regressions/Differences:
bugs modalg_5 bug25210
thrusection not_solids Q1 Q2 Q4 Q5 Q7 Q8 R4 R8 S7 T2 U1 U5 V4 V8 W4 W5
thrusection specific A1 A2 A5 A6 A9 B1 E5 E6 E9 F1 G3 G4 G5 G6
http://occt-tests/CR25706-2-master-occt/Debian60-64/summary.html
http://occt-tests/CR25706-2-master-occt/Windows-32-VC10/summary.html

Testing cases:
bugs modalg_5 bug25578 - OK
http://occt-tests/CR25706-2-master-occt/Debian60-64/bugs/modalg_5/bug25578.html
http://occt-tests/CR25706-2-master-occt/Windows-32-VC10/bugs/modalg_5/bug25578.html

bugs modalg_5 bug25582 - OK
http://occt-tests/CR25706-2-master-occt/Debian60-64/bugs/modalg_5/bug25582.html
http://occt-tests/CR25706-2-master-occt/Windows-32-VC10/bugs/modalg_5/bug25582.html

bugs moddata_3 bug25706_1 - OK
http://occt-tests/CR25706-2-master-occt/Debian60-64/bugs/moddata_3/bug25706_1.html
http://occt-tests/CR25706-2-master-occt/Windows-32-VC10/bugs/moddata_3/bug25706_1.html

bugs moddata_3 bug25706_2 - OK
http://occt-tests/CR25706-2-master-occt/Debian60-64/bugs/moddata_3/bug25706_2.html
http://occt-tests/CR25706-2-master-occt/Windows-32-VC10/bugs/moddata_3/bug25706_2.html

bugs moddata_3 bug25706_3 - OK
http://occt-tests/CR25706-2-master-occt/Debian60-64/bugs/moddata_3/bug25706_3.html
http://occt-tests/CR25706-2-master-occt/Windows-32-VC10/bugs/moddata_3/bug25706_3.html

Testing on Linux:
Total MEMORY difference: 370019996 / 369608324
Total CPU difference: 48902.81000000011 / 46823.18000000004

Testing on Windows:
Total MEMORY difference: 275969040 / 276683660
Total CPU difference: 33355.984375 / 39959.984375

There are not differences in images found by testdiff.
13Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: azv
Date: Fri Jan 23 15:55:56 2015 +0300

    0025582: SIGSEGV in thrusections of circle segments
    
    Eliminating regressions

14Commenter 14
Dear Mikhail,

The regressions were caused by the fix for issue #0025582. I have pushed my changes into CR25706_2. Could you, please, review it?
15Commenter 15
Reviewed.
16Commenter 2
Branch [archived branch] has been updated forcibly by Commenter 3.

[revision removed]
17Commenter 2
Branch [archived branch] has been updated by Commenter 3.

[revision removed]


Detailed log of new commits:

Author: Commenter 3
Date: Mon Jan 26 12:19:58 2015 +0300

    Fixed compilation warning ('di' : unreferenced formal parameter).

18Commenter 3
Dear Commenter 1,
Branch CR25706_2(contains CR25711, CR25578, CR25582, CR25706_1) from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested in Release mode.
[revision removed]

Number of compiler warnings:

occt component :
Linux: 18 (18 on master)
Windows: 1 (0 on master) - fixed

products component :
Linux: 11 (11 on master)
Windows: 1 (1 on master)

Regressions/Differences:
No regressions

Testing cases:
bugs modalg_5 bug25578 - OK

bugs modalg_5 bug25582 - OK
http://occt-tests/CR25706-2-master-occt/Debian60-64/bugs/modalg_5/bug25582.html [^]
http://occt-tests/CR25706-2-master-occt/Windows-32-VC10/bugs/modalg_5/bug25582.html [^]

bugs moddata_3 bug25706_1 - OK
http://occt-tests/CR25706-2-master-occt/Debian60-64/bugs/moddata_3/bug25706_1.html [^]
http://occt-tests/CR25706-2-master-occt/Windows-32-VC10/bugs/moddata_3/bug25706_1.html [^]

bugs moddata_3 bug25706_2 - OK
http://occt-tests/CR25706-2-master-occt/Debian60-64/bugs/moddata_3/bug25706_2.html [^]
http://occt-tests/CR25706-2-master-occt/Windows-32-VC10/bugs/moddata_3/bug25706_2.html [^]

bugs moddata_3 bug25706_3 - OK
http://occt-tests/CR25706-2-master-occt/Debian60-64/bugs/moddata_3/bug25706_3.html [^]
http://occt-tests/CR25706-2-master-occt/Windows-32-VC10/bugs/moddata_3/bug25706_3.html [^]

Testing on Linux:
Total MEMORY difference: 369759752 / 370114884
Total CPU difference: 53939.91000000013 / 51750.710000000094

Testing on Windows:
Total MEMORY difference: 276226856 / 275769192
Total CPU difference: 51231.875 / 38148.296875

There are not differences in images found by testdiff.

19Commenter 2
Branch [archived branch] has been updated by Commenter 3.

[revision removed]


Detailed log of new commits:

Author: Commenter 3
Date: Mon Jan 26 16:07:52 2015 +0300

    Added test bugs/modalg_5/bug25578

20Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
21Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
22Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]