MantisBT - Community
View Issue Details
0032495Community[OCCT] OCCT:Codingpublic2021-07-28 05:582021-09-04 16:28
galbramc 
bugmaster 
normalminor 
verifiedfixed 
MacOSX
[OCCT] 6.7.0 
[OCCT] 7.6.0* 
Not required
0032495: Coding rules - eliminate CLang UndefinedBehaviorSanitizer warnings
src/NCollection/NCollection_Array1.hxx:405:31: runtime error: applying non-zero offset 8 to null pointer

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/NCollection/NCollection_Array1.hxx:405:31 in

src/AdvApp2Var/AdvApp2Var_SysBase.cxx:840:3: runtime error: applying non-zero offset 140341856688136 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_SysBase.cxx:840:3 in
src/AdvApp2Var/AdvApp2Var_SysBase.cxx:847:3: runtime error: applying non-zero offset 140341856692704 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_SysBase.cxx:847:3 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6488:50: runtime error: applying non-zero offset 140341856688144 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6488:50 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6495:62: runtime error: applying non-zero offset 140341856688144 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6495:62 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6496:23: runtime error: applying non-zero offset 140341856688400 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6496:23 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6511:25: runtime error: applying non-zero offset 140341856688400 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6511:25 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6511:39: runtime error: applying non-zero offset 140341856689840 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6511:39 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6526:6: runtime error: applying non-zero offset 140341856690128 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6526:6 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6526:20: runtime error: applying non-zero offset 140341856692176 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6526:20 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6541:22: runtime error: applying non-zero offset 140341856689840 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6541:22 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6541:44: runtime error: applying non-zero offset 140341856692176 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6541:44 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6551:59: runtime error: applying non-zero offset 140341856692176 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6551:59 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6552:20: runtime error: applying non-zero offset 140341856688400 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6552:20 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6580:12: runtime error: applying non-zero offset 140341856692176 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6580:12 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6581:12: runtime error: applying non-zero offset 140341856688400 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6581:12 in
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6584:40: runtime error: applying non-zero offset 140341856692176 to null pointer
Compile on macOS Big Sur with Xcode 12.2 (clang 12.0.5) using the flags

-fsanitize=undefined -fno-omit-frame-pointer

and run the test suite.
No tags attached.
child of 0023952closed apn Improving thread-safety of intersections, approximations and other modeling algorithms 
Issue History
2021-07-28 05:58galbramcNew Issue
2021-07-28 05:58galbramcAssigned To => kgv
2021-07-28 09:26kgvProduct Version7.5.1 => 7.5.0
2021-07-28 09:26kgvTarget Version => 7.6.0*
2021-07-28 09:26kgvSummaryXcode 12.2 UndefinedBehaviorSanitizer reports new warnings => Coding rules - eliminate CLang UndefinedBehaviorSanitizer warnings
2021-07-28 09:26kgvDescription Updatedbug_revision_view_page.php?rev_id=25541#r25541
2021-07-28 09:27kgvDescription Updatedbug_revision_view_page.php?rev_id=25542#r25542
2021-07-28 09:35gitNote Added: 0102843
2021-07-28 09:38kgvRelationship addedchild of 0023952
2021-07-28 09:38kgvProduct Version7.5.0 => 6.7.0
2021-07-28 10:37gitNote Added: 0102844
2021-07-28 11:20gitNote Added: 0102845
2021-07-28 11:21gitNote Added: 0102846
2021-07-28 12:30kgvNote Added: 0102848
2021-07-28 12:30kgvAssigned Tokgv => mkrylova
2021-07-28 12:30kgvStatusnew => assigned
2021-07-28 12:31kgvNote Edited: 0102848bug_revision_view_page.php?bugnote_id=102848#r25544
2021-07-30 12:03mkrylovaNote Added: 0102886
2021-07-30 16:05galbramcNote Added: 0102892
2021-07-30 16:09kgvNote Added: 0102893
2021-07-30 16:19galbramcNote Added: 0102894
2021-07-30 16:27kgvNote Added: 0102895
2021-07-30 16:31galbramcNote Added: 0102896
2021-07-30 18:21mkrylovaNote Edited: 0102886bug_revision_view_page.php?bugnote_id=102886#r25572
2021-08-04 12:23gitNote Added: 0102972
2021-08-04 12:26gitNote Added: 0102973
2021-08-04 14:25gitNote Added: 0102977
2021-08-04 17:08mkrylovaNote Added: 0102980
2021-08-04 18:02galbramcNote Added: 0102985
2021-08-04 18:02galbramcNote Edited: 0102985bug_revision_view_page.php?bugnote_id=102985#r25579
2021-08-06 16:05mkrylovaNote Added: 0103035
2021-08-17 00:04galbramcNote Added: 0103247
2021-09-01 15:40gitNote Added: 0103632
2021-09-01 21:33mkrylovaNote Added: 0103649
2021-09-01 21:34mkrylovaNote Added: 0103650
2021-09-01 21:34mkrylovaAssigned Tomkrylova => kgv
2021-09-01 21:34mkrylovaStatusassigned => resolved
2021-09-01 22:42galbramcNote Added: 0103651
2021-09-02 00:01gitNote Added: 0103654
2021-09-02 10:17gitNote Added: 0103660
2021-09-02 13:38kgvNote Added: 0103672
2021-09-02 13:38kgvAssigned Tokgv => galbramc
2021-09-02 13:38kgvStatusresolved => feedback
2021-09-03 16:49galbramcNote Added: 0103730
2021-09-03 16:56kgvNote Added: 0103731
2021-09-03 16:56kgvAssigned Togalbramc => bugmaster
2021-09-03 16:56kgvStatusfeedback => reviewed
2021-09-03 17:19mkrylovaNote Edited: 0103650bug_revision_view_page.php?bugnote_id=103650#r25687
2021-09-04 14:27smoskvinNote Added: 0103764
2021-09-04 14:27smoskvinStatusreviewed => tested
2021-09-04 14:36bugmasterChangeset attached => occt master 3016a390
2021-09-04 14:36bugmasterStatustested => verified
2021-09-04 14:36bugmasterResolutionopen => fixed
2021-09-04 14:59gitNote Added: 0103794
2021-09-04 15:00gitNote Added: 0103795
2021-09-04 15:00gitNote Added: 0103796
2021-09-04 15:00gitNote Added: 0103797
2021-09-04 16:28smoskvinTest case number => Not required

