kbingham / libcamera

libcamera - Making complex cameras easy. This is a personal fork, please use the upstream repository at https://git.libcamera.org/libcamera/libcamera.git/
https://libcamera.org
Other
173 stars 69 forks source link

Conditional jump or move depends on uninitialised value #6

Closed kbingham closed 4 years ago

kbingham commented 4 years ago

It appears we're using an uninitalised variable, and valgrind picked up on it.

libcamera/libcamera-daily$ valgrind ./build/build-clang-10/src/cam/cam -c 3 -C10
==1784336== Memcheck, a memory error detector
==1784336== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1784336== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==1784336== Command: ./build/build-clang-10/src/cam/cam -c 3 -C10
==1784336== 
[22:47:52.899435142] [1784336]  INFO IPAManager ipa_manager.cpp:136 libcamera is not installed. Adding '/home/linuxembedded/iob/libcamera/libcamera-daily/build/build-clang-10/src/ipa' to the IPA search path
[22:47:53.002443094] [1784336]  INFO Camera camera_manager.cpp:287 libcamera v0.0.0+1855-b83ee94f
[22:47:53.824898947] [1784338]  INFO IPAProxy ipa_proxy.cpp:122 libcamera is not installed. Loading IPA configuration from '/home/linuxembedded/iob/libcamera/libcamera-daily/src/ipa/vimc/data'
Using camera platform/vimc.0 Sensor B
[22:47:54.223156621] [1784336]  INFO VIMC vimc.cpp:212 Skipping unsupported pixel format RGB888
[22:47:54.286875950] [1784336]  INFO Camera camera.cpp:811 configuring streams: (0) 1920x1080-BGR888
Capture 10 frames
==1784336== Thread 2:
==1784336== Conditional jump or move depends on uninitialised value(s)
==1784336==    at 0x4118EC: Capture::requestComplete(libcamera::Request*) (capture.cpp:167)
==1784336==    by 0x4152EF: libcamera::BoundMethodMember<Capture, void, libcamera::Request*>::activate(libcamera::Request*, bool) (bound_method.h:190)
==1784336==    by 0x4AEDBEA: libcamera::Signal<libcamera::Request*>::emit(libcamera::Request*) (signal.h:127)
==1784336==    by 0x4AEBEE5: libcamera::Camera::requestComplete(libcamera::Request*) (camera.cpp:996)
==1784336==    by 0x4B838ED: libcamera::PipelineHandler::completeRequest(libcamera::Camera*, libcamera::Request*) (pipeline_handler.cpp:476)
==1784336==    by 0x4C24155: libcamera::VimcCameraData::bufferReady(libcamera::FrameBuffer*) (vimc.cpp:533)
==1784336==    by 0x4C268AF: libcamera::BoundMethodMember<libcamera::VimcCameraData, void, libcamera::FrameBuffer*>::activate(libcamera::FrameBuffer*, bool) (bound_method.h:190)
==1784336==    by 0x4BB3A3A: libcamera::Signal<libcamera::FrameBuffer*>::emit(libcamera::FrameBuffer*) (signal.h:127)
==1784336==    by 0x4BAD309: libcamera::V4L2VideoDevice::bufferAvailable(libcamera::EventNotifier*) (v4l2_videodevice.cpp:1472)
==1784336==    by 0x4BB7B8F: libcamera::BoundMethodMember<libcamera::V4L2VideoDevice, void, libcamera::EventNotifier*>::activate(libcamera::EventNotifier*, bool) (bound_method.h:190)
==1784336==    by 0x4B5179A: libcamera::Signal<libcamera::EventNotifier*>::emit(libcamera::EventNotifier*) (signal.h:127)
==1784336==    by 0x4B509C6: libcamera::EventDispatcherPoll::processNotifiers(std::vector<pollfd, std::allocator<pollfd> > const&) (event_dispatcher_poll.cpp:282)
==1784336== 
82074.640012 (0.00 fps) stream0 seq: 000000 bytesused: 6220800
82074.680018 (25.00 fps) stream0 seq: 000001 bytesused: 6220800
82074.727088 (21.24 fps) stream0 seq: 000002 bytesused: 6220800
82074.766777 (25.20 fps) stream0 seq: 000003 bytesused: 6220800
82074.808468 (23.99 fps) stream0 seq: 000004 bytesused: 6220800
82074.856303 (20.91 fps) stream0 seq: 000005 bytesused: 6220800
82074.901783 (21.99 fps) stream0 seq: 000006 bytesused: 6220800
82074.950037 (20.72 fps) stream0 seq: 000007 bytesused: 6220800
82074.997260 (21.18 fps) stream0 seq: 000008 bytesused: 6220800
82075.044010 (21.39 fps) stream0 seq: 000009 bytesused: 6220800
==1784336== Warning: invalid file descriptor -1 in syscall close()
==1784336== 
==1784336== HEAP SUMMARY:
==1784336==     in use at exit: 0 bytes in 0 blocks
==1784336==   total heap usage: 9,034 allocs, 9,034 frees, 2,140,653 bytes allocated
==1784336== 
==1784336== All heap blocks were freed -- no leaks are possible
==1784336== 
==1784336== Use --track-origins=yes to see where uninitialised values come from
==1784336== For lists of detected and suppressed errors, rerun with: -s
==1784336== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
kbingham commented 4 years ago

Solved thanks to Tomi's fixups.

libcamera-daily$ valgrind ./build/build-clang-10/src/cam/cam -c 3 -C10 ==188975== Memcheck, a memory error detector ==188975== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==188975== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info ==188975== Command: ./build/build-clang-10/src/cam/cam -c 3 -C10 ==188975== [162:49:50.348921731] [188975] INFO IPAManager ipa_manager.cpp:136 libcamera is not installed. Adding '/home/linuxembedded/iob/libcamera/libcamera-daily/build/build-clang-10/src/ipa' to the IPA search path [162:49:50.473354028] [188975] INFO Camera camera_manager.cpp:292 libcamera v0.0.0+1924-b2b8c4dc [162:49:51.278188183] [188978] INFO IPAProxy ipa_proxy.cpp:122 libcamera is not installed. Loading IPA configuration from '/home/linuxembedded/iob/libcamera/libcamera-daily/src/ipa/vimc/data' Using camera platform/vimc.0 Sensor B [162:49:51.679072374] [188975] INFO VIMC vimc.cpp:212 Skipping unsupported pixel format RGB888 [162:49:51.743390870] [188975] INFO Camera camera.cpp:811 configuring streams: (0) 1920x1080-BGR888 Capture 10 frames 586192.110806 (0.00 fps) stream0 seq: 000000 bytesused: 6220800 586192.149556 (25.81 fps) stream0 seq: 000001 bytesused: 6220800 586192.186044 (27.41 fps) stream0 seq: 000002 bytesused: 6220800 586192.222157 (27.69 fps) stream0 seq: 000003 bytesused: 6220800 586192.270507 (20.68 fps) stream0 seq: 000004 bytesused: 6220800 586192.312244 (23.96 fps) stream0 seq: 000005 bytesused: 6220800 586192.355167 (23.30 fps) stream0 seq: 000006 bytesused: 6220800 586192.394722 (25.28 fps) stream0 seq: 000007 bytesused: 6220800 586192.436829 (23.75 fps) stream0 seq: 000008 bytesused: 6220800 586192.475741 (25.70 fps) stream0 seq: 000009 bytesused: 6220800 ==188975== ==188975== HEAP SUMMARY: ==188975== in use at exit: 0 bytes in 0 blocks ==188975== total heap usage: 9,001 allocs, 9,001 frees, 2,137,733 bytes allocated ==188975== ==188975== All heap blocks were freed -- no leaks are possible ==188975== ==188975== For lists of detected and suppressed errors, rerun with: -s ==188975== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)