Skip to content

indi_gphoto_ccd crashes during Live View with Panasonic Lumix DC-G9 #1292

@mattjowil

Description

@mattjowil

Describe the bug
Human
When initiating "Live Video" in Ekos using a Panasonic Lumix DC-G9, the indi_gphoto_ccd driver crashes after a few seconds.

AI (Here is additional information from Gemini 3):
The issue stems from the fact that Panasonic's Live View stream (PTP Opcode 0x9706) does not send a standard JPEG right away. Instead, it wraps the JPEG frames in a custom container, resulting in 17 bytes of proprietary metadata preceding the actual JPEG SOI marker (0xFF 0xD8).

When libjpeg (or the underlying parser) processes this buffer, it detects the anomaly (Corrupt JPEG data: 17 extraneous bytes before marker 0xd8 and Invalid JPEG file structure: two SOI markers). Since this exception is seemingly not caught within a try-catch block in the driver's video streaming loop, it leads to an unhandled C++ exception (terminate called without an active exception) and completely crashes the indi_gphoto_ccd process.

To Reproduce
Exact steps to reproduce the behavior:

  1. Connect a Panasonic Lumix DC-G9 via USB.
  2. Start the indi_gphoto_ccd driver in Ekos.
  3. Go to the Capture module and click "Live Video".
  4. The live view window opens and might show a stream for a few seconds, sometimes a couple of minutes.
  5. The stream freezes, and Ekos reports: "INDI driver indi_gphoto_ccd crashed!".

Expected behavior
User (human) perspective:
The live stream must be visible until stopped by the user.

AI perspective (includes possible solution hint):

  1. Ideal: The driver should check for the Panasonic-specific header and strip the 17 extraneous bytes (offsetting the buffer to 0xFF 0xD8) before passing it to the JPEG decoder.

  2. Minimum: The driver should have robust error handling (e.g., a try-catch block) around the frame decoding process. If a frame is corrupt or contains unexpected headers, the driver should drop that single frame and log a warning, rather than crashing the entire driver process.

Screenshots
None

Desktop (please complete the following information):

  • OS: Linux Mint 22.3 / Raspberry Pi OS (Debian GNU/Linux 13 (trixie))
  • Version INDI Library: 2.1.6 Code v2.1.5.1-37-g91e3e3525. Protocol 1.7.
  • KStars Version 3.7.9 Stable Build: 2025-11-05T06:45:40Z

Log Files
Relevant excerpt from the log file:
[2026-03-27T21:13:02.414 CET INFO ][ org.kde.kstars.indi] - GPhoto CCD : "[INFO] Starting the video stream with target exposure 0.100000 s (Max theoretical FPS 10) "
[2026-03-27T21:13:02.414 CET DEBG ][ org.kde.kstars.indi] - GPhoto CCD : "[DEBUG] Setting toggle widget viewfinder: 1 "
[2026-03-27T21:13:02.420 CET DEBG ][ org.kde.kstars.indi] - GPhoto CCD : "[DEBUG] Setting new configuration OK. "
[2026-03-27T21:13:02.420 CET DEBG ][ org.kde.kstars.indi] - GPhoto CCD : "[DEBUG] Pixel format 100 is supported by SER recorder. "
[2026-03-27T21:13:02.420 CET DEBG ][ org.kde.kstars.indi] - GPhoto CCD : "[DEBUG] Pixel format 100 is supported by MJPEG encoder. "
[2026-03-27T21:13:13.847 CET DEBG ][ org.kde.kstars.indi] - INDI Server: "2026-03-27T20:13:13: Driver indi_gphoto_ccd: Corrupt JPEG data: 17 extraneous bytes before marker 0xd8"
[2026-03-27T21:13:13.847 CET DEBG ][ org.kde.kstars.indi] - INDI Server: "2026-03-27T20:13:13: Driver indi_gphoto_ccd: Invalid JPEG file structure: two SOI markers"
[2026-03-27T21:13:13.847 CET DEBG ][ org.kde.kstars.indi] - INDI Server: "2026-03-27T20:13:13: Driver indi_gphoto_ccd: terminate called without an active exception"
[2026-03-27T21:13:13.847 CET DEBG ][ org.kde.kstars.indi] - INDI Server: ""
[2026-03-27T21:13:13.995 CET DEBG ][ org.kde.kstars.indi] - INDI Server: "2026-03-27T20:13:13: Driver indi_gphoto_ccd: read EOF"
[2026-03-27T21:13:13.995 CET DEBG ][ org.kde.kstars.indi] - INDI Server: "<delProperty device="GPhoto CCD"/>"
[2026-03-27T21:13:13.995 CET DEBG ][ org.kde.kstars.indi] - INDI Server: "2026-03-27T20:13:13: Driver indi_gphoto_ccd: Terminated after #0 restarts."
[2026-03-27T21:13:13.995 CET DEBG ][ org.kde.kstars.indi] - INDI Server: ""
[2026-03-27T21:13:13.995 CET CRIT ][ org.kde.kstars.indi] - INDI driver "indi_gphoto_ccd" crashed!
log_21-12-25.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions