View Issue Details

IDProjectCategoryView StatusLast Update
0028657Open CASCADEOCCT:Foundation Classespublic2017-09-29 16:25
Reporterkgv Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
OSAndroid 
Product Version6.3.1 
Target Version7.2.0Fixed in Version7.2.0 
Summary0028657: Foundation Classes - OSD_Thread does not release thread resources on non-Windows platforms
DescriptionOSD_Thread destructor does nothing on Linux:
void OSD_Thread::Destroy ()
{
#ifdef _WIN32

  // On Windows, close current handle 
  if ( myThread ) 
    CloseHandle ( myThread );

#else

  // On Unix/Linux, do nothing

#endif  

  myThread = 0;
  myThreadId = 0;
}

and so does ::Run() as well.

If application does not call explicitly OSD_Thread::Detach() or OSD_Thread::Wait() - it ends up with leaked resources since when thread finishes it's job, nobody will free memory.
Steps To ReproduceNot required.

static Standard_Address OCC28657_ThreadFunc (Standard_Address )
{
  return 0;
}

static Standard_Integer OCC28657 (Draw_Interpretor& , Standard_Integer , const char** )
{
  OSD_Thread aThread (OCC28657_ThreadFunc);
  for (Standard_Integer anIter = 0; anIter < 10000; ++anIter, ++aDumpIter)
  {
    aThread.Run();
  }
  return 0;
}
//
meminfo
OCC28657
meminfo


Results Ubuntu 17.04:
  Private memory:     49 MiB
  Working Set:        83 MiB (peak: 83 MiB)
  Virtual memory:     356 MiB
  Heap memory:     4 MiB
...
  Private memory:     80021 MiB
  Working Set:        163 MiB (peak: 163 MiB)
  Virtual memory:     80367 MiB
  Heap memory:     8 MiB


Results Android 4.4.2:
  Private memory:     16 MiB
  Working Set:        67 MiB (peak: 67 MiB)
  Virtual memory:     520 MiB
  Heap memory:     2 MiB
...
  Private memory:     26 MiB
  Working Set:        77 MiB (peak: 77 MiB)
  Virtual memory:     532 MiB
  Heap memory:     10 MiB


Results Android 6.0.1:
  Private memory:     139 MiB
  Working Set:        41 MiB (peak: 41 MiB)
  Virtual memory:     1577 MiB
  Heap memory:     7 MiB
... 1000
  Private memory:     1142 MiB
  Working Set:        65 MiB (peak: 65 MiB)
  Virtual memory:     2618 MiB
  Heap memory:     9 MiB
...
... W/libc: pthread_create failed: couldn't allocate 1044480-bytes mapped space: Out of memory
... W/libc: pthread_create failed: couldn't allocate 1044480-bytes mapped space: Out of memory
  Private memory:     1576 MiB
  Working Set:        66 MiB (peak: 66 MiB)
  Virtual memory:     3053 MiB
  Heap memory:     9 MiB
TagsNo tags attached.
Test case numberNot needed

Activities

git

2017-04-15 18:57

administrator   ~0065246

Branch CR28657 has been created by kgv.

SHA-1: 59a62411d72d8c45c8601130488770596158eb08


Detailed log of new commits:

Author: kgv
Date: Sat Apr 15 18:57:30 2017 +0300

    0028657: Foundation Classes - OSD_Thread does not release thread resources on non-Windows platforms
    
    ~OSD_Thread(), OSD_Thread::SetFunction() and OSD_Thread::Run()
    now detach old thread also on platforms using pthreads.

kgv

2017-04-15 18:58

developer   ~0065247

Patch is ready for review.

abv

2017-04-17 09:46

manager   ~0065248

No remarks, please test.

Kirill, please give results of the same measurements after the fix.

mkv

2017-04-17 18:03

tester   ~0065269

Dear BugMaster,
Branch CR28657 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
SHA-1: 59a62411d72d8c45c8601130488770596158eb08

Number of compiler warnings:

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

products component :
Linux: 64 (64 on master)
Windows: 0 (0 on master)
MacOS : 1184

Regressions/Differences/Improvements:
http://occt-tests/CR28657-master-OCCT/Debian70-64/summary.html
Failed:
  bugs modalg_5 bug23952_1, bug23952_2
  bugs vis bug26404, bug26676, bug26975, bug27083, bug27337, bug28093
  demo samples penrose, raytrace
  v3d glsl msaa, tiles
  v3d materials bug24855, bug24872_2
  v3d raytrace bug24130, bug24819, bug25201, bug25221, bug25833, bug26070, bug26617, connected, plastic, refraction, sample_ball, sample_ball_alpha, sample_ball_iss, sample_cube, sample_cube_clamp, sample_cube_twosided, sample_materials, textures

Testing cases:
Not needed

Testing on Linux:
occt component :
Total MEMORY difference: 91031307 / 89994207 [+1.15%]
Total CPU difference: 19501.09000000006 / 19409.040000000256 [+0.47%]
products component :
Total MEMORY difference: 30357847 / 30341918 [+0.05%]
Total CPU difference: 5402.289999999971 / 5356.299999999965 [+0.86%]
Testing on Windows:
occt component :
Total MEMORY difference: 57805156 / 57804189 [+0.00%]
Total CPU difference: 18273.645137998592 / 18136.473458698543 [+0.76%]
products component :
Total MEMORY difference: 22303659 / 22265369 [+0.17%]
Total CPU difference: 5340.07023099997 / 5359.788757399982 [-0.37%]

There are no differences in images found by testdiff.

mkv

2017-04-17 18:04

tester   ~0065270

Dear kgv,
Branch CR28657 has been rejected due to:
- regressions/differences/improvements

git

2017-04-17 20:38

administrator   ~0065273

Branch CR28657 has been updated by kgv.

SHA-1: 9a2220eeab838d40182c7fa84312ed33c7aaf06e


Detailed log of new commits:

Author: kgv
Date: Mon Apr 17 20:38:45 2017 +0300

    OSD_Thread::Wait() - close thread handle after joining

kgv

2017-04-17 20:42

developer   ~0065274

> Kirill, please give results of the same measurements after the fix.
After patch, Ubuntu 17.04:
  Private memory:     17 MiB
  Working Set:        84 MiB (peak: 84 MiB)
  Virtual memory:     324 MiB
  Heap memory:     4 MiB

  Private memory:     57 MiB
  Working Set:        86 MiB (peak: 86 MiB)
  Virtual memory:     364 MiB
  Heap memory:     4 MiB

git

2017-04-17 20:46

administrator   ~0065275

Branch CR28657 has been updated forcibly by kgv.

SHA-1: b14e906437bf6b44404f8701205cfc9efe4407ce

git

2017-04-17 20:48

administrator   ~0065276

Branch CR28657_1 has been created by kgv.

SHA-1: a78df834d146108186b56ab595e29a0dfa00038c


Detailed log of new commits:

Author: kgv
Date: Sat Apr 15 18:57:30 2017 +0300

    0028657: Foundation Classes - OSD_Thread does not release thread resources on non-Windows platforms
    
    ~OSD_Thread(), OSD_Thread::SetFunction() and OSD_Thread::Run()
    now detach old thread also on platforms using pthreads.
    OSD_Thread::Wait() now closes thread handle after joining.

kgv

2017-04-17 20:49

developer   ~0065277

Please test updated patch.

mkv

2017-04-18 17:40

tester   ~0065310

Dear BugMaster,
Branch CR28657_1 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
SHA-1: a78df834d146108186b56ab595e29a0dfa00038c

Number of compiler warnings:

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

products component :
Linux: 64 (64 on master)
Windows: 0 (0 on master)
MacOS : 1200

Regressions/Differences/Improvements:
No regressions/differences

Testing cases:
Not needed

Testing on Linux:
occt component :
Total MEMORY difference: 92079171 / 90705102 [+1.51%]
Total CPU difference: 19888.24000000029 / 19728.220000000332 [+0.81%]
products component :
Total MEMORY difference: 30351483 / 30341918 [+0.03%]
Total CPU difference: 5373.489999999979 / 5356.299999999965 [+0.32%]
Testing on Windows:
occt component :
Total MEMORY difference: 57805223 / 57804189 [+0.00%]
Total CPU difference: 18209.528726998557 / 18136.473458698543 [+0.40%]
products component :
Total MEMORY difference: 22303677 / 22265369 [+0.17%]
Total CPU difference: 5358.946351999965 / 5359.788757399982 [-0.02%]

There are no differences in images found by testdiff.

mkv

2017-04-18 17:41

tester   ~0065311

Dear BugMaster,
Branch CR28657_1 is TESTED.

git

2017-05-12 11:36

administrator   ~0065967

Branch CR28657 has been deleted by kgv.

SHA-1: b14e906437bf6b44404f8701205cfc9efe4407ce

git

2017-05-12 11:36

administrator   ~0065968

Branch CR28657_1 has been deleted by kgv.

SHA-1: a78df834d146108186b56ab595e29a0dfa00038c

Related Changesets

occt: master b2ec0b4d

2017-04-15 15:57:30

kgv


Committer: bugmaster Details Diff
0028657: Foundation Classes - OSD_Thread does not release thread resources on non-Windows platforms

~OSD_Thread(), OSD_Thread::SetFunction() and OSD_Thread::Run()
now detach old thread also on platforms using pthreads.
OSD_Thread::Wait() now closes thread handle after joining.
Affected Issues
0028657
mod - src/OSD/OSD_Thread.cxx Diff File
mod - src/OSD/OSD_Thread.hxx Diff File

Issue History

Date Modified Username Field Change
2017-04-15 17:27 kgv New Issue
2017-04-15 17:27 kgv Assigned To => abv
2017-04-15 18:10 kgv Relationship added related to 0026365
2017-04-15 18:45 kgv Steps to Reproduce Updated
2017-04-15 18:48 kgv Relationship deleted related to 0026365
2017-04-15 18:53 kgv Steps to Reproduce Updated
2017-04-15 18:57 git Note Added: 0065246
2017-04-15 18:58 kgv Note Added: 0065247
2017-04-15 18:58 kgv Status new => resolved
2017-04-15 18:58 kgv Steps to Reproduce Updated
2017-04-15 19:00 kgv Product Version 7.1.0 => 6.3.1
2017-04-15 19:01 kgv Description Updated
2017-04-17 08:24 kgv Steps to Reproduce Updated
2017-04-17 08:25 kgv Steps to Reproduce Updated
2017-04-17 09:46 abv Note Added: 0065248
2017-04-17 09:46 abv Assigned To abv => bugmaster
2017-04-17 09:46 abv Status resolved => reviewed
2017-04-17 10:19 mkv Assigned To bugmaster => mkv
2017-04-17 10:25 mkv Test case number => Not needed
2017-04-17 18:03 mkv Note Added: 0065269
2017-04-17 18:04 mkv Note Added: 0065270
2017-04-17 18:04 mkv Assigned To mkv => kgv
2017-04-17 18:04 mkv Status reviewed => assigned
2017-04-17 20:38 git Note Added: 0065273
2017-04-17 20:42 kgv Note Added: 0065274
2017-04-17 20:46 git Note Added: 0065275
2017-04-17 20:48 git Note Added: 0065276
2017-04-17 20:49 kgv Note Added: 0065277
2017-04-17 20:49 kgv Assigned To kgv => bugmaster
2017-04-17 20:49 kgv Status assigned => resolved
2017-04-17 20:49 kgv Status resolved => reviewed
2017-04-17 20:54 mkv Assigned To bugmaster => mkv
2017-04-18 17:40 mkv Note Added: 0065310
2017-04-18 17:41 mkv Note Added: 0065311
2017-04-18 17:41 mkv Assigned To mkv => bugmaster
2017-04-18 17:41 mkv Status reviewed => tested
2017-04-21 14:59 bugmaster Changeset attached => occt master b2ec0b4d
2017-04-21 14:59 bugmaster Status tested => verified
2017-04-21 14:59 bugmaster Resolution open => fixed
2017-05-12 11:36 git Note Added: 0065967
2017-05-12 11:36 git Note Added: 0065968
2017-09-29 16:19 aiv Fixed in Version => 7.2.0
2017-09-29 16:25 aiv Status verified => closed