FS#77705 - python-opencv 4.7 results in core dump when opening ONNX model

Attached to Project: Arch Linux
Opened by Cecil Watson (cesman) - Friday, 03 March 2023, 01:55 GMT
Last edited by Antonio Rojas (arojas) - Monday, 29 May 2023, 00:27 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
After upgrading to opencv 4.7 and python-opencv 4.7, I noted an error with loading an model I made in YOLO and converted to ONNX no longer working. This had previous worked with no issues w/ opencv 4.6. If I revert to 4.6 it still functions (well it didn't up until yesterday when I assume a dependent library got updated and 4.6 no longer funtions). Here is the error I see:

/usr/include/c++/12.2.1/bits/stl_vector.h:1123: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = float; _Alloc = std::allocator<float>; reference = float&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
/usr/include/c++/12.2.1/bits/stl_vector.h:1123: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_tyAborted (core dumped)

If I create a venv and install opencv-python (which pulls down 4.7.0.68), activate it and run the script, the script functions without issue. So I don't believe this is an upstream issue.

Additional info:
* package version(s)
opencv-cuda-4.7.-03 and python-opencv-4.7.0-3
* config and/or log files etc.
* link to upstream bug report, if any

Steps to reproduce:
sudo pacman -Sy opencv-cuda python-opencv

I've uploaded the python script and model here:
https://drive.google.com/drive/folders/1i_aqCIovVoC6ufG1b8e-S6ELNG9DEMp3?usp=share_link

python yv5_cls.py

core dumps

python -m venv ~/path/to/venv/opencv47
activate ~/path/to/venv/opencv47/bin/activate
python yv_cls.py

woks as expected
This task depends upon

Closed by  Antonio Rojas (arojas)
Monday, 29 May 2023, 00:27 GMT
Reason for closing:  Fixed
Additional comments about closing:  opencv 4.7.0-11
Comment by Toolybird (Toolybird) - Friday, 03 March 2023, 04:27 GMT
> core dumps

Does a backtrace with debug symbols [1] shed any light? Please post it.

PS. that Google link requires a login. It's no good.

[1] https://wiki.archlinux.org/title/Debugging/Getting_traces#Debuginfod
Comment by Cecil Watson (cesman) - Friday, 03 March 2023, 06:55 GMT
Here is an updated link that doesn't require a login:
https://drive.google.com/drive/folders/1i_aqCIovVoC6ufG1b8e-S6ELNG9DEMp3?usp=sharing

I'm attempting to debug now. It is downloading debug info for various files and it is taking some time. I'll post once I have the information.
Comment by Cecil Watson (cesman) - Friday, 03 March 2023, 07:11 GMT
Attached is the trace.
   trace.log (21.9 KiB)
Comment by Antonio Rojas (arojas) - Friday, 03 March 2023, 07:39 GMT
Your trace is missing debug symbols for opencv. Please install them and get a new trace.
Comment by Toolybird (Toolybird) - Friday, 03 March 2023, 07:52 GMT
Was just about to say the same thing...but then noticed opencv is compiled with:

-DBUILD_WITH_DEBUG_INFO=OFF

Is that the reason for missing symbols?
Comment by Antonio Rojas (arojas) - Friday, 03 March 2023, 07:56 GMT
Nevermind, looks like the current opencv debug package is broken somehow, will investigate.

Anyway: this is an assert, please report it upstream. The pypi package is not affected because it's likely compiled without asserts, but this is still an upstream problem.
Comment by Antonio Rojas (arojas) - Friday, 03 March 2023, 07:58 GMT
@Toolybird huh, good catch. I wonder why a pretty big debug package is still being produced anyway.
Comment by Cecil Watson (cesman) - Friday, 03 March 2023, 09:09 GMT
Thanks for the info and review. I've opened a bug report with OpenCV.
Comment by Cecil Watson (cesman) - Saturday, 04 March 2023, 06:14 GMT
Here is the link to the OpenCV bug report:
https://github.com/opencv/opencv/issues/23323

The response so far is suggesting perhaps a broken build.
Comment by Antonio Rojas (arojas) - Saturday, 04 March 2023, 18:00 GMT
You'll have to post a backtrace with debug symbols to make them realize it's an opencv issue. Proper debug packages are on their way but they will take a few hours to reach the main repos, for now you can grab them from here: https://pkgbuild.com/~arojas/
Comment by Cecil Watson (cesman) - Saturday, 04 March 2023, 23:59 GMT
Thanks for the files. Unfortunately, trying to debug, I'm seeing a lot of warnings like this:

warning: File "/usr/lib/debug/usr/lib/libopencv_core.so.4.7.0.debug" has a different build-id, file skipped
warning: File "/usr/lib/debug/.build-id/34/60fea22215db892edccc0732ff15fbee7d63d6.debug" has a different build-id, file skipped
warning: the debug information found in "/usr/lib/debug//usr/lib/libopencv_core.so.4.7.0.debug" does not match "/usr/lib/libopencv_core.so.407" (CRC mismatch).

warning: the debug information found in "/usr/lib/debug//usr/lib/libopencv_core.so.4.7.0.debug" does not match "/usr/lib/libopencv_core.so.407" (CRC mismatch).

I've attached the trace.
Comment by Antonio Rojas (arojas) - Sunday, 05 March 2023, 18:01 GMT
Yeah looks like having two different incompatible packages built out of the same PKGBUILD interferes with creation of debug packages. I have updated it now with working packages, until I figure out what to do with the official ones - I'll probably just end up dropping the cuda version.
Comment by Cecil Watson (cesman) - Sunday, 05 March 2023, 21:55 GMT
Attached a trace with the most recent packages.
   trace.log (161.8 KiB)
Comment by Antonio Rojas (arojas) - Sunday, 05 March 2023, 22:03 GMT
Thanks, but please post it on the upstream report.
Comment by Cecil Watson (cesman) - Sunday, 05 March 2023, 22:06 GMT
You're welcome. I've posted it to the OpenCV ticket.

Loading...