Discussion:
[gs-bugs] [Bug 698353] - MuPDF - NDEBUG in fitz/context.h prevents debug builds of user programs
b***@artifex.com
2017-08-14 08:55:39 UTC
Permalink
http://bugs.ghostscript.com/show_bug.cgi?id=698353

Bug ID: 698353
Summary: NDEBUG in fitz/context.h prevents debug builds of user
programs
Product: MuPDF
Version: master
Hardware: PC
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: P4
Component: fitz
Assignee: mupdf-***@artifex.com
Reporter: ***@yahoo.com
QA Contact: gs-***@ghostscript.com
Word Size: ---

Hi,

The following block of code in fitz/context.h breaks DEBUG builds for programs
that include this header

576 #if defined(MEMENTO) || !defined(NDEBUG)
577 #define FITZ_DEBUG_LOCKING
578 #endif

I should not be obligated to build a debug version of mupdf in order to debug
my own program. Here is error

/usr/local/pobj/k2pdfopt-2.42/k2pdfopt_v2.42/k2pdfoptlib/k2sys.c:120: warning:
\
warning: sprintf() is often misused, please use snprintf()
/usr/local/lib/libglib-2.0.so.4200.5: warning: warning: stpcpy() is dangerous;
do not \
use it willuslib/libwilluslib.a(font.c.o): In function `fz_lock':
/usr/local/include/mupdf/fitz/context.h:596: undefined reference to \
`fz_lock_debug_lock' willuslib/libwilluslib.a(font.c.o): In function
`fz_unlock':
/usr/local/include/mupdf/fitz/context.h:603: undefined reference to \
`fz_lock_debug_unlock' willuslib/libwilluslib.a(font.c.o): In function
`fz_lock':
/usr/local/include/mupdf/fitz/context.h:596: undefined reference to \
`fz_lock_debug_lock' willuslib/libwilluslib.a(font.c.o): In function
`fz_unlock':
/usr/local/include/mupdf/fitz/context.h:603: undefined reference to \
`fz_lock_debug_unlock'
/usr/local/include/mupdf/fitz/context.h:603: undefined reference to \
`fz_lock_debug_unlock'

where fz_lock_debug_lock and fz_lock_debug_unlock are not defined. Could we
remove the !defined(NDEBUG) term and perhaps replace it with something more
sensible like defined(FZ_LOCK_DEBUG)?

Thank you,
Paul Irofti
--
You are receiving this mail because:
You are the QA Contact for the bug.
b***@artifex.com
2017-11-09 15:19:01 UTC
Permalink
http://bugs.ghostscript.com/show_bug.cgi?id=698353

Robin Watts <***@artifex.com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
CC| |***@artifex.com

--- Comment #1 from Robin Watts <***@artifex.com> ---
Fixed in:

commit 258f03a0a55c1aa802e1be47e463d8abc5096196
Author: Robin Watts <***@artifex.com>
Date: Wed Nov 8 19:45:14 2017 +0000

Bug 698353: Avoid having our API depend on DEBUG/NDEBUG.

Currently, our API uses static inlines for fz_lock and
fz_unlock, the definitions for which depend on whether
we build NDEBUG or not. This isn't ideal as it causes
problems when people link a release binary with a debug
lib (or vice versa).

We really want to continue to use static inlines for the
locking functions as used from MuPDF, as we hit them
hard in the keep/drop functions.

We therefore remove fz_lock/fz_unlock from the public API
entirely. Accordingly, we move the fz_lock/fz_unlock
static inlines into fitz-imp.h (an internal header),
together with the fz_keep_.../fz_drop_... functions.

We then have public fz_lock/fz_unlock functions for any
external callers to use that are free of compilications.

At the same time, to avoid another indirection, we change
from holding the locking functions as a pointer to a
struct to a struct itself.
--
You are receiving this mail because:
You are the QA Contact for the bug.
Loading...