Printing and Linux - a non-option

Hi Folks,

Printing on Linux is now completely broken. In testing functionality in 19r1.1 and 19r3.1 on Mint, CentOS, OpenSuSE, Fedora, Arch, and my homebrew config, any call to PageSetupDialog or OpenPrinterDialog on a system with no printer defined causes a hard-crash in your app with no opportunity t catch an exception and handle a fail situation. I do have a printer attached and can print from other, non-Xojo applications.

This case - <https://xojo.com/issue/58365> - only speaks to Pi builds, but I can duplicate on any Linux system - ARM, 32bit, or 64bit.

Around 35 years ago, an Apple (France) Developer Support Engineer answer to a similar question was to check if a printer is defined in the running OS and work accordingly.

In the Xojo environment, I do not know what is the situation.

As far as I recall, every new computer is delivered without a defined printer. Setting a default Printer is the user’s job. Our job is to deal with that. :wink:

In the code below, what happens to pageSetup (Nil ?) if there is no defined Printer ?

Var pageSetup As PrinterSetup pageSetup = New PrinterSetup

I know you’re not crazy :wink:
Some of our customers report the same, too…

But… I can’t tell Xojo how to reproduce this. When I run your latest attached example project on a freshly installed Ubuntu 20.04 VM, it doesn’t crash.
In that setup, there is only the default “print to pdf” available.

Hmm - so what is the printer setup exactly when it crashes reliably? How can you “print from other apps” when there is “no printer defined”?
I somehow suspect that it has to be related to some situation with printers available/configured (but currently not reachable; or if a network printer is configured, but sleeps/awakes).
In <https://xojo.com/issue/58365> @Frank Hoogerbeets notes:

But then again - I couldn’t set up a similar situation that reproduces this 100%.

The sad fact remains that in “some situations / setups”, Xojo built applications on Linux (in general, not just RasPi) are crashing when trying to print. The mistery remains: how to reliably reproduce this? Which situation and/or (printer)-setup has to be met so that the crashes occur?

[quote=490211:@Emile Schwarz]In the code below, what happens to pageSetup (Nil ?) if there is no defined Printer ?

Var pageSetup As PrinterSetup pageSetup = New PrinterSetup[/quote]
Crash.[quote=490247:@Jürg Otter]Hmm - so what is the printer setup exactly when it crashes reliably? How can you “print from other apps” when there is “no printer defined”?
[/quote]
Sorry that I was not more clear - the other apps do not crash when I try to print with no printer attached and I get the crash regardless of whether there is a printer attached and defined.

I’ve now added a printer to the system. I can really print from the settings applet, Libre Office, and Thunderbird Mail.

However, that same test project still crashes. The Page Setting dialog pops up for just long enough to notice and then poof.

I then built the app and ran it from the Terminal and got this backtrace:

$ '/home/tjones/Builds - PrinterFailure/Linux 64 bit/PrinterFailure/PrinterFailure' PrinterFailure: /build/libproxy-qs9zh5/libproxy-0.4.15/libmodman/module_manager.hpp:58: std::vector<T*> libmodman::module_manager::get_extensions() const [with T = libproxy::network_extension]: Assertion `obj != NULL' failed. Aborted (core dumped)
An interesting note is that this printer is directly attached via USB, so I don’t know why a network_extension would be involved …

@William Yu - as always, you are welcome to remote into this system if it would assist in sorting this.

More data -

This is definitely related to network printing.

I unplugged the USB cable and turned off networking on this system and the Page Setup dialog comes up as expected and I can print to PDF. I then plugged the USB cable back in and the same crash occurred as above (SIGABRT, by the way) even though I still had networking disabled. Further checks make it look like a USB printer can sometimes be seen as a network printer - even with networking disabled - depending on how the device reports itself.

Further data points -

CentOS 7.3, OpenSuSE LEAP, Fedora 28 and 31, Mint 19.3, Ubuntu 20.04 and 18.04 all react the same way. All 64bit

however, 32bit seems to suffer the same on 2 older Ubuntu 16.04 and Fedora 18 32bit systems

[quote=490301:@Tim Jones]More data -
This is definitely related to network printing.
[/quote]
That was my conclusion too. See my replies here https://forum.xojo.com/51581-printersetup-crash-on-linux/p2#p474944