chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.3k stars 461 forks source link

linux: cefclient crash when opening print dialog from pdf viewer #3207

Open magreenblatt opened 2 years ago

magreenblatt commented 2 years ago

Original report by Micha Ahrweiler (Bitbucket: mbaschnitzi, GitHub: mbaschnitzi).


When a pdf in cefclient is opened and the print button inside the pdf viewer is clicked, cefclient segfaults.

This is due to ClientPrintHandlerGtk::OnPrintStart not being called before ClientPrintHandlerGtk::OnPrintSettings, so ClientPrintHandlerGtk::PrintHandler::OnPrintSettings is invoked on NULL.

This happens with and without --use-views, but not with --use-views --enable-chrome-runtime even when selecting ‘Print using system dialog…’.

One way of mitigating this inside cefclient would be to call OnPrintStart inside OnPrintSettings, if it hadn’t been called before, but this of course still violates the documentation on CefPrintHandler::OnPrintStart.

Tested under debian 11, gnome and cefclient 95.7.12+g99c4ac0+chromium-95.0.4638.54. In M88 the issue also happens. In M86 no dialog opens but also no crash, but might be a different issue.

In M84 the issue does not happen with our own application, but I couldn’t confirm with cefclient.

magreenblatt commented 2 years ago

Sounds like it doesn't reproduce with currently supported versions.

magreenblatt commented 2 years ago

Original comment by Josep Torra (Bitbucket: Josep Torra).


I’d just reproduced this issue myself using the following steps in Ubuntu 18.04.

Installled updated cmake following https://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line

wget https://cef-builds.spotifycdn.com/cef_binary_100.0.11%2Bg45b9728%2Bchromium-100.0.4896.46_linux64_beta.tar.bz2
tar xvf cef_binary_100.0.11+g45b9728+chromium-100.0.4896.46_linux64_beta.tar.bz2
cd cef_binary_100.0.11+g45b9728+chromium-100.0.4896.46_linux64_beta
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .
make -j8 cefclient
cd tests/cefclient/Release
./cefclient --url=https://and-mag.com/pubs/and-mag-i01.pdf

And got the following backtrace.

#0  0x000055e2ad1cbddd in client::ClientPrintHandlerGtk::PrintHandler::OnPrintSettings(scoped_refptr<CefPrintSettings>, bool) ()
[Current thread is 1 (Thread 0x7f46b4a35c40 (LWP 15334))]
(gdb) bt
#0  0x000055e2ad1cbddd in client::ClientPrintHandlerGtk::PrintHandler::OnPrintSettings(scoped_refptr<CefPrintSettings>, bool) ()
#1  0x000055e2ad1cc5ac in client::ClientPrintHandlerGtk::OnPrintSettings(scoped_refptr<CefBrowser>, scoped_refptr<CefPrintSettings>, bool) ()
#2  0x000055e2ad233d56 in (anonymous namespace)::print_handler_on_print_settings(_cef_print_handler_t*, _cef_browser_t*, _cef_print_settings_t*, int) ()
#3  0x00007f46ab20f41a in OnPrintSettings () at ../../cef/libcef_dll/ctocpp/print_handler_ctocpp.cc:66
#4  0x00007f46ae67c77b in UpdateSettings () at ../../cef/libcef/browser/printing/print_dialog_linux.cc:270
#5  0x00007f46b0f22bfe in printing::PrintingContextLinux::UseDefaultSettings() () at ../../printing/printing_context_linux.cc:101
#6  0x00007f46b0a2f8ef in UseDefaultSettings () at ../../chrome/browser/printing/print_job_worker.cc:323

Please could you verify that is really fixed and point us which is the fix.

magreenblatt commented 2 years ago

Original comment by Josep Torra (Bitbucket: Josep Torra).


In addition, a build of a previous version in debug mode I could narrow to browser being null at https://bitbucket.org/chromiumembedded/cef/src/4615fffafbdd48f69dcde745a37bb82b903ce934/libcef/browser/printing/print_view_manager.cc#lines-237

I’d tried to understand the rest of code with no luck, but it seemed to me like the browser and webcontents map isn’t resolving. Maybe because webcontents is related to a ViewGuest?

magreenblatt commented 2 years ago
magreenblatt commented 2 years ago
magreenblatt commented 1 year ago