Skip to content

SIGBUS Crash in OpenCV 4.10 ZXing Library During Process Shutdown #27971

@daniel-kognition

Description

@daniel-kognition

System Information

  • OpenCV Version: 4.10.0
  • OS: Linux (Ubuntu 20.04)
  • Architecture: x86_64
  • Library: libopencv_core.so.410 (from /opt/opencv/share/java/opencv4/)
  • JVM: OpenJDK 21.0.7+6 (64-bit)
  • Java Version: OpenJDK Runtime Environment (21.0.7+6-Ubuntu-0ubuntu120.04)
  • Build Type: Release
  • Additional Context: Using OpenCV through JNI from Java application; crash occurs when using Paravision SDK that links against OpenCV 4.10

Detailed description

OpenCV 4.10 crashes with SIGBUS during process shutdown cleanup when the embedded ZXing library destructors are called. The crash occurs in libopencv_core.so.410 during std::vector<zxing::Ref<zxing::qrcode::Version>>::~vector() destructor execution.

Crash Signature

SIGBUS (0x7) at pc=0x00007fb2f0967d6d, pid=470, tid=480
Problematic frame:
C [libopencv_core.so.410+0x2ddcd6d] std::vector<zxing::Ref<zxing::qrcode::Version>, std::allocator<zxing::Ref<zxing::qrcode::Version> > >::~vector()+0x3d

Memory Corruption Indicators

From core dump analysis:

  • RBP register: 0xcccccccccccccccc (poison pattern indicating use-after-free/double-free)
  • Error type: free(): double free detected in tcache 2
  • Crash location: During on_exit cleanup handlers, specifically in OpenCV's embedded ZXing library destructors

Stack Trace (from core dump)

Backtrace:
/opt/opencv/share/java/opencv4/libopencv_core.so.410(_ZNSt6vectorIN5zxing3RefINS0_6qrcode7VersionEEESaIS4_EED1Ev+0x3d)[0x7fe1dbd02d6d]
/usr/lib/x86_64-linux-gnu/libc.so.6(+0x468a7)[0x7fe2bd5528a7]
/usr/lib/x86_64-linux-gnu/libc.so.6(on_exit+0x0)[0x7fe2bd552a60]
/usr/lib/jvm/java-21-openjdk-amd64/lib/server/libjvm.so(+0xd080dd)[0x7fe2bccb80dd]
[... JVM shutdown hooks ...]

Steps to reproduce

  1. Load OpenCV 4.10 in a Java application (via JNI)

    • OpenCV is loaded through System.loadLibrary() or equivalent
    • OpenCV is used through a third-party SDK (Paravision SDK) that links against OpenCV 4.10
  2. Use OpenCV functionality that initializes the ZXing QR code library

    • The ZXing library appears to be initialized during first use of certain OpenCV features
    • Initialization happens automatically when OpenCV is used
  3. Complete the application work successfully

    • All tests pass: "Tests run: 1, Failures: 0, Errors: 0, Skipped: 0"
    • All OpenCV operations complete without errors
    • Application logic executes correctly
  4. Allow the process to shutdown normally

    • JVM begins shutdown sequence
    • Application cleanup code completes
    • Process attempts to exit
  5. Crash occurs during on_exit cleanup handlers

    • OpenCV's static/global destructors are called
    • Specifically crashes in std::vector<zxing::Ref<zxing::qrcode::Version>>::~vector() destructor
    • Error: free(): double free detected in tcache 2
    • Process terminates with SIGBUS

Note: The crash only occurs during process shutdown, not during normal operation. All application functionality works correctly before the crash.

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions