MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0023855Community[OCCT] OCCT:Modeling Algorithmspublic2013-03-25 12:572014-05-05 13:37
ReporterPawel 
Assigned Tobugmaster 
PrioritynormalSeverityminor 
StatusclosedResolutionfixed 
PlatformWindowsOSVC++ 2008OS Version64 bit
Product Version[OCCT] 6.6.0 
Target Version[OCCT] 6.7.1Fixed in Version[OCCT] 6.7.1 
Summary0023855: Old BOPs fail on Win7 64bit when using TBB
DescriptionOld BOPs fail when using OCCT with TBB on an 64 bit Windows7.

Investigations show that the lines (30/31):

const TopOpeBRepDS_ListOfInterference* l1 = (const TopOpeBRepDS_ListOfInterference*)(*((long int*)v1));
const TopOpeBRepDS_ListOfInterference* l2 = (const TopOpeBRepDS_ListOfInterference*)(*((long int*)v2));

in TopOpeBRep_sort.cxx, in the compll-method obtain pointers that apparently do not point at valid objects and so the line 32 causes the exception:
if (l1->Extent() == 0) return (0);

The problem occurs only when MMGT_OPT=2.
32 bit version is not affected.
Steps To ReproduceMake sure the following environment variables are set:

set MMGT_OPT=2
set MMGT_REENTRANT=1

and then run DRAW:

pload ALL
psphere s1 10
psphere s2 10
common result s1 s2

... exception is thrown.

The script runs without problems if either MMGT_OPT=1 or MMGT_OPT=0.
TagsNo tags attached.
Test case numberbugs modalg_5(010) bug23855
Attached Files

- Relationships
related to 0024066closedPawel Memory corruption when using BRepPrimAPI package 

-  Notes
(0024595)
Pawel (developer)
2013-06-03 01:39

Dear Roman,

can I please ask you to check if you can confirm this problem?

I know you have great experience with Intel TBB so maybe you could give a hint what causes such behaviour.

Thanks
Pawel
(0024596)
Roman Lygin (developer)
2013-06-03 08:25

Hi Julia,
This has nothing to do with TBB actually. This code will equally fail with any allocator. TBB just seems to provoke it more aggressively, what is good.

The root-cause is likely the same as in 0022786: wrong pointer arithmetic and attempt to store a pointer in long int. On Windows 64, the size of long int is 32 bit so it loses part of the pointer.

It looks like it input parameters v1 and v2 are pointers to pointers, so following should work:
const TopOpeBRepDS_ListOfInterference* l1 = *(const TopOpeBRepDS_ListOfInterference**)(v1);

For C++ code you might want to prefer more strict reinterpret_cast<> to C-style casting:
const TopOpeBRepDS_ListOfInterference* l1 = *reinterpret_cast<const TopOpeBRepDS_ListOfInterference**>(v1);

But please check the semantics and test.
Hope this helps.
Roman
(0024597)
Roman Lygin (developer)
2013-06-03 08:26

Ohh, just realized that this was Pawel who reassigned this to me initially. Anyway, hope this will help to both of you, Pawel and Julia.
(0027294)
Pawel (developer)
2013-12-22 18:05

One observation: The problem does not occur with tbb42_20131003oss.
(0027542)
Roman Lygin (developer)
2014-01-17 21:34

I have just came across this issue when running the regression test on Windows 64bit:
test bugs fclasses bug23237

The fix has been pushed into the repository.
I have also fixed some warning "unreachable code" (interesting which the compiler did not trigger it on the original code).

As mentioned earlier, the root-cause has nothing to do with TBB. It's just plain wrong casting a pointer to long int which may fail on Windows 64 regardless of the underlying allocator.
(0027543)
kgv (developer)
2014-01-17 22:46

Just small comment:
+  Standard_Address p = T;
+  Standard::Free(p);

the copy seems to be redundant since 0024489
(0027544)
Roman Lygin (developer)
2014-01-17 23:23

Right. However I intentionally left it as is, to ease backporting to previous versions of OCC (I had to apply it to 6.7.0 at least).
Re 0024489 I have a comment to be posted there.
(0027549)
abv (manager)
2014-01-18 13:44

Reviewed, please test. Sorry I have added one more commit to make the code around more readable (mostly adding line breaks between operators).
(0027559)
abv (manager)
2014-01-20 18:00

Please test also on 64-bit Windows!
(0027587)
mkv (tester)
2014-01-22 10:57

Dear BugMaster,

Branch CR23855 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
SHA-1: b83ea14c43780ba3334c951892e0047d7379da73

Number of compiler warnings:

occt component :
Linux: 48 (48 on master)
Windows: 1 (1 on master)

products component :
Linux: 12 (12 on master)
Windows: 2 (2 on master)

Regressions/Differences:
No regressions/differences

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 365200936 / 365947140
Total CPU difference: 43948.98999999988 / 44021.22000000015

Testing on Windows:
Total MEMORY difference: 417067404 / 417396220
Total CPU difference: 32577.796875 / 32472.65625

There are not differences in images found by testdiff.
(0027646)
mkv (tester)
2014-01-27 11:35

Dear BugMaster,

Branch CR23855 (and products from GIT master) was compiled on 64-bit Windows platform and tested.
No regressions/differences

Testing cases:
bugs modalg_5 bug23855 - OK.

- Related Changesets
occt: master 091232ba
Timestamp: 2014-01-30 08:58:31
Author: Roman Lygin
Committer: bugmaster
Details ] Diff ]
0023855: Old BOPs fail on Win7 64bit when using TBB

Minor code refactoring (readability)

Test case for issue CR23855
mod - src/TopOpeBRep/TopOpeBRep_sort.cxx Diff ] File ]
add - tests/bugs/modalg_5/bug23855 Diff ] File ]

- Issue History
Date Modified Username Field Change
2013-03-25 12:57 Pawel New Issue
2013-03-25 12:57 Pawel Assigned To => bugmaster
2013-05-14 14:09 Pawel Assigned To bugmaster => jgv
2013-05-14 14:09 Pawel Product Version 6.5.5 => 6.6.0
2013-05-14 14:09 Pawel Target Version => 6.7.0
2013-06-03 01:39 Pawel Note Added: 0024595
2013-06-03 01:39 Pawel Assigned To jgv => Roman Lygin
2013-06-03 01:39 Pawel Status new => feedback
2013-06-03 08:25 Roman Lygin Note Added: 0024596
2013-06-03 08:25 Roman Lygin Assigned To Roman Lygin => jgv
2013-06-03 08:25 Roman Lygin Status feedback => assigned
2013-06-03 08:26 Roman Lygin Note Added: 0024597
2013-07-11 19:59 Pawel Relationship added related to 0024066
2013-12-21 10:13 abv Target Version 6.7.0 => 6.7.1
2013-12-22 18:05 Pawel Note Added: 0027294
2014-01-17 21:34 Roman Lygin Note Added: 0027542
2014-01-17 21:34 Roman Lygin Status assigned => resolved
2014-01-17 22:46 kgv Note Added: 0027543
2014-01-17 23:23 Roman Lygin Note Added: 0027544
2014-01-18 13:44 abv Note Added: 0027549
2014-01-18 13:44 abv Assigned To jgv => bugmaster
2014-01-18 13:44 abv Status resolved => reviewed
2014-01-20 17:50 mkv Assigned To bugmaster => mkv
2014-01-20 18:00 abv Note Added: 0027559
2014-01-22 10:57 mkv Note Added: 0027587
2014-01-27 11:35 mkv Note Added: 0027646
2014-01-27 11:36 mkv Test case number => bugs modalg_5(010) bug23855
2014-01-27 11:36 mkv Assigned To mkv => bugmaster
2014-01-27 11:36 mkv Status reviewed => tested
2014-02-03 10:15 bugmaster Changeset attached => occt master 091232ba
2014-02-03 10:15 bugmaster Status tested => verified
2014-02-03 10:15 bugmaster Resolution open => fixed
2014-05-05 13:34 user533 Status verified => closed
2014-05-05 13:37 user533 Fixed in Version => 6.7.1


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker