libgphoto2 icon indicating copy to clipboard operation
libgphoto2 copied to clipboard

Segfault in capture(gp.GP_CAPTURE_IMAGE)

Open jabdoa2 opened this issue 1 year ago • 1 comments

Describe the bug

Scenario: We mounted a Sony MX100M7 on a KUKA robot and take pictures at certain points. We sometimes get USB communication issues due to movement/bad cabling/interference.

When we take a picture using the following command we sometimes get segfaults (of our python program):

camera.capture(gp.GP_CAPTURE_IMAGE)

We suspect this happens when we get communications failures. However, the following (simplified) works absolutely fine and can handle the communications failures:

try:
  camera.trigger_capture()
  while True:
      event_type, event_data = self.camera.wait_for_event(1000)
      if event_type == gp.GP_EVENT_FILE_ADDED:
          return event_data
except gp.GPhoto2Error as e:
    print("GOT ERROR: {}. Will retry!".format(e))

Also works with GP_EVENT_CAPTURE_COMPLETE (but takes a bit longer). According to the examples this should behave exactly the same.

In our application we handle the error and reset the camera via libusb. Aferwards, we are able to retry the capture without issues.

Name the camera

$ gphoto2 --auto-detect
Modell                         Port                                            
----------------------------------------------------------
USB PTP Class Camera           usb:001,005

It is a Sony RX100M7.

libgphoto2 and gphoto2 version

$ gphoto2 --version
gphoto2 2.5.23

Copyright (c) 2000-2019 Marcus Meissner and others

gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named COPYING.

This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.23         gcc, popt(m), exif, cdk, aa, jpeg, readline
libgphoto2      2.5.25         standard camlibs (SKIPPING lumix), gcc, ltdl, EXIF
libgphoto2_port 0.12.0         iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, ltdl, EXIF, USB, serial without locking

To Reproduce Steps to reproduce the behavior:

Run the above code repeatedly. It happens roughly every 30 to 50th picture for us in average. Does not happen at all with the second snippet.

jabdoa2 avatar Nov 28 '22 16:11 jabdoa2

please update to libgphoto2 2.5.30. i fixed some memory corruptions in between in the Sony code.

msmeissn avatar Nov 28 '22 16:11 msmeissn