OpenPrinting / libcups

OpenPrinting CUPS Library Sources
https://openprinting.github.io/cups/cups3.html
Apache License 2.0
35 stars 17 forks source link

Segfault when using cupsGetDests #74

Closed michaelrsweet closed 8 months ago

michaelrsweet commented 8 months ago

Discussed in https://github.com/OpenPrinting/libcups/discussions/73

Originally posted by **NJRoadfan** January 12, 2024 Hello, I am [working on](https://github.com/Netatalk/netatalk/issues/663) updating some code to support libcups3. I am at the point that I would like to test against the actual libcups3 library. How would one go about doing this? Can libcups3 co-exist with an existing CUPS 2.x install? Or do I have to start fresh with a new Linux VM without any CUPS packages installed and build libcups3? Also, is the cups-local server needed to print? If so, I'll have to build/install it as well. My existing code calls libcups to submit a job (ultimately a PDF) via cupsCreateDestJob() and cupsStartDestDocument().
NJRoadfan commented 8 months ago

Adding some details here to reproduce.

Test environment: Hardware: Raspberry Pi 400 OS: Raspberry Pi OS (Debian 11 "bullseye")

Running CUPS 2.3.3op2 included with OS with one printer queue, the CUPS-PDF printer.

Steps to reproduce: -Clone current master of libcups3 -Configure with --prefix=/usr/ -Compile and install -Built the "simple" application in the CUPS API docs that calls cupsEnumDests() and prints out the results. -Application segfaults when calling cupsEnumDests().

Issue is not just limited to calling cupsEnumDests(). The application I am testing and updating for libcups3 support is also segfaulting when calling cupsGetDests().

Note: I tried testing with the tagged 3.0b2 release. It does not segfault, but still has issues. The sample application outputs a list of printer destinations and then hangs. Have to Ctrl-C at that point.

michaelrsweet commented 8 months ago

OK, so the segfault is an easy fix - the value formatter didn't handle dateTime values...

The hang is occurring when shutting down the DNS-SD thread, not sure why yet.

michaelrsweet commented 8 months ago

Looks like zdohnal fixed the hang in CUPS 2.5, so I brought that fix over:

[master 778600ccc] Fix hang and crash in cupsGetDests (Issue #74)

NJRoadfan commented 8 months ago

Just synced the changes and re-built. Looks like everything is working now, including my project. 👍