Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: window.print() without printers causes the main process to crash #31151

Open
3 tasks done
andsmedeiros opened this issue Sep 27, 2021 · 28 comments
Open
3 tasks done

Comments

@andsmedeiros
Copy link

andsmedeiros commented Sep 27, 2021

Preflight Checklist

Electron Version

14.0.1

What operating system are you using?

Ubuntu

Operating System Version

5.11.0-37-generic #41-Ubuntu SMP Mon Sep 20 16:39:20 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

What arch are you using?

x64

Last Known Working Electron version

13.4.0

Expected Behavior

Calling window.print() should open the print window, even if there are no printers installed in the system.

Actual Behavior

Calling window.print() from the renderer process crashes the main process.

Testcase Gist URL

https://gist.github.com/85a5466567215173419a17982e79becb

Additional Information

When the process crashes, the terminal prints:

#0 0x5616b9f1e143 <unknown>
#1 0x5616b9fc517c <unknown>
#2 0x5616b9fc5141 close
#3 0x7f4c4568817b <unknown>

Failed to get crash dump id.
Report Id: --2021-09-27 12:

Failed to get crash dump id.
Report Id: --2021-09-27 12:
PATH/TO/PROJECT/node_modules/electron/dist/electron exited with signal SIGILL

When calling BrowserWindow.print(), the console prints:
[22590:0927/121740.971531:ERROR:print_backend_cups.cc(218)] CUPS: Error getting default printer: No destinations added.
and the print callback is called with [ false, 'no valid printers available' ] for args. The main process does not crash, but the print window never opens (I have filed a similar issue back at v10.x: #25498)

On v13.4.0, a similar error message is printed, but the process does not crashes (or does, but recovers immediately somehow):

Crashing due to FD ownership violation:
#0 0x564e03bc1143
<unknown>
#1 0x564e03c6817c <unknown>
#2 0x564e03c68141 close
#3 0x7f20e79ea17b <unknown>

Electron exited with signal SIGTRAP.
Saving files to temp directory...
Saved files to /tmp/tmp-18241-0f2HhywGTnpu
Electron v13.4.0 started.

Also, the print window is correctly displayed, containing only the 'Print to File' option.

@laurent22
Copy link

Same problem with v14 on Linux. It crashes the application: laurent22/joplin#5651

@andsmedeiros
Copy link
Author

This persists in v15.3.0

[21457:1101/150957.956472:ERROR:nss_util.cc(286)] After loading Root Certs, loaded==false: NSS error code: -8018
Crashing due to FD ownership violation:
#0 0x5560142abb73
<unknown>
#1 0x55601435329c <unknown>
#2 0x556014353261 close
#3 0x7fb74344717b <unknown>
[21494:1101/150958.271823:ERROR:broker_posix.cc(40)] Recvmsg error: Connection reset by peer (104)

Electron exited with signal SIGTRAP.

@andsmedeiros
Copy link
Author

Can this be triaged, please? Having the main process crash in response to an absolutely fine call in the renderer seems some pretty disruptive behaviour.

@danipiresk2k13
Copy link

danipiresk2k13 commented Nov 21, 2021

I have the same issue on electron v16.

I already tested it with silent: false and prints a blank page.

Any Ideas/ solutions?

@Phylu
Copy link

Phylu commented Jan 11, 2022

I encountered the same issue on electron v14.2.1. However, this does not seem to be an issue whether there is a (default) printer configured or not. I have a configured printer, that shows up if I print anything using the system print window. Only electron crashes:

Crashing due to FD ownership violation:
#0 0x557a4ca63973 <unknown>
#1 0x557a4cb0a9ac <unknown>
#2 0x557a4cb0a971 close
#3 0x7fb0a84fa17b <unknown>

Failed to get crash dump id.
Report Id: --2022-01-11 22:

Failed to get crash dump id.
Report Id: --2022-01-11 22:
[1]    38072 illegal hardware instruction  mailspring

This is only a problem on my Ubuntu 21.10 machine, but not on my macOS 12.0.1 macbook.

@nornagon
Copy link
Member

Please attach a crash dump. You can collect them by adding the following snippet to your main process code, before app.whenReady:

const { app, crashReporter } = require('electron')

console.log(app.getPath('crashDumps'))
crashReporter.start({ submitURL: '', uploadToServer: false })

Then reproduce the crash, zip up the crash dumps directory and attach it here.

@andsmedeiros
Copy link
Author

@nornagon I just tried that but the crash directory wasn't even created.

This is the gist I just tried:
https://gist.github.com/c48b913d1213fa1adfc97bbe1a3ddb5e

It still crashes with v16.0.7 and 17.0.0-beta.3.

@Phylu
Copy link

Phylu commented Jan 13, 2022

@nornagon Here is a fresh crash dump. :)
print-crash.zip

@AlexTaverna
Copy link

AlexTaverna commented Mar 24, 2022

i have the same problem on v17.0.1

Crashing due to FD ownership violation:
#0 0x559a8df8cd53 <unknown>
#1 0x559a8e03a3dc <unknown>
#2 0x559a8e03a3a1 <unknown>
#3 0x7ffb8b297cdb <unknown>

@nornagon if i try to generate the crash dump i get :
[0324/103809.989226:ERROR:scoped_ptrace_attach.cc(27)] ptrace: Operation not permitted (1)

@charlag
Copy link

charlag commented Sep 20, 2022

It is happening to our users quite a lot but not across all distros (e.g. happening on Ubuntu 22.04 and older, does not occur on Fedora 36, does not occurs on Debian 11).

@andsmedeiros
Copy link
Author

I just tried this fiddle with v17.0.0 and the print window does open, but the whole program crashes as soon as I cancel the dialog (without the weird stacktrace or FD violation errors, just a SIGSEGV).
Printing works, though.
I also tested with v17.4.11, v18.0.0, v19.0.0 and v20.0.0 and everything works as intended (opening the dialog, cancelling and printing). This must be already corrected by either of the Electron or Ubuntu teams. As I also upgraded my Ubuntu version to 22.04 from then, it is hard to be sure where the issue was.
I am not closing this issue as it looks like it still affects other people, possibly with the same OS as mine.

@charlag
Copy link

charlag commented Nov 14, 2022

For maintainers I would ilke to point out that this seems to be related to network printers
tutao/tutanota#3727 (comment)

@martijnhartlief
Copy link

Good catch, we're indeed only using network printers, it never occurred to me that it was tested with a local printer.

@alishefaee
Copy link

alishefaee commented Dec 24, 2022

I'm using linux Linux Mint 21.1 "Vera" Cinnamon Edition and slightly after print page pops up I got this error and app close immediately :

Crashing due to FD ownership violation:
#0 0x55b4c8700f23 <unknown>
#1 0x55b4c877cc5c <unknown>
#2 0x55b4c877cc21 close
#3 0x7f7f690d6ef3 <unknown>
/home/shefa/printer-electron/node_modules/electron/dist/electron exited with signal SIGTRAP

//package.json

  "devDependencies": {
    "electron": "^22.0.0",
    "electron-builder": "^23.6.0",
  },
  "build": {
    "appId": "appId",
    "productName": "management",
    "publish": [
      {
        "provider": "generic",
        "url": "http://127.0.0.1:8080/"
      }
    ],
    "linux": {
      "target": [
        "AppImage",
        "deb"
      ],
      "icon": "icon/logo.png"
    },
  }

update:
content of

console.log(app.getPath('crashDumps'))

will be attach
Crashpad.zip
ed.

@icecream17
Copy link

icecream17 commented Mar 4, 2023

Although it says v13.4.0 works in the issue, it also fails with pulsar's electron version (v12.2.3)

Edit: As mentioned in the issue mentioning this one, the electron build instructions for linux fundamentally require various libcup* dependencies depending on distro. This is probably because chromium requires it? See issue

@aswinsekar
Copy link

Issue exist in ^21.0.0 when Linux machine have network printer configured.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 4, 2023

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jun 4, 2023
@atheck
Copy link

atheck commented Jun 5, 2023

It still does not work with electron 24.4.1. With electron 25.0.1 nothing happens when calling webContents.print(). But maybe I'm doing something wrong. I have to check this.

@github-actions github-actions bot removed the stale label Jun 6, 2023
@shoebilyas123
Copy link

shoebilyas123 commented Jun 25, 2023

This issue still exists. I was trying to print on my Ubuntu 22.04.2 LTS and have no printers attached to my pc. I get the error
[20623:0625/195233.252880:ERROR:print_backend_cups.cc(220)] CUPS: Error getting default printer: No destinations added.

The app should atleast open a print window irrespective of whether there's a printer or not.

@woyishengwuti
Copy link

It still does not work with electron 14.x,15.x,16.x,17.x,I was trying to print on my Ubuntu 22.04.6 LTS and only using network printers.I get the error (Use 'electron --trace-warnings ...' to show where the warning was created)[24794:0707/100229.237004:ERROR:sandbox linux.cc(374)] InitializeSandbox() called with multiple threads in process gpu-process.24803:0707/100232.097834:ERROR:print render frame helper.cc(2080)] Printing failed.Crashing due to FD ownership violation: #0 0x558ba38b93c3 <unknown> #1 0x558ba39603fc <unknown> #2 0x558ba39603C1close #3 0x7f2524901cdb<unknown>

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@popod
Copy link
Contributor

popod commented Oct 6, 2023

bump

@yashimself
Copy link

This issue persists with Electron version 25.3.0. Tested on Ubuntu 22.04 LTS. I get the following error when network printers are attached and the app crashes:

Crashing due to FD ownership violation:
#0 0x559b77ae8a73 <unknown>
#1 0x559b77adca9c <unknown>
#2 0x559b77adca6b close
#3 0x7efc8cef9ef3 <unknown>

@Rigner
Copy link

Rigner commented Nov 30, 2023

Hey,

The Crashing due to FD ownership violation: error is still an issue on all Electron 14+ releases. It's caused by a safety measure added in Chromium 92. Doesn't only happen in window.print() but also any native-module that calls fork() to summon a new child process.
More details can be found here: https://bugs.chromium.org/p/chromium/issues/detail?id=1280227

I've tried to get in contact with anyone who could give some guidance on how we could get it fixed over the last few days (or at least what would be the best way to get it sorted), but didn't get a single response.

If nobody from the electron team answers in the next 24 hours, I'll check tomorrow how I can add an option on linux to turn off that FD ownership safety (since adding something to reset FD states after fork() seems like a lot of pain).

Have a nice day and I hope it helps!

@valueerrorx
Copy link

as far as i understand your latest fix PR didn't make it. @Rigner
so this issue is still not fixed.. is it?

for now i send the path to the backend and use "xdg-open filepath" as a workaround in my app but there needs to be a better way.

@Rigner
Copy link

Rigner commented Jan 19, 2024

Indeed, I need to allocate time to find a proper solution to that issue...

Well for your use case, there would be only one: adding a way to turn off the chromium safeties, like I did in the PR, just need to move the code around

Would also need to add a way to reset that safety, it's just annoying to do because you would need to access chromium through electron, from a native lib, and my knowledge on that part is quite limited (+ only a few people know about that topic, I wasn't able to find anyone who could help me when I made that feature)

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@andsmedeiros
Copy link
Author

bump -- AFAIK this still occurs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: No status
Development

No branches or pull requests