jim-easterbrook / python-gphoto2

Python interface to libgphoto2
GNU Lesser General Public License v3.0
359 stars 59 forks source link

segfault when calling gp_camera_get_storageinfo after camera disconnected #66

Closed AntiSol closed 5 years ago

AntiSol commented 5 years ago

Hi again, This time I might have an actual bug for you: if I call gp_camera_get_storageinfo after turning off or disconnecting the camera, python segfaults.

jim-easterbrook commented 5 years ago

Yep, I'm able to reproduce this one. I get a nice set of warnings from libgphoto2 first though.

WARNING: gphoto2: (b'gp_libusb1_write [libusb1.c:589]') b"'libusb_bulk_transfer (port->pl->dh, port->settings.usb.outep, (unsigned char*)bytes, size, &curwritten, port->timeout)' failed: No such device (it may have been disconnected) (-4)"
WARNING: gphoto2: (b'gp_port_write [gphoto2-port.c:406]') b'Writing 12 = 0xc bytes to port failed: Could not find the requested device on the USB port (-52)'
WARNING: gphoto2: (b'ptp_usb_sendreq [usb.c:109]') b'PTP_OC 0x1004 sending req failed: Could not find the requested device on the USB port (-52)'
WARNING: gphoto2: (b'storage_info_func [library.c:7429]') b"'ptp_getstorageids (params, &sids)' failed: PTP No Device (0x02f9)"
WARNING: gphoto2: (b'gp_camera_get_storageinfo [gphoto2-camera.c:1849]') b"'gp_filesystem_get_storageinfo ( camera->fs, sifs, nrofsifs, context )' failed: -52"
Segmentation fault (core dumped)
jim-easterbrook commented 5 years ago

Commit 16aa491 fixes this bug.

jim-easterbrook commented 5 years ago

Now released as version 1.8.4.

AntiSol commented 5 years ago

awesome, thanks, but I'm getting the following trying to upgrade:

$ sudo pip install --upgrade gphoto2
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
Collecting gphoto2
  Downloading https://files.pythonhosted.org/packages/5f/f2/1579e8525c3deaa7b468d43548dad186c083fe12e41a89876c561039abc1/gphoto2-1.8.4.tar.gz (7.3MB)
    100% |████████████████████████████████| 7.3MB 770kB/s 
