Bug 706940 - Dereference of free object; can't embed LibertinusSans-Bold
Summary: Dereference of free object; can't embed LibertinusSans-Bold
Status: RESOLVED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 10.01.2
Hardware: PC Linux
: P4 normal
Assignee: Default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-25 16:20 UTC by Karl Berry
Modified: 2023-07-25 19:47 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
doc.pdf input file (2.14 MB, application/pdf)
2023-07-25 16:20 UTC, Karl Berry
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Berry 2023-07-25 16:20:48 UTC
Created attachment 24601 [details]
doc.pdf input file

With attached doc.pdf, running (gs 10.01.2, compiled from original source, GNU/Linux x86_64)

gs -q -dNOPAUSE -DBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf doc.pdf

results in

Dereference of free object 149, next object number as offset failed, returning NULL object.                                                                    
GPL Ghostscript 10.01.2: Can't embed the complete font QMNCHZ+LibertinusSans-Bold as it is too large, embedding a subset.         

The output looks ok at first blush, but evidently something must be awry.

I get the same error messages with 9.56.1 and 9.20.

Sorry, my attempts to cut down the input pdf made the problem go away.

Thanks,
Karl
Comment 1 Ken Sharp 2023-07-25 18:10:10 UTC
The PDF file has an xref which contains this line at index 149:

0000000162 00256 f 

So that means object 149 can be found at offset 162, has a generation number of 256 and is a free object.

There is no object 149 in the file and there is no object at offset 162, that is the middle of object 4, which is an annotation. The object is, however, referenced in the file by object 134:

134 0 obj
<<
  /S /Transparency
  /CS 149 0 R
>>
endobj

and object 134 is used by a Form XObject:

122 0 obj
<<
  /Type /XObject
  /Subtype /Form
  /FormType 1
  /PTEX.FileName (./img/shadowbox.pdf)
  /PTEX.PageNumber 1
  /PTEX.InfoDict 137 0 R
  /BBox [ 0 0 292 151 ]
  /Group 134 0 R

That From is used by a Resources Dictionary:

130 0 obj
<<
  /Font <<
...
  >>
  /XObject <<
    /Fm2 121 0 R
    /Im9 122 0 R

Which is used by the Page object 131:

131 0 obj
<<
  /Type /Page
  /Contents 132 0 R
  /Resources 130 0 R

Which is page #6 in the Pages tree.

So in summary; yes something is awry. It's your PDF file. There is also a separate error in a pattern.

Just because Ghostscript tells you there is a problem with your PDF file, and other consumers don't, doesn't mean Ghostscript has a bug.

The warning about embedding the font is a different issue altogether and is probably due to the size of the font (doesn't look like it has been subset at all). Ghostscript embeds a subset font in the output and I imagine it works correctly.

I don't actually see any bug here, except the knackered input file.
Comment 2 Karl Berry 2023-07-25 19:47:42 UTC
Thanks much for the analysis, and sorry for the noise.