Notes
(0102843)
git   
2021-07-28 09:35   
Branch CR32495 has been created by kgv.

SHA-1: d4c5c23c132f4cf329ed23dfb164bd451382d2ba


Detailed log of new commits:

Author: kgv
Date: Wed Jul 28 09:32:34 2021 +0300

    0032495: Coding rules - eliminate CLang UndefinedBehaviorSanitizer warnings
(0102844)
git   
2021-07-28 10:37   
Branch CR32495 has been updated forcibly by kgv.

SHA-1: 415031c1e41bdd73762ca1d4f04e8e097a4e721f
(0102845)
git   
2021-07-28 11:20   
Branch CR32495 has been updated forcibly by kgv.

SHA-1: db51fae183b8dc8dc6f65a469fbf916f2fedbf7b
(0102846)
git   
2021-07-28 11:21   
Branch CR32495 has been updated forcibly by kgv.

SHA-1: 0637b663978689c05f02d7322b91c52ef627b6ac
(0102848)
kgv   
2021-07-28 12:30   
(edited on: 2021-07-28 12:31)
Maria, a draft for AdvApp2Var_SysBase.cxx has been pushed to CR32495.
Please try propagating fix to AdvApp2Var_ApproxF2var.cxx (see all uses of variable `wrkar`).

It seems these are remnants of weird logic with memory jumps / offsets.
AdvApp2Var code is too large to revise the whole logic, so lets just try fix warning.

(0102886)
mkrylova   
2021-07-30 12:03   
(edited on: 2021-07-30 18:21)
Analysis

(0102892)
galbramc   
2021-07-30 16:05   
I just realized my initial description was not complete. Here is the complete list of warnings. I can also any fixes if you would like me to.