Installing collected packages: gphoto2
  Found existing installation: gphoto2 1.8.3
    Uninstalling gphoto2-1.8.3:
      Successfully uninstalled gphoto2-1.8.3
  Running setup.py install for gphoto2 ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-Za3D1n/gphoto2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-jKDI8C/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/version.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/port_info_list.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/file.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/result.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/abilities_list.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/list.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/camera.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/context.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/filesys.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/widget.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/port_log.py -> build/lib.linux-x86_64-2.7/gphoto2
    copying src/swig-bi-py2-gp2.5.0/__init__.py -> build/lib.linux-x86_64-2.7/gphoto2
    running build_ext
    building '_port_log' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/src
    creating build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include -I/usr/include/libexif -I/usr/include/python2.7 -c src/swig-bi-py2-gp2.5.0/port_log_wrap.c -o build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/port_log_wrap.o -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label -Wno-strict-prototypes -DGPHOTO2_VERSION=0x020509
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/port_log_wrap.o -lgphoto2 -lm -lgphoto2_port -lm -lexif -o build/lib.linux-x86_64-2.7/gphoto2/_port_log.so
    building '_list' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include -I/usr/include/libexif -I/usr/include/python2.7 -c src/swig-bi-py2-gp2.5.0/list_wrap.c -o build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/list_wrap.o -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label -Wno-strict-prototypes -DGPHOTO2_VERSION=0x020509
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/list_wrap.o -lgphoto2 -lm -lgphoto2_port -lm -lexif -o build/lib.linux-x86_64-2.7/gphoto2/_list.so
    building '_context' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include -I/usr/include/libexif -I/usr/include/python2.7 -c src/swig-bi-py2-gp2.5.0/context_wrap.c -o build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/context_wrap.o -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label -Wno-strict-prototypes -DGPHOTO2_VERSION=0x020509
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/context_wrap.o -lgphoto2 -lm -lgphoto2_port -lm -lexif -o build/lib.linux-x86_64-2.7/gphoto2/_context.so
    building '_filesys' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include -I/usr/include/libexif -I/usr/include/python2.7 -c src/swig-bi-py2-gp2.5.0/filesys_wrap.c -o build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/filesys_wrap.o -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label -Wno-strict-prototypes -DGPHOTO2_VERSION=0x020509
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/filesys_wrap.o -lgphoto2 -lm -lgphoto2_port -lm -lexif -o build/lib.linux-x86_64-2.7/gphoto2/_filesys.so
    building '_widget' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include -I/usr/include/libexif -I/usr/include/python2.7 -c src/swig-bi-py2-gp2.5.0/widget_wrap.c -o build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/widget_wrap.o -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label -Wno-strict-prototypes -DGPHOTO2_VERSION=0x020509
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/widget_wrap.o -lgphoto2 -lm -lgphoto2_port -lm -lexif -o build/lib.linux-x86_64-2.7/gphoto2/_widget.so
    building '_version' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include -I/usr/include/libexif -I/usr/include/python2.7 -c src/swig-bi-py2-gp2.5.0/version_wrap.c -o build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/version_wrap.o -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label -Wno-strict-prototypes -DGPHOTO2_VERSION=0x020509
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/version_wrap.o -lgphoto2 -lm -lgphoto2_port -lm -lexif -o build/lib.linux-x86_64-2.7/gphoto2/_version.so
    building '_port_info_list' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include -I/usr/include/libexif -I/usr/include/python2.7 -c src/swig-bi-py2-gp2.5.0/port_info_list_wrap.c -o build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/port_info_list_wrap.o -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label -Wno-strict-prototypes -DGPHOTO2_VERSION=0x020509
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/port_info_list_wrap.o -lgphoto2 -lm -lgphoto2_port -lm -lexif -o build/lib.linux-x86_64-2.7/gphoto2/_port_info_list.so
    building '_file' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include -I/usr/include/libexif -I/usr/include/python2.7 -c src/swig-bi-py2-gp2.5.0/file_wrap.c -o build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/file_wrap.o -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label -Wno-strict-prototypes -DGPHOTO2_VERSION=0x020509
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/file_wrap.o -lgphoto2 -lm -lgphoto2_port -lm -lexif -o build/lib.linux-x86_64-2.7/gphoto2/_file.so
    building '_camera' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include -I/usr/include/libexif -I/usr/include/python2.7 -c src/swig-bi-py2-gp2.5.0/camera_wrap.c -o build/temp.linux-x86_64-2.7/src/swig-bi-py2-gp2.5.0/camera_wrap.o -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label -Wno-strict-prototypes -DGPHOTO2_VERSION=0x020509
    src/swig-bi-py2-gp2.5.0/camera_wrap.c:3845:7: error: ‘GP_EVENT_FILE_CHANGED’ redeclared as different kind of symbol
       int GP_EVENT_FILE_CHANGED = GP_EVENT_CAPTURE_COMPLETE + 1;
           ^
    In file included from /usr/include/gphoto2/gphoto2-library.h:29:0,
                     from /usr/include/gphoto2/gphoto2.h:51,
                     from src/swig-bi-py2-gp2.5.0/camera_wrap.c:3821:
    /usr/include/gphoto2/gphoto2-camera.h:109:2: note: previous definition of ‘GP_EVENT_FILE_CHANGED’ was here
      GP_EVENT_FILE_CHANGED /**< CameraFilePath* = file path on camfs */
      ^
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
  Rolling back uninstall of gphoto2
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-Za3D1n/gphoto2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-jKDI8C/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-Za3D1n/gphoto2/

thoughts?

jim-easterbrook commented 5 years ago

The installer reckons you've got libgphoto2 version 2.5.9 (the -DGPHOTO2_VERSION=0x020509 option on each compiler command) which means GP_EVENT_FILE_CHANGED shouldn't be defined in the C library as it was added in version 2.5.17. This may be a result of your attempts to upgrade libgphoto2. The header files are new but pkg-config --modversion libgphoto2 gives the old version.

AntiSol commented 5 years ago

Aah, thanks, yeah it turns out i had an old pkgconfig file hanging around from the old version. I deleted it and was able to install the new version just fine. Confirmed fixed. thanks!