Re: print/texlive/base: use bundled poppler for now

2017-12-25 Thread Matthias Kilian
Hi,

On Mon, Dec 25, 2017 at 11:00:00AM +, Edd Barrett wrote:
> Any info you have on the crash would also be useful. Did you have a trace?

That's what I got today, when building math/octave (exactly: when
math/octave runs texi2pdf to generate pdf documentation). Please
note that you'll probably have to use egdb (package gdb from ports).

$ egdb /usr/local/bin/pdftex pdftex.core 
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-openbsd6.2".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/bin/pdftex...done.
[New process 223395]
Core was generated by `pdftex'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  _rthread_mutex_timedlock (mutexp=0x22a, trywait=0, abs=0x0, timed=0) at 
/usr/src/lib/libc/thread/rthread_mutex.c:154
154 if (*mutexp == NULL) {
(gdb) bt
#0  _rthread_mutex_timedlock (mutexp=0x22a, trywait=0, abs=0x0, timed=0) at 
/usr/src/lib/libc/thread/rthread_mutex.c:154
#1  0x178abe406ea3 in MutexLocker::MutexLocker (this=0x7f7e2600, 
mutexA=0x22a) at ../goo/GooMutex.h:78
#2  0x178abe427b7d in Dict::add(char*, Object&&) (this=0x202, 
key=0x178abafcdaf0 "ProcSet", val=) at Dict.cc:145
#3  0x1788965c8599 in Object::dictAdd(char*, Object&&) 
(this=0x7f7e2a40, key=0x178abafcdaf0 "ProcSet", val=)
at /usr/local/include/poppler/Object.h:347
#4  0x1788965c5179 in initDictFromDict (obj=..., dict=0x178ab8fdc240) at 
../.././../texk/web2c/pdftexdir/pdftoepdf.cc:196
#5  0x1788965c3c7f in write_epdf () at 
../.././../texk/web2c/pdftexdir/pdftoepdf.cc:963
#6  0x1788965a880c in writeimage (img=0) at 
../.././../texk/web2c/pdftexdir/writeimg.c:382
#7  0x17889656499c in zpdfwriteimage (n=4) at pdftex0.c:22285
#8  0x1788965934b8 in doextension () at pdftex0.c:37228
#9  0x178896596ff1 in maincontrol () at pdftex0.c:38916
#10 0x1788965215ab in mainbody () at pdftexini.c:5656
#11 0x178896503117 in main (ac=5, av=0x7f7e2f68) at 
../.././../texk/web2c/lib/texmfmp.c:1013



And from the build log of math/octave:

TEXINPUTS="/home/ports/pobj/p2/octave-4.2.1/octave-4.2.1/build-aux:$TEXINPUTS" \
MAKEINFO='/bin/sh 
/home/ports/pobj/p2/octave-4.2.1/octave-4.2.1/build-aux/missing makeinfo   -I 
doc/interpreter -I 
/home/ports/pobj/p2/octave-4.2.1/octave-4.2.1/doc/interpreter' \
texi2pdf  --build-dir=doc/interpreter/octave.t2p -o doc/interpreter/octave.pdf  
\
`test -f 'doc/interpreter/octave.texi' || echo 
'/home/ports/pobj/p2/octave-4.2.1/octave-4.2.1/'`doc/interpreter/octave.texi
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016-OpenBSD_Ports) 
(preloaded format=pdfetex)
 restricted \write18 enabled.
entering extended mode
(/home/ports/pobj/p2/octave-4.2.1/octave-4.2.1/doc/interpreter/octave.texi
(/home/ports/pobj/p2/octave-4.2.1/octave-4.2.1/build-aux/texinfo.tex
Loading texinfo [version 2016-09-18.18]: pdf, fonts, markup, glyphs,
page headings, tables, conditionals, indexing, sectioning, toc, environments,
defuns, macros, cross references, insertions,
(/usr/local/share/texmf-local/tex/generic/epsf/epsf.tex
This is `epsf.tex' v2.7.4 <14 February 2011>
) localization, formatting, and turning on texinfo input format.)
(/home/ports/pobj/p2/octave-4.2.1/octave-4.2.1/doc/interpreter/macros.texi)
(/home/ports/pobj/p2/octave-4.2.1/octave-4.2.1/doc/interpreter/version-octave.t
exi) 

Re: print/texlive/base: use bundled poppler for now

2017-12-25 Thread Edd Barrett
Hi Kili,

Thanks for working on this.

Can you give me a few days to check out the pdftex crash and see if I can fix 
it? I should be able to work on this on and after the 27th.

Any info you have on the crash would also be useful. Did you have a trace?

Thanks again, and happy holidays.

On 25 December 2017 00:45:22 GMT+00:00, Matthias Kilian 
 wrote:
>On Thu, Dec 21, 2017 at 11:44:23PM +0100, Matthias Kilian wrote:
>> tl;dr: scroll down, apply the patch, run a bulk build, send ok's
>
>Ping. There will be no update of print/poppler without this. I'm
>trying to update poppler since more than 9 months now, fixed a
>couple ports in advance, and the last piece that's in the way is
>texlive.  Nobody will debug it until a poppler update is in the
>tree, and upstream probably won't fix it before tl-2018, which would
>probably hit our ports tree end of 2018 or early 2019.
>
>Either texlive suffers from the outdated bundled poppler, or all
>other ports suffer from the outdated poppler in our tree.
>
>Ciao,
>   Kili
>
>Index: Makefile
>===
>RCS file: /cvs/ports/print/texlive/base/Makefile,v
>retrieving revision 1.94
>diff -u -p -r1.94 Makefile
>--- Makefile   23 Oct 2017 17:11:02 -  1.94
>+++ Makefile   21 Dec 2017 22:19:08 -
>@@ -6,7 +6,7 @@ COMMENT =  base binaries for TeXLive typ
> DISTNAME =texlive-${DIST_V}b-source
> PKGNAME = texlive_base-${V}
> WRKDIST = ${WRKDIR}/texlive-${DIST_V}-source
>-REVISION =4
>+REVISION =5
> 
> DISTFILES =   ${DISTNAME}${EXTRACT_SUFX} \
>   texlive-${DIST_V}-extra${EXTRACT_SUFX}
>@@ -19,7 +19,7 @@ SHARED_LIBS +=   texlua520.0 # 7.4
> WANTLIB += ICE SM X11 Xau Xaw Xdmcp Xext Xi Xmu Xpm Xrender Xt
> WANTLIB += c cairo expat fontconfig freetype gd glib-2.0 graphite2
>WANTLIB += harfbuzz harfbuzz-icu iconv icudata icui18n icuio icuuc intl
>-WANTLIB += jpeg lcms2 m openjp2 paper pcre pixman-1 png poppler
>+WANTLIB += jpeg m paper pcre pixman-1 png
> WANTLIB += potrace pthread ${COMPILER_LIBCXX} tiff webp xcb
> WANTLIB += xcb-render xcb-shm z zzip
> WANTLIB += ${LIBCXX}
>@@ -35,7 +35,6 @@ RUN_DEPENDS =print/ghostscript/gnu \
> LIB_DEPENDS = converters/libiconv \
>   graphics/png \
>   graphics/gd \
>-  print/poppler \
>   graphics/cairo \
>   textproc/icu4c \
>   graphics/graphite2 \
>@@ -46,15 +45,11 @@ LIB_DEPENDS =  converters/libiconv \
> 
> MODULES = textproc/intltool perl
> 
>-# c++-11 required for poppler
>-COMPILER =base-clang ports-gcc
>-
> # Never set SEPARATE_BUILD
> CONFIGURE_STYLE = gnu
> 
> CPPFLAGS =-I${X11BASE}/include \
>-  -I${LOCALBASE}/include \
>-  -I${LOCALBASE}/include/poppler
>+  -I${LOCALBASE}/include
> 
> CXXFLAGS +=   -std=c++11
> 
>@@ -112,12 +107,10 @@ CONFIGURE_ARGS +=--mandir=${PREFIX}/man
>   --with-banner-add="-OpenBSD_Ports" \
>   --disable-luajittex \
>   --disable-mfluajit \
>-  --with-system-xpdf \
>   --with-system-icu \
>   --with-system-cairo \
>   --with-system-harfbuzz \
>   --with-system-graphite2 \
>-  --with-system-poppler \
>   --with-system-libpaper \
>   --with-system-zziplib \
>   --with-system-potrace

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Re: print/texlive/base: use bundled poppler for now

2017-12-24 Thread Jeremie Courreges-Anglas
On Mon, Dec 25, 2017 at 01:45:22AM +0100, Matthias Kilian wrote:
> On Thu, Dec 21, 2017 at 11:44:23PM +0100, Matthias Kilian wrote:
> > tl;dr: scroll down, apply the patch, run a bulk build, send ok's

Sorry to pick this up so late...

> Ping. There will be no update of print/poppler without this. I'm
> trying to update poppler since more than 9 months now, fixed a
> couple ports in advance, and the last piece that's in the way is
> texlive.  Nobody will debug it until a poppler update is in the
> tree, and upstream probably won't fix it before tl-2018, which would
> probably hit our ports tree end of 2018 or early 2019.
> 
> Either texlive suffers from the outdated bundled poppler, or all
> other ports suffer from the outdated poppler in our tree.

I think your diff is the way to go.  No need for a full bulk, I think:

  sqlite> select * from depends where dependspath like '%texlive%' and type = 
'L';
  graphics/evince|print/texlive/base|||print/texlive/base|L
  textproc/p5-LaTeXML|print/texlive/base|||print/texlive/base|L

The LIB_DEPENDS in textproc/p5-LaTeXML looks bogus, and
graphics/evince seems unaffected by your texlive-base change:

  russell /usr/ports/graphics/evince$ make port-lib-depends-check
  evince-3.26.0(graphics/evince):
  Extra:  gnome-autoar-0.0

  (Looks unrelated to texlive/poppler.)

Please see below,

> Ciao,
>   Kili
> 
> Index: Makefile
> ===
> RCS file: /cvs/ports/print/texlive/base/Makefile,v
> retrieving revision 1.94
> diff -u -p -r1.94 Makefile
> --- Makefile  23 Oct 2017 17:11:02 -  1.94
> +++ Makefile  21 Dec 2017 22:19:08 -
> @@ -6,7 +6,7 @@ COMMENT = base binaries for TeXLive typ
>  DISTNAME =   texlive-${DIST_V}b-source
>  PKGNAME =texlive_base-${V}
>  WRKDIST =${WRKDIR}/texlive-${DIST_V}-source
> -REVISION =   4
> +REVISION =   5
>  
>  DISTFILES =  ${DISTNAME}${EXTRACT_SUFX} \
>   texlive-${DIST_V}-extra${EXTRACT_SUFX}
> @@ -19,7 +19,7 @@ SHARED_LIBS +=  texlua520.0 # 7.4
>  WANTLIB += ICE SM X11 Xau Xaw Xdmcp Xext Xi Xmu Xpm Xrender Xt
>  WANTLIB += c cairo expat fontconfig freetype gd glib-2.0 graphite2
>  WANTLIB += harfbuzz harfbuzz-icu iconv icudata icui18n icuio icuuc intl
> -WANTLIB += jpeg lcms2 m openjp2 paper pcre pixman-1 png poppler
> +WANTLIB += jpeg m paper pcre pixman-1 png
>  WANTLIB += potrace pthread ${COMPILER_LIBCXX} tiff webp xcb
>  WANTLIB += xcb-render xcb-shm z zzip
>  WANTLIB += ${LIBCXX}
> @@ -35,7 +35,6 @@ RUN_DEPENDS =   print/ghostscript/gnu \
>  LIB_DEPENDS =converters/libiconv \
>   graphics/png \
>   graphics/gd \
> - print/poppler \
>   graphics/cairo \
>   textproc/icu4c \
>   graphics/graphite2 \
> @@ -46,15 +45,11 @@ LIB_DEPENDS = converters/libiconv \
>  
>  MODULES =textproc/intltool perl
>  
> -# c++-11 required for poppler
> -COMPILER =   base-clang ports-gcc
> -
>  # Never set SEPARATE_BUILD
>  CONFIGURE_STYLE =gnu
>  
>  CPPFLAGS =   -I${X11BASE}/include \
> - -I${LOCALBASE}/include \
> - -I${LOCALBASE}/include/poppler
> + -I${LOCALBASE}/include
>  
>  CXXFLAGS +=  -std=c++11

ok jca@ if you also remove this line.  -std=c++11 will break the build
with g++ from base, and shouldn't be needed given the older poppler
bundled sources.  I have verified that without this line texlive-base
builds fine with g++ from base - on amd64.

>  
> @@ -112,12 +107,10 @@ CONFIGURE_ARGS +=   --mandir=${PREFIX}/man
>   --with-banner-add="-OpenBSD_Ports" \
>   --disable-luajittex \
>   --disable-mfluajit \
> - --with-system-xpdf \
>   --with-system-icu \
>   --with-system-cairo \
>   --with-system-harfbuzz \
>   --with-system-graphite2 \
> - --with-system-poppler \
>   --with-system-libpaper \
>   --with-system-zziplib \
>   --with-system-potrace
> 



Re: print/texlive/base: use bundled poppler for now

2017-12-24 Thread Matthias Kilian
On Thu, Dec 21, 2017 at 11:44:23PM +0100, Matthias Kilian wrote:
> tl;dr: scroll down, apply the patch, run a bulk build, send ok's

Ping. There will be no update of print/poppler without this. I'm
trying to update poppler since more than 9 months now, fixed a
couple ports in advance, and the last piece that's in the way is
texlive.  Nobody will debug it until a poppler update is in the
tree, and upstream probably won't fix it before tl-2018, which would
probably hit our ports tree end of 2018 or early 2019.

Either texlive suffers from the outdated bundled poppler, or all
other ports suffer from the outdated poppler in our tree.

Ciao,
Kili

Index: Makefile
===
RCS file: /cvs/ports/print/texlive/base/Makefile,v
retrieving revision 1.94
diff -u -p -r1.94 Makefile
--- Makefile23 Oct 2017 17:11:02 -  1.94
+++ Makefile21 Dec 2017 22:19:08 -
@@ -6,7 +6,7 @@ COMMENT =   base binaries for TeXLive typ
 DISTNAME = texlive-${DIST_V}b-source
 PKGNAME =  texlive_base-${V}
 WRKDIST =  ${WRKDIR}/texlive-${DIST_V}-source
-REVISION = 4
+REVISION = 5
 
 DISTFILES =${DISTNAME}${EXTRACT_SUFX} \
texlive-${DIST_V}-extra${EXTRACT_SUFX}
@@ -19,7 +19,7 @@ SHARED_LIBS +=texlua520.0 # 7.4
 WANTLIB += ICE SM X11 Xau Xaw Xdmcp Xext Xi Xmu Xpm Xrender Xt
 WANTLIB += c cairo expat fontconfig freetype gd glib-2.0 graphite2
 WANTLIB += harfbuzz harfbuzz-icu iconv icudata icui18n icuio icuuc intl
-WANTLIB += jpeg lcms2 m openjp2 paper pcre pixman-1 png poppler
+WANTLIB += jpeg m paper pcre pixman-1 png
 WANTLIB += potrace pthread ${COMPILER_LIBCXX} tiff webp xcb
 WANTLIB += xcb-render xcb-shm z zzip
 WANTLIB += ${LIBCXX}
@@ -35,7 +35,6 @@ RUN_DEPENDS = print/ghostscript/gnu \
 LIB_DEPENDS =  converters/libiconv \
graphics/png \
graphics/gd \
-   print/poppler \
graphics/cairo \
textproc/icu4c \
graphics/graphite2 \
@@ -46,15 +45,11 @@ LIB_DEPENDS =   converters/libiconv \
 
 MODULES =  textproc/intltool perl
 
-# c++-11 required for poppler
-COMPILER = base-clang ports-gcc
-
 # Never set SEPARATE_BUILD
 CONFIGURE_STYLE =  gnu
 
 CPPFLAGS = -I${X11BASE}/include \
-   -I${LOCALBASE}/include \
-   -I${LOCALBASE}/include/poppler
+   -I${LOCALBASE}/include
 
 CXXFLAGS +=-std=c++11
 
@@ -112,12 +107,10 @@ CONFIGURE_ARGS += --mandir=${PREFIX}/man
--with-banner-add="-OpenBSD_Ports" \
--disable-luajittex \
--disable-mfluajit \
-   --with-system-xpdf \
--with-system-icu \
--with-system-cairo \
--with-system-harfbuzz \
--with-system-graphite2 \
-   --with-system-poppler \
--with-system-libpaper \
--with-system-zziplib \
--with-system-potrace



Re: print/texlive/base: use bundled poppler for now

2017-12-23 Thread Jeremie Courreges-Anglas
On Fri, Dec 22 2017, Martin Schröder  wrote:
> 2017-12-22 0:08 GMT+01:00 Matthias Kilian :
>> And here it is. NOT to be committed, because it breaks pdftex at
>> runtime. (Some use after free or realloc failure, iirc, I don't
>
> Please make sure that patches versions of pdftex and luatex clearly
> identify themselves as such so that mid-/upstream has at least a
> chance to understand bug reports about these versions.

I think it's up to the bug reporter to tell whether they used an
OS-provided package or they compiled from sources, along with platforms
details, etc

If an upstream wants packagers to add distro-specific chatter to
foo --version, then they should provide us with an easy & documented way
to do this.

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: print/texlive/base: use bundled poppler for now

2017-12-22 Thread Matthias Kilian
Hi,

On Fri, Dec 22, 2017 at 12:18:00AM +0100, Martin Schröder wrote:
> 2017-12-22 0:08 GMT+01:00 Matthias Kilian :
> > And here it is. NOT to be committed, because it breaks pdftex at
> > runtime. (Some use after free or realloc failure, iirc, I don't
> 
> Please make sure that patches versions of pdftex and luatex clearly
> identify themselves as such so that mid-/upstream has at least a
> chance to understand bug reports about these versions.

ls /usr/ports/print/texlive/base/patches. Look, it's patched.

When I find a bug, and manage to fix it, I add a patch and leave
it to the maintainer to get it to upstream. I'll *not* start to
fiddle with displayed versions or a special README in that case.

In this special case (luatex and pdftex with new poppler): the
luatex patch is there to make it build with C++-11, so it will be
hopefully obsolete with texlive-2017 (which edd@ is working on).
And the xpdftex patch tries to fix the build  with the new
poppler-internal object API (but breaks at runtime), which upstream
(wherever that is for pdftex) didn't seem to touch yet at all.

So what should I display in a version info or wherever (in case I
manage to fix pdftex correctly for poppler > 0.58)? "Note: this
differs from upstream in that it uses a new version of poppler and
fixes pdftex so that it builds and works with a poppler API which
shouldn't be used at all be pdftex'?

No, I'll not start doing things like this. Instead I'm waiting for
oks for the other diff (let texlive use the bundled poppler which
is even more rotten like our current poppler, and which will also
be rotten after the update to texlive-2017).

Ciao,
Kili



Re: print/texlive/base: use bundled poppler for now

2017-12-21 Thread Martin Schröder
2017-12-22 0:08 GMT+01:00 Matthias Kilian :
> And here it is. NOT to be committed, because it breaks pdftex at
> runtime. (Some use after free or realloc failure, iirc, I don't

Please make sure that patches versions of pdftex and luatex clearly
identify themselves as such so that mid-/upstream has at least a
chance to understand bug reports about these versions.

Best
Martin



Re: print/texlive/base: use bundled poppler for now

2017-12-21 Thread Matthias Kilian
On Thu, Dec 21, 2017 at 11:44:23PM +0100, Matthias Kilian wrote:
> I hope that this diff, making it possible to update print/poppler,
> will make it easier to look what's wrong with pdftex, and I'll also
> send a send a separate mail with the above mentioned patches for
> building print/texlive/base with a newer poppler).

And here it is. NOT to be committed, because it breaks pdftex at
runtime. (Some use after free or realloc failure, iirc, I don't
want to dig into this any deeper again).

Note: this only builds (but doesn'y work) with a new poppler (>=0.59)
for which I sent an update some weeks ago.

Note 2: you'll need egdb from ports (pkg_add gdb) to debug it.

Note 3: if you google for pdftex and poppler, you'll find some
patches, for exmaple, from archlinux. Similar to the patch below,
but not identical (because archlinux already has a newer texlive).
However you'll also find reports that those patches don't work
(segfaults or error messages) and that users fall back to uninstall
new poppler and run with the rotten one bundled with texlive.

Index: Makefile
===
RCS file: /cvs/ports/print/texlive/base/Makefile,v
retrieving revision 1.94
diff -u -p -r1.94 Makefile
--- Makefile23 Oct 2017 17:11:02 -  1.94
+++ Makefile21 Dec 2017 22:50:38 -
@@ -2,6 +2,8 @@
 
 COMMENT =  base binaries for TeXLive typesetting distribution
 
+DEBUG = -g -O0
+
 # This year they used a different datestamp on the -source tarball.
 DISTNAME = texlive-${DIST_V}b-source
 PKGNAME =  texlive_base-${V}
Index: patches/patch-texk_web2c_luatexdir_image_pdftoepdf_w
===
RCS file: 
/cvs/ports/print/texlive/base/patches/patch-texk_web2c_luatexdir_image_pdftoepdf_w,v
retrieving revision 1.1
diff -u -p -r1.1 patch-texk_web2c_luatexdir_image_pdftoepdf_w
--- patches/patch-texk_web2c_luatexdir_image_pdftoepdf_w15 Oct 2017 
19:07:33 -  1.1
+++ patches/patch-texk_web2c_luatexdir_image_pdftoepdf_w21 Dec 2017 
22:50:38 -
@@ -5,6 +5,7 @@ Let it build with -std=c++11.
 found by sthen@ at
 
https://github.com/termux/termux-packages/blob/master/packages/texlive-bin/c%2B%2B11.patch
 
+Fix build with poppler->=0.58. From archlinux texlive-bin r305861.
 
 Index: texk/web2c/luatexdir/image/pdftoepdf.w
 --- texk/web2c/luatexdir/image/pdftoepdf.w.orig
@@ -23,3 +24,184 @@ Index: texk/web2c/luatexdir/image/pdftoe
 } else {
  switch (fe) {
  case FE_FAIL:
+@@ -224,7 +229,7 @@ PdfDocument *refMemStreamPdfDocument(char *docstream, 
+ free(checksum);
+ }
+ if (pdf_doc->doc == NULL) {
+-docmemstream = new MemStream( docstream,0,streamsize, obj.initNull() 
);
++docmemstream = new MemStream( docstream,0,streamsize, Object(objNull) 
);
+ doc = new PDFDoc(docmemstream); /* takes ownership of docmemstream */
+ pdf_doc->pc++;
+ if (!doc->isOk() || !doc->okToPrint()) {
+@@ -408,9 +413,8 @@ static void copyArray(PDF pdf, PdfDocument * pdf_doc, 
+ Object obj1;
+ pdf_begin_array(pdf);
+ for (i = 0, l = array->getLength(); i < l; ++i) {
+-array->getNF(i, );
++obj1 = array->getNF(i);
+ copyObject(pdf, pdf_doc, );
+-obj1.free();
+ }
+ pdf_end_array(pdf);
+ }
+@@ -422,9 +426,8 @@ static void copyDict(PDF pdf, PdfDocument * pdf_doc, D
+ pdf_begin_dict(pdf);
+ for (i = 0, l = dict->getLength(); i < l; ++i) {
+ copyName(pdf, dict->getKey(i));
+-dict->getValNF(i, );
++obj1 = dict->getValNF(i);
+ copyObject(pdf, pdf_doc, );
+-obj1.free();
+ }
+ pdf_end_dict(pdf);
+ }
+@@ -510,13 +513,12 @@ static void writeRefs(PDF pdf, PdfDocument * pdf_doc)
+ PDFDoc *doc = pdf_doc->doc;
+ xref = doc->getXRef();
+ for (r = pdf_doc->inObjList; r != NULL;) {
+-xref->fetch(r->ref.num, r->ref.gen, );
++obj1 = xref->fetch(r->ref.num, r->ref.gen);
+ if (obj1.isStream())
+ pdf_begin_obj(pdf, r->num, OBJSTM_NEVER);
+ else
+ pdf_begin_obj(pdf, r->num, 2);
+ copyObject(pdf, pdf_doc, );
+-obj1.free();
+ pdf_end_obj(pdf);
+ n = r->next;
+ delete r;
+@@ -736,7 +738,7 @@ void write_epdf(PDF pdf, image_dict * idict, int suppr
+ catalog = doc->getCatalog();
+ page = catalog->getPage(img_pagenum(idict));
+ pageref = catalog->getPageRef(img_pagenum(idict));
+-doc->getXRef()->fetch(pageref->num, pageref->gen, );
++pageobj = doc->getXRef()->fetch(pageref->num, pageref->gen);
+ pageDict = pageobj.getDict();
+ /* write the Page header */
+ pdf_begin_obj(pdf, img_objnum(idict), OBJSTM_NEVER);
+@@ -753,12 +755,11 @@ void write_epdf(PDF pdf, image_dict * idict, int suppr
+ pdf_dict_add_int(pdf, "PTEX.PageNumber", (int) img_pagenum(idict));
+ }
+ if ((suppress_optional_info & 8)