Sir:
Can any experts please give me some clue?
Situation: Several relatively simple openCV codes, which work on a desktop, look work on laptop but segfault message.
Both laptop and desktop setup is Debian amd64 testing repo openCV 4.6.1 , c++ compiled by g++
dmesg shows
[ 338.133879] pro[913]: segfault at 55650b9402f3 ip 00007f65f773e975 sp 00007ffe837c5790 error 4 in libc-2.33.so[7f65f76da000+158000]
[ 338.133879] Code: 00 0f 1f 40 00 55 53 48 83 ec 18 48 8b 05 83 75 14 00 48 8b 00 48 85 c0 0f 85 87 00 00 00 48 85 ff 74 49 48 8b 1d db 74 14 00 <48> 8b 47 f8 48 8d 77 f0 64 8b 2b a8 02 75 3c 48 8b 15 bd 73 14 00
As there are a lot of differences between these two settings, I have no idea where to start. One point I do not understand is that program looks working on a laptop with segfault message.
I have several other codes which have not been checked. But, so far, all codes look work with segfault.
I appreciate any suggestion.
Thank you in advance.
** Added on edit **
Following script also works with segfault
#include <opencv2/opencv.hpp>
#include <iostream>
int main(int argc, char**argv) {
cv::Mat img = cv::imread("/path/to/some/sample.jpg", cv::IMREAD_COLOR);
char key = 0;
cv::namedWindow("Test Event");
cv::imshow("Test Event", img);
while (key != 27) {
key = cv::pollKey();
}
return 0;
}
berak
July 21, 2022, 7:09am
2
venusian:
openCV 4.6.1
that’s from the future (please look again)
venusian:
c++ compiled by g++
did YOU build that locally, or is it from some weird ppm ?
venusian:
dmesg shows
that’s unfortunately quite useless. can you debug it ?
maybe even get us a backtrace ?
Thank you for your reply.
It looks like I checked wrong column. The first line of getBuildInformation() is:
General configuration for OpenCV 4.6.0
Yes, I complied myself. g++ (Debian 11.3.0-4).
As I do not have an access to the laptop for several days, I will check backtrace next week. Please excuse my poor experience with OS.
Following additional information after original post.
With the simple code (at the end of original post), “Test Event” window shows correct, pollkey() loop works, then segfault. Exit code is 139, so probably “return 0;” is not executed.
Please allow me several days for additional information.
Thank you in advance.
So, the code crashes at the end of main() when your objects try to destruct themselves.
I suspect this: As you are not using waitKey, there is no message loop for that imshow might need, leaving it in a randow state, where it might in, some enviroments and situations, segfault.
berak
July 22, 2022, 6:14am
5
pollKey()
translates to waitKey(1)
on any os that is not windows
Sir:
waitKey also segfaults.
A gdb screendump captured by script (tcsh) is at the end of this post. I did following:
>gdb
(gdb) exec-file simple
(gdb) run simple
- many lines cv::getBuildInformation(); output
enter esc key
-several lines-
(gdb) backtrace
-several lines
(geb) quit
y
>
Apology for escape sequences which are annoying. “simple” is an executable name.
I appreciate any help
**** gdb output start***
ESC[?2004h(gdb) exec-file simple
ESC[?2004l^MESC[?2004h(gdb) run simple
ESC[?2004l^MStarting program: ESC[32m/common/cpp/camera/simple/simpleESC[m si
mple
[Thread debugging using libthread_db enabled]
Using host libthread_db library "ESC[32m/lib/x86_64-linux-gnu/libthread_db.so
.1ESC[m".
General configuration for OpenCV 4.6.0 =====================================
Version control: unknown
Extra modules:
Location (extra): /build/opencv-YhfR1Z/opencv-4.6.0+dfsg/contr
ib/modules
Version control (extra): unknown
Platform:
Timestamp: 2022-07-07T14:36:56Z
Host: Linux 5.10.0-15-amd64 x86_64
CMake: 3.23.2
CMake generator: Ninja
CMake build tool: /usr/bin/ninja
Configuration: Release
CPU/HW features:
Baseline: SSE SSE2
requested: SSE2
disabled: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (14 files): + SSE3 SSSE3 SSE4_1
SSE4_2 (1 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (0 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (4 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (29 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (5 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: /usr/bin/c++ (ver 11.3.0)
C++ flags (Release): -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -fvisibility-inlines-hidden -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG
C++ flags (Debug): -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -fvisibility-inlines-hidden -g -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG
C flags (Debug): -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -g -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now
Linker flags (Debug): -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
ccache: NO
Precompiled headers: NO
Extra dependencies: dl m pthread rt
3rdparty dependencies:
OpenCV modules:
To be built: alphamat aruco barcode bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc intensity_transform java line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab viz wechat_qrcode ximgproc xobjdetect xphoto
Disabled: world
Disabled by dependency: sfm
Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv gapi julia matlab ovis python2 ts
Applications: apps
Documentation: doxygen python javadoc
Non-free algorithms: NO
GUI: GTK3
GTK+: YES (ver 3.24.34)
GThread : YES (ver 2.72.3)
GtkGlExt: NO
OpenGL support: NO
VTK support: YES (ver 9.1.0)
Media I/O:
ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 62)
WEBP: /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020f)
PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.4.0)
JPEG 2000: OpenJPEG (ver 2.5.0)
OpenEXR: /usr/lib/x86_64-linux-gnu/libImath-2_5.so /usr/lib/x86_64-linux-gnu/libIlmImf-2_5.so /usr/lib/x86_64-linux-gnu/libIex-2_5.so /usr/lib/x86_64-linux-gnu/libHalf-2_5.so /usr/lib/x86_64-linux-gnu/libIlmThread-2_5.so (ver 2_5)
GDAL: YES (/usr/lib/x86_64-linux-gnu/libgdal.so)
GDCM: YES (3.0.13)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: YES (2.2.6)
FFMPEG: YES
avcodec: YES (59.18.100)
avformat: YES (59.16.100)
avutil: YES (57.17.100)
swscale: YES (6.4.100)
avresample: NO
GStreamer: YES (1.20.3)
PvAPI: NO
v4l/v4l2: YES (linux/videodev2.h)
gPhoto2: YES
Parallel framework: TBB (ver 2021.5 interface 12050)
Trace: YES (built-in)
Other third-party libraries:
VA: NO
Lapack: NO
Eigen: YES (ver 3.4.0)
Custom HAL: NO
Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so (3.12.4)
OpenCL: YES (no extra features)
Include path: /usr/include/CL
Link libraries: Dynamic load
Python 3:
Interpreter: /usr/bin/python3 (ver 3.10.5)
Libraries: /usr/lib/x86_64-linux-gnu/libpython3.10.so (ver 3.10.5)
numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.21.5)
install path: lib/python3.10/dist-packages
Python (for build): /usr/bin/python3
Java:
ant: /usr/bin/ant (ver 1.10.12)
JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
Java wrappers: YES
Java tests: NO
Install to: /usr
-----------------------------------------------------------------
[New Thread 0x7fffea0fe640 (LWP 2188)]
[New Thread 0x7fffe98fd640 (LWP 2189)]
[New Thread 0x7fffe8924640 (LWP 2190)]
[Thread 0x7fffe8924640 (LWP 2190) exited]
Thread 1 "simple" received signal SIGSEGV, Segmentation fault.
ESC[34m0x00007ffff77f4995ESC[m in ESC[33m__GI___libc_freeESC[m (ESC[36mmemESC[m=0x5550000e3e54) at ESC[32mmalloc.cESC[m:3288
3288 malloc.c: No such file or directory.
ESC[?2004hESC[?2004l^MESC[?2004h(gdb) backtrace
ESC[?2004l^M#0 ESC[34m0x00007ffff77f4995ESC[m in ESC[33m__GI___libc_freeESC[m (ESC[36mmemESC[m=0x5550000e3e54)
at ESC[32mmalloc.cESC[m:3288
#1 ESC[34m0x00007ffff0a0f30cESC[m in ESC[33mosgeo::proj::common::UnitOfMeasure::~UnitOfMeasure()ESC[m
() from ESC[32m/usr/lib/x86_64-linux-gnu/libproj.so.25ESC[m
#2 ESC[34m0x00007ffff77a9586ESC[m in ESC[33m__cxa_finalizeESC[m (ESC[36mdESC[m=0x7fffef660000)
at ESC[32mcxa_finalize.cESC[m:83
#3 ESC[34m0x00007fffef377bb7ESC[m in ESC[33m??ESC[m () from ESC[32m/usr/lib/x86_64-linux-gnu/libproj.so.22ESC[m
#4 ESC[34m0x00007fffffffe250ESC[m in ESC[33m??ESC[m ()
#5 ESC[34m0x00007ffff7fdc473ESC[m in ESC[33m_dl_finiESC[m () at ESC[32mdl-fini.cESC[m:139
Backtrace stopped: frame did not save the PC
ESC[?2004h(gdb) quit
ESC[?2004l^MESC[?2004hA debugging session is active.
Inferior 1 [process 2183] will be killed.
Quit anyway? (y or n) y
*** gdb script end***
1 Like
self reply.
Today, all comps went dist-upgrade.
No segfaults.
Build information follows:
General configuration for OpenCV 4.6.0 =====================================
Version control: unknown
Extra modules:
Location (extra): /build/opencv-YhfR1Z/opencv-4.6.0+dfsg/contrib/modules
Version control (extra): unknown
Platform:
Timestamp: 2022-07-07T14:36:56Z
Host: Linux 5.10.0-15-amd64 x86_64
CMake: 3.23.2
CMake generator: Ninja
CMake build tool: /usr/bin/ninja
Configuration: Release
CPU/HW features:
Baseline: SSE SSE2
requested: SSE2
disabled: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (14 files): + SSE3 SSSE3 SSE4_1
SSE4_2 (1 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (0 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (4 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (29 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (5 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: /usr/bin/c++ (ver 11.3.0)
C++ flags (Release): -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -fvisibility-inlines-hidden -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG
C++ flags (Debug): -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -fvisibility-inlines-hidden -g -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG
C flags (Debug): -g -O2 -ffile-prefix-map=/build/opencv-YhfR1Z/opencv-4.6.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -g -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now
Linker flags (Debug): -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
ccache: NO
Precompiled headers: NO
Extra dependencies: dl m pthread rt
3rdparty dependencies:
OpenCV modules:
To be built: alphamat aruco barcode bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc intensity_transform java line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab viz wechat_qrcode ximgproc xobjdetect xphoto
Disabled: world
Disabled by dependency: sfm
Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv gapi julia matlab ovis python2 ts
Applications: apps
Documentation: doxygen python javadoc
Non-free algorithms: NO
GUI: GTK3
GTK+: YES (ver 3.24.34)
GThread : YES (ver 2.72.3)
GtkGlExt: NO
OpenGL support: NO
VTK support: YES (ver 9.1.0)
Media I/O:
ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 62)
WEBP: /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020f)
PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.4.0)
JPEG 2000: OpenJPEG (ver 2.5.0)
OpenEXR: /usr/lib/x86_64-linux-gnu/libImath-2_5.so /usr/lib/x86_64-linux-gnu/libIlmImf-2_5.so /usr/lib/x86_64-linux-gnu/libIex-2_5.so /usr/lib/x86_64-linux-gnu/libHalf-2_5.so /usr/lib/x86_64-linux-gnu/libIlmThread-2_5.so (ver 2_5)
GDAL: YES (/usr/lib/x86_64-linux-gnu/libgdal.so)
GDCM: YES (3.0.13)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: YES (2.2.6)
FFMPEG: YES
avcodec: YES (59.18.100)
avformat: YES (59.16.100)
avutil: YES (57.17.100)
swscale: YES (6.4.100)
avresample: NO
GStreamer: YES (1.20.3)
PvAPI: NO
v4l/v4l2: YES (linux/videodev2.h)
gPhoto2: YES
Parallel framework: TBB (ver 2021.5 interface 12050)
Trace: YES (built-in)
Other third-party libraries:
VA: NO
Lapack: NO
Eigen: YES (ver 3.4.0)
Custom HAL: NO
Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so (3.12.4)
OpenCL: YES (no extra features)
Include path: /usr/include/CL
Link libraries: Dynamic load
Python 3:
Interpreter: /usr/bin/python3 (ver 3.10.5)
Libraries: /usr/lib/x86_64-linux-gnu/libpython3.10.so (ver 3.10.5)
numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.21.5)
install path: lib/python3.10/dist-packages
Python (for build): /usr/bin/python3
Java:
ant: /usr/bin/ant (ver 1.10.12)
JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
Java wrappers: YES
Java tests: NO
Install to: /usr
-----------------------------------------------------------------