Bug 703013

Summary: Broken 16-bit visuals in X Display Driver
Product: Ghostscript Reporter: Alexei Podtelezhnikov <apodtele>
Component: X Display DriverAssignee: Chris Liddell (chrisl) <chris.liddell>
Status: RESOLVED FIXED    
Severity: normal CC: mjg, sphinx.pinastri
Priority: P4    
Version: 9.25   
Hardware: PC   
OS: Windows 10   
Customer: Word Size: ---
Attachments: Distorted screenshot
Test case for seg fault

Description Alexei Podtelezhnikov 2020-10-21 17:57:25 UTC
Created attachment 19985 [details]
Distorted screenshot

X11 driver appears to be severely broken with 16-bit visuals, see attached screenshot: striped instead of white background, distorted fill color in cropped  path. I am using RealVNC to force 16-bit visuals.

$ xdpyinfo
...
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    6
supported pixmap formats:
    depth 32, bits_per_pixel 32, scanline_pad 32
    depth 24, bits_per_pixel 32, scanline_pad 32
    depth 16, bits_per_pixel 16, scanline_pad 32
    depth 8, bits_per_pixel 8, scanline_pad 32
    depth 4, bits_per_pixel 8, scanline_pad 32
    depth 1, bits_per_pixel 1, scanline_pad 32
...
screen #0:
  dimensions:    1920x1080 pixels (488x274 millimeters)
  resolution:    100x100 dots per inch
  depths (6):    16, 32, 24, 8, 4, 1
  root window id:    0x3f
  depth of root window:    16 planes
  number of colormaps:    minimum 1, maximum 1
  default colormap:    0x20
  default number of colormap cells:    64
  preallocated pixels:    black 0, white 65535
  options:    backing-store YES, save-unders YES
  largest cursor:    1920x1080
  current input event mask:    0xfac033
    KeyPressMask             KeyReleaseMask           EnterWindowMask          
    LeaveWindowMask          KeymapStateMask          ExposureMask             
    StructureNotifyMask      SubstructureNotifyMask   SubstructureRedirectMask 
    FocusChangeMask          PropertyChangeMask       ColormapChangeMask       
  number of visuals:    8
  default visual id:  0x23
  visual:
    visual id:    0x23
    class:    TrueColor
    depth:    16 planes
    available colormap entries:    64 per subfield
    red, green, blue masks:    0xf800, 0x7e0, 0x1f
    significant bits in color specification:    8 bits
Comment 1 Peter Cherepanov 2021-01-02 21:18:21 UTC
To reproduce on Linux desktop:
Xephyr -screen "1280x1024x16"  :1
DISPLAY=:1 ~/ghostpdl/debugbin/gs -dEPSCrop  ~/ghostpdl/examples/tiger.eps 
Other unusual visuals are also broken.
Comment 2 Chris Liddell (chrisl) 2022-02-21 11:29:59 UTC
Fixed in:
https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=270438bfda60
Comment 3 M.J.G. 2022-09-03 15:44:03 UTC
Created attachment 23111 [details]
Test case for seg fault

That fix may have broken some devices, in particular x11cmyk x11gray2 x11gray4 give a seg fault when doing (i= one of those, others work):

gs  -dBATCH -dNOPAUSE -sDEVICE=$i -sOutputFile=/dev/null dummy.pdf >/dev/null

I bisected this to commit 270438bfda60. Should I open a new bug or reopen?