src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6488:50: runtime error: applying non-zero offset 140552806553616 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6495:62: runtime error: applying non-zero offset 140552806553616 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6496:23: runtime error: applying non-zero offset 140552806553872 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6511:25: runtime error: applying non-zero offset 140552806553872 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6511:39: runtime error: applying non-zero offset 140552806555312 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6526:6: runtime error: applying non-zero offset 140552806555600 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6526:20: runtime error: applying non-zero offset 140552806557648 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6541:22: runtime error: applying non-zero offset 140552806555312 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6541:44: runtime error: applying non-zero offset 140552806557648 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6551:59: runtime error: applying non-zero offset 140552806557648 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6552:20: runtime error: applying non-zero offset 140552806553872 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6580:12: runtime error: applying non-zero offset 140552806557648 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6581:12: runtime error: applying non-zero offset 140552806553872 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6584:40: runtime error: applying non-zero offset 140552806557648 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6592:53: runtime error: applying non-zero offset 140552806553872 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6592:67: runtime error: applying non-zero offset 140552806557648 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6599:3: runtime error: applying non-zero offset 140552806557648 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3518:44: runtime error: applying non-zero offset 140552806598160 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3527:39: runtime error: applying non-zero offset 140552806598736 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3527:53: runtime error: applying non-zero offset 140552806598160 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3537:44: runtime error: applying non-zero offset 140552806598448 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3546:39: runtime error: applying non-zero offset 140552806600176 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3546:53: runtime error: applying non-zero offset 140552806598448 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3557:51: runtime error: applying non-zero offset 140552806598736 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3558:3: runtime error: applying non-zero offset 140552806600176 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3558:17: runtime error: applying non-zero offset 140552806598160 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3558:31: runtime error: applying non-zero offset 140552806598448 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3813:63: runtime error: applying non-zero offset 140552806648336 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3817:63: runtime error: applying non-zero offset 140552806650384 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3825:55: runtime error: applying non-zero offset 140552806664336 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3826:55: runtime error: applying non-zero offset 140552806664464 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3834:47: runtime error: applying non-zero offset 140552806648336 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3834:61: runtime error: applying non-zero offset 140552806650384 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3835:9: runtime error: applying non-zero offset 140552806664336 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3835:23: runtime error: applying non-zero offset 140552806664464 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3835:37: runtime error: applying non-zero offset 140552806664592 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3835:51: runtime error: applying non-zero offset 140552806652432 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3835:65: runtime error: applying non-zero offset 140552806658576 to null pointer
(0102893)
kgv   
2021-07-30 16:09   
galbramc,
 -fsanitize=undefined -fno-omit-frame-pointer
and run the test suit

Could you please also comment if you run the whole test suit or some single or a couple of test cases would do the trick?
(0102894)
galbramc   
2021-07-30 16:19   
I'm running my own test suite for his. I'm not sure how to run the OCC test suite... If you can point me to some instructions or tell me how I can try running the OCC test suite. I'm sure that just a couple of tests will do the trick.

The call sequence that leads to these warnings is:

ShapeConstruct::ConvertSurfaceToBSpline
GeomConvert_ApproxSurface::GeomConvert_ApproxSurface
AdvApp2Var_ApproxAFunc2Var::AdvApp2Var_ApproxAFunc2Var
AdvApp2Var_ApproxAFunc2Var::Perform
AdvApp2Var_ApproxAFunc2Var::ComputePatches
AdvApp2Var_ApproxAFunc2Var::ComputeConstraints
AdvApp2Var_Iso::MakeApprox
AdvApp2Var_ApproxF2var::mma2fnc_
(0102895)
kgv   
2021-07-30 16:27   
galbramc, how long it takes on your configuration?
Could you check the current patch in CR32495 to see if it indeed fixes warnings in AdvApp2Var_SysBase.cxx and NCollection_Array1.hxx?
(0102896)
galbramc   
2021-07-30 16:31   
I only have to run one of my tests to get this error, so it takes seconds. I tested the patch and the patch fixed AdvApp2Var_SysBase.cxx and NCollection_Array1.hxx.
(0102972)
git   
2021-08-04 12:23   
Branch CR32495 has been updated forcibly by mkrylova.

SHA-1: cccd2fa57b52239d17564e2da6641da668aa0f5b
(0102973)
git   
2021-08-04 12:26   
Branch CR32495_1 has been created by mkrylova.

SHA-1: 978685da4825d2255aab623fc011f6bf16a0a4d4


Detailed log of new commits:

Author: kgv
Date: Wed Jul 28 09:32:34 2021 +0300

    0032495: Coding rules - eliminate CLang UndefinedBehaviorSanitizer warnings
    
    - fixed CLang UndefinedBehaviorSanitizer warnings
(0102977)
git   
2021-08-04 14:25   
Branch CR32495_1 has been updated by mkrylova.

SHA-1: 7ffd8a46db8ce58bad136f8df4cbc6a198fec4e7


Detailed log of new commits:

Author: mkrylova
Date: Wed Aug 4 14:24:32 2021 +0300

    # fixed initialization

(0102980)
mkrylova   
2021-08-04 17:08   
Analysis, Solution Implementation, Testing
(0102985)
galbramc   
2021-08-04 18:02   
Almost all of them got fixed. I still get these three warnings:

src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:6433:49: runtime error: applying non-zero offset 140469407445008 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3509:49: runtime error: applying non-zero offset 140469407528976 to null pointer
src/AdvApp2Var/AdvApp2Var_ApproxF2var.cxx:3801:50: runtime error: applying non-zero offset 140469407567376 to null pointer

(0103035)
mkrylova   
2021-08-06 16:05   
Solution implementation
(0103247)
galbramc   
2021-08-17 00:04   
Was there updated code that I should test to fix those last 3 warnings?
(0103632)
git   
2021-09-01 15:40   
Branch CR32495_2 has been created by mkrylova.

SHA-1: dd127ccfb2553b1b7131616a2915f2be6af1aeb0


Detailed log of new commits:

Author: kgv
Date: Wed Jul 28 09:32:34 2021 +0300

    0032495: Coding rules - eliminate CLang UndefinedBehaviorSanitizer warnings
    
    - fixed CLang UndefinedBehaviorSanitizer warnings
(0103649)
mkrylova   
2021-09-01 21:33   
http://jenkins-test-occt.nnov.opencascade.com/view/CR32495_2-master-MKRYLOVA/view/ALL/ [^]
(0103650)
mkrylova   
2021-09-01 21:34   
(edited on: 2021-09-03 17:19)
Patch is ready to review:
- OCCT: CR32495_2

(0103651)
galbramc   
2021-09-01 22:42   
I'm still getting the 3 warnings I listed above. All three warnings are related to this new code:

wrkar_off = reinterpret_cast<double*> (iofwr + wrkar);
(0103654)
git   
2021-09-02 00:01   
Branch CR32495_3 has been created by kgv.

SHA-1: dbd086ed2ff3f355905de430efa6664fdbd40dfe


Detailed log of new commits:

Author: mkrylova
Date: Wed Jul 28 09:32:34 2021 +0300

    0032495: Coding rules - eliminate CLang UndefinedBehaviorSanitizer warnings
    
    - fixed CLang UndefinedBehaviorSanitizer warnings
(0103660)
git   
2021-09-02 10:17   
Branch CR32495_3 has been updated forcibly by kgv.

SHA-1: 059055bb08084eed7629b4f0fd699e8444308b1f
(0103672)
kgv   
2021-09-02 13:38   
@galbramc, could you check branch CR32495_3?
(0103730)
galbramc   
2021-09-03 16:49   
Sorry for the delay. I wanted to make sure to run our whole test suite.

CR32495_3 fixes all the warnings. Thank you for taking care of this!
(0103731)
kgv   
2021-09-03 16:56   
Please raise the patch
- OCCT: branch CR32495_3.
(0103764)
smoskvin   
2021-09-04 14:27   
Combination -
OCCT branch : IR-2021-09-03
master SHA - f26ee38f2a309ffbf7de4eebbcef2c5a5c57d84e
a87b7ddc8cb44606b91e3f37113847c3f5f50fdc
Products branch : IR-2021-09-03 SHA - 87cca1a8f3dd94387a936b9d49f5bd719c69cf4d
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:
Debian80-64:
OCCT
Total CPU difference: 17495.94000000042 / 17441.55000000031 [+0.31%]
Products
Total CPU difference: 11565.440000000113 / 11534.270000000102 [+0.27%]
Windows-64-VC14:
OCCT
Total CPU difference: 19307.140625 / 19200.421875 [+0.56%]
Products
Total CPU difference: 12917.859375 / 12874.53125 [+0.34%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
(0103794)
git   
2021-09-04 14:59   
Branch CR32495 has been deleted by mnt.

SHA-1: cccd2fa57b52239d17564e2da6641da668aa0f5b
(0103795)
git   
2021-09-04 15:00   
Branch CR32495_1 has been deleted by mnt.

SHA-1: 7ffd8a46db8ce58bad136f8df4cbc6a198fec4e7
(0103796)
git   
2021-09-04 15:00   
Branch CR32495_2 has been deleted by mnt.

SHA-1: dd127ccfb2553b1b7131616a2915f2be6af1aeb0
(0103797)
git   
2021-09-04 15:00   
Branch CR32495_3 has been deleted by mnt.

SHA-1: 059055bb08084eed7629b4f0fd699e8444308b1f