Skip to content

Fix two race conditions in LazyInit and Matrix default allocator#8713

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
grundman:patch-6
May 24, 2017
Merged

Fix two race conditions in LazyInit and Matrix default allocator#8713
opencv-pushbot merged 1 commit intoopencv:masterfrom
grundman:patch-6

Conversation

@grundman
Copy link
Copy Markdown
Contributor

@grundman grundman commented May 10, 2017

No description provided.

@alalek
Copy link
Copy Markdown
Member

alalek commented May 11, 2017

  1. Use CV_SINGLETON_LAZY_INIT macro, without creation of global objects (you can't guarantee initialization order of them - so Mutex g_matAllocatorMutex; doesn't work because it may not be initialized when you want to use them). See "static initialization order fiasco" for more info.
  2. Don't change CV_SINGLETON_LAZY_INIT macro. It is well known pattern: https://en.wikipedia.org/wiki/Double-checked_locking

@vpisarev
Copy link
Copy Markdown
Contributor

@alalek, let me assign it to you

Fix race condition in getDefaultAllocator and setDefaultAllocator interaction / not threadsafe currently
@alalek
Copy link
Copy Markdown
Member

alalek commented May 24, 2017

@grundman Patch is rebased and updated (race condition in Mat::getDefaultAllocator() is resolved, other changes were removed).

@alalek
Copy link
Copy Markdown
Member

alalek commented May 24, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants