1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00
Ghazi-raad 5a0679b862 Fix null pointer dereference in G-API stateful kernels
Fixes #28095

Problem:
- Stateful kernels dereference null state pointer on line 446 in gcpukernel.hpp
- jinboson confirmed state_ptr is null on x86 Ubuntu (7 hours ago)
- Causes crash with std::shared_ptr assertion on LoongArch64 and strict platforms

Solution (addressing Copilot review feedback from PR #28096):
1. Added null pointer check using CV_Error instead of CV_Assert:
   - CV_Assert with && 'message' doesn't display the message correctly
   - CV_Error properly reports cv::Error::StsNullPtr with clear message

2. Fixed test kernels to properly initialize state using std::make_shared:
   - GOCVStInvalidResize: Initialize state in setup()
   - GOCVCountStateSetups: Initialize state before incrementing counter
   - Used std::make_shared<int>() for modern C++ best practice

Impact:
- Prevents crashes on platforms with strict null pointer checking
- Provides actionable error message for developers
- Fixes StatefulKernel.StateInitOnceInRegularMode and InvalidReallocatingKernel tests
2025-12-06 12:45:48 +00:00
2020-02-26 15:12:45 +03:00
2018-10-11 17:57:51 +00:00
2025-12-05 16:00:14 +03:00
2025-08-01 09:50:10 +03:00
2024-03-03 23:37:07 +05:30

OpenCV: Open Source Computer Vision Library

Resources

Contributing

Please read the contribution guidelines before starting work on a pull request.

Summary of the guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.

Additional Resources

S
Description
No description provided
Readme Apache-2.0 3.3 GiB
Languages
C++ 87.6%
C 3.2%
Python 2.9%
CMake 2%
Java 1.5%
Other 2.6%