Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix possible MatProfile race by ordering remove before free.
When building with `-tags matprofile` set, gocv will occasionally panic due to a duplicate pointer added to the pprof Profile: #851 (comment) The pointer added comes directly from new (via Mat_New). Assuming correct memory allocator behavior, that means that we must be inserting a pointer which was previously deleted. Since the pointer is currently removed from the Profile *after* it is freed, there's a possible data race in multithreaded applications where `new` gives us back a deleted pointer immediately and we insert it before we have a chance to remove it from the profile, triggering this condition. I'm not completely certain this resolves the issue since the race is extremely difficult to reproduce.
- Loading branch information