Files
opencv-MIRROR/modules
Abhishek Gola 8928a088d6 Merge pull request #31292 from SomSamantray/fix-instrumentation-parallel-for-segfault
When OpenCV is built with -DENABLE_INSTRUMENTATION=ON, calling cv::parallel_for_ (for example via cv::cvtColor) from any thread other than the one that initialized cv::instr::InstrStruct crashed with a null-pointer dereference in ParallelLoopBodyWrapperContext::finalize(). Because InstrTLSStruct::pCurrentNode defaults to NULL on newly created threads and InstrStruct only initializes the constructing thread's TLS slot, finalize() dereferenced a null pThreadRoot.

The same null-pointer assumption existed in the error and exception branches of CV_INSTRUMENT_FUN_RT_META and CV_INSTRUMENT_FUN_RV_META, where cv::instr::getCurrentNode() was dereferenced unconditionally.

This change guards both pThreadRoot in ParallelLoopBodyWrapperContext::finalize() and cv::instr::getCurrentNode() in the instrumentation function-wrapper macros, matching the existing null check in IntrumentationRegion and OPENCV_TRACE's if (traceRootRegion) check.
2026-12-02 16:11:43 +05:30
..