eclipse.platform.swt icon indicating copy to clipboard operation
eclipse.platform.swt copied to clipboard

Printing a custom size page crashes Eclipse (Linux/GTK)

Open vpa1977 opened this issue 2 years ago • 2 comments

Describe the bug It is impossible to print custom size page on Linux/GTK

To Reproduce

  1. Open any file in the text editor
  2. Select File|Print and click Page Setup.
  3. Define custom page size
  4. Print to File

Eclipse crashes with

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fd94563ed16, pid=41296, tid=41297
#
# JRE version: OpenJDK Runtime Environment (17.0.9+6) (build 17.0.9-ea+6-Ubuntu-1)
# Java VM: OpenJDK 64-Bit Server VM (17.0.9-ea+6-Ubuntu-1, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [libswt-gtk-4962r3.so+0x3ed16]  Java_org_eclipse_swt_internal_C_strlen+0xf
#
# Core dump will be written. Default location: Core dumps may be processed with "/lib/systemd/systemd-coredump %P %u %g %s %t 9223372036854775808 %h" (or dumping to /home/vladimirp/eclipse/jee-2023-09-crashing/eclipse/core.41296)
#
# An error report file with more information is saved as:
# /home/vladimirp/eclipse/jee-2023-09-crashing/eclipse/hs_err_pid41296.log
#
# If you would like to submit a bug report, please visit:
#   Unknown
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Expected behavior PDF file with the current page is printed

Screenshots image

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • [ ] All OS
    • [ ] Windows
    • [x] Linux
    • [ ] macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc) Ubuntu 23.10

  2. JRE/JDK version

17.0.9

Version since ?, first reported here

Workaround (or) Additional context It appears that the return values from GTK are not checked in https://github.com/eclipse-platform/eclipse.platform.swt/blob/459daddd8d72b22437dd88a956ea31feccb45ff0/bundles/org.eclipse.swt/Eclipse%20SWT%20Printing/gtk/org/eclipse/swt/printing/PrintDialog.java causing the subsequent crash.

vpa1977 avatar Nov 01 '23 01:11 vpa1977

Relevant portion of Java stack from crash log:

C  [libswt-gtk-4962r3.so+0x3ed16]  Java_org_eclipse_swt_internal_C_strlen+0xf
j  org.eclipse.swt.printing.PrintDialog.storeBytes(Ljava/lang/String;J)V+1
j  org.eclipse.swt.printing.PrintDialog.open()Lorg/eclipse/swt/printing/PrinterData;+1292

SyntevoAlex avatar Nov 01 '23 08:11 SyntevoAlex