I think I have found the bug. pose incorporates an ancient version of
gzip, which includes an `inflate' function. But the font libraries which
pose get linked with also call `inflate', expecting the modern zlib
implementation (which is incompatible). The old version gets called
instead; it has an entirely different interface involving global variables
which needed to be initialized. They aren't, so pose crashes.
To fix this, I ripped out the old gzip code and replaced it with calls to
zlib. A patch is attached. It touches Makefile.am and configure.in, so
you'll have to re-run automake/autoconf after applying. If it's not clear
from the patch, you can also blow away BuildUnix/Gzip and SrcShared/Gzip.
--
Nate Eldredge
[EMAIL PROTECTED]
Only in pose-3.5-old/BuildUnix: Gzip
diff -ru pose-3.5-old/BuildUnix/Makefile.am pose-3.5/BuildUnix/Makefile.am
--- pose-3.5-old/BuildUnix/Makefile.am 2005-05-25 17:11:48.000000000 -0700
+++ pose-3.5/BuildUnix/Makefile.am 2005-05-25 15:59:16.000000000 -0700
@@ -4,7 +4,7 @@
## All rights reserved.
##
======================================================================================
-SUBDIRS = Gzip jpeg espws-2.0
+SUBDIRS = jpeg espws-2.0
AUTOMAKE_OPTIONS = foreign
SUFFIXES = .cpp
@@ -38,7 +38,6 @@
INCLUDES +=
-I$(srcdir)/../SrcShared/Palm/Platform/Incs/Core/System
INCLUDES +=
-I$(srcdir)/../SrcShared/Palm/Platform/Incs/Core/UI
INCLUDES +=
-I$(srcdir)/../SrcShared/Palm/Platform/Incs/Libraries
-INCLUDES += -I$(srcdir)/../SrcShared/Gzip
INCLUDES += -I$(srcdir)/../SrcShared/jpeg
INCLUDES += -I$(srcdir)/../SrcShared/omnithread
INCLUDES += -I$(srcdir)/../SrcShared/Patches
@@ -404,7 +403,7 @@
bin_PROGRAMS = pose
-pose_LDADD = Gzip/libposergzip.a
+pose_LDADD = -lz
pose_LDADD += jpeg/libposerjpeg.a
pose_LDADD += espws-2.0/libposerespws.a
pose_LDADD += -lfltk
Only in pose-3.5/BuildUnix: Makefile.am.rej
diff -ru pose-3.5-old/BuildUnix/configure.in pose-3.5/BuildUnix/configure.in
--- pose-3.5-old/BuildUnix/configure.in 2005-05-25 17:11:48.000000000 -0700
+++ pose-3.5/BuildUnix/configure.in 2005-05-25 15:59:16.000000000 -0700
@@ -10,7 +10,6 @@
AC_INIT(../SrcUnix/Platform_Unix.cpp)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(pose, 0, no)
-AC_CONFIG_SRCDIR([configure.in])
AC_PROG_MAKE_SET
AC_PROG_CC
@@ -175,7 +174,7 @@
_WARNINGS_CFLAGS='-w'
_WARNINGS_CXXFLAGS='-w'
LIBS="$LIBS -lsocket"
- poser_optimize="-O2 -fno-strict-aliasing"
+ poser_optimize="-O2"
poser_debug="-gdwarf-2"
AR='/usr/local/bin/ar.elf'
;;
@@ -267,10 +266,10 @@
dnl
dnl AC_ARG_ENABLE(optimize,
dnl [ --enable-optimize optimize code (default no)],
-dnl FLAGS_OPTIMIZE="-O2 -fno-strict-aliasing",
+dnl FLAGS_OPTIMIZE="-O2",
dnl FLAGS_OPTIMIZE="")
-FLAGS_OPTIMIZE="-O2 -fno-strict-aliasing"
+FLAGS_OPTIMIZE="-O2"
dnl ========================================================
@@ -392,4 +391,4 @@
AM_CONDITIONAL(SOLARIS, test x$USE_SOLARIS_CPP = xtrue)
-AC_OUTPUT(Makefile Gzip/Makefile jpeg/Makefile espws-2.0/Makefile)
+AC_OUTPUT(Makefile jpeg/Makefile espws-2.0/Makefile)
Only in pose-3.5/BuildUnix: configure.in.rej
Only in pose-3.5/BuildUnix: configure.rej
Only in pose-3.5/BuildUnix: mkinstalldirs.rej
Only in pose-3.5: ID
Only in pose-3.5-old/SrcShared: Gzip
diff -ru pose-3.5-old/SrcShared/Miscellaneous.cpp
pose-3.5/SrcShared/Miscellaneous.cpp
--- pose-3.5-old/SrcShared/Miscellaneous.cpp 2002-03-29 05:11:15.000000000
-0800
+++ pose-3.5/SrcShared/Miscellaneous.cpp 2005-05-25 16:32:20.000000000
-0700
@@ -37,78 +37,7 @@
#include <strstream> // strstream
#include <time.h> // time, localtime
-
-extern "C" {
- // These are defined in machdep_maccess.h, too
-#undef get_byte
-#undef put_byte
-#undef put_long
-#include "gzip.h"
-#include "lzw.h"
-
-int (*write_buf_proc)(char *buf, unsigned size);
-
-DECLARE(uch, inbuf, INBUFSIZ +INBUF_EXTRA);
-DECLARE(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
-DECLARE(ush, d_buf, DIST_BUFSIZE);
-DECLARE(uch, window, 2L*WSIZE);
-DECLARE(ush, tab_prefix, 1L<<BITS);
-
-int test = 0; /* test .gz file integrity */
-int level = 1; /* compression level */
-int exit_code = OK; /* program exit code */
-int verbose = 2; /* be verbose (-v) */
-int quiet = 0; /* be quiet (-q) */
-
-char ifname[] = "ifname";
-char ofname[] = "ofname";
-char* progname = "progname";
-
-long bytes_in; /* number of input bytes */
-long bytes_out; /* number of output bytes */
-int ifd; /* input file descriptor */
-int ofd; /* output file descriptor */
-unsigned insize; /* valid bytes in inbuf */
-unsigned inptr; /* index of next byte to be processed in
inbuf */
-unsigned outcnt; /* bytes in output buffer */
-
-#include <setjmp.h>
-jmp_buf env;
-
-RETSIGTYPE abort_gzip()
-{
- LogDump ();
- abort ();
-// longjmp (env, 1);
-}
-
-int my_fprintf (FILE*, const char* fmt, ...)
-{
- int n;
- va_list arg;
-
- va_start (arg, fmt);
- n = LogGetStdLog ()->VPrintf (fmt, arg);
- va_end (arg);
-
- return n;
-}
-
-} // extern "C"
-
-
-extern "C"
-{
- int PrvGzipReadProc (char* buf, unsigned size);
- int PrvGzipWriteProc (char* buf, unsigned size);
-}
-
-static void* gSrcP;
-static void* gDstP;
-static long gSrcBytes;
-static long gDstBytes;
-static long gSrcOffset;
-static long gDstOffset;
+#include <zlib.h>
// ===========================================================================
// ¥ StMemory Class
@@ -1710,7 +1639,7 @@
* DESCRIPTION: .
*
* PARAMETERS: srcPP - pointer to the pointer to the source bytes. The
- * referenced pointer gets udpated to
point past the
+ * referenced pointer gets updated to
point past the
* last byte included the packed output.
*
* dstPP - pointer to the pointer to the
destination buffer.
@@ -1725,41 +1654,17 @@
void GzipEncode (void** srcPP, void** dstPP, long srcBytes, long dstBytes)
{
- gSrcP = *srcPP;
- gDstP = *dstPP;
- gSrcBytes = srcBytes;
- gDstBytes = dstBytes;
- gSrcOffset = 0;
- gDstOffset = 0;
-
- bytes_in = srcBytes; // (for gzip internal debugging)
-
- ush attr = 0; /* ascii/binary flag */
- ush deflate_flags = 0; /* pkzip -es, -en or -ex equivalent */
- int method;
-
- clear_bufs ();
-
- read_buf = &::PrvGzipReadProc;
- write_buf_proc = &::PrvGzipWriteProc;
-
- bi_init (NO_FILE);
- ct_init (&attr, &method);
- lm_init (level, &deflate_flags);
-
- deflate ();
-
- // Perform a put_byte(0) to pad out the
- // compressed buffer. gzip apparently can skid off the
- // end of the compressed data when inflating it, so we need
- // an extra zero.
-
- put_byte (0);
-
- flush_outbuf ();
-
- *srcPP = ((char*) gSrcP) + gSrcOffset;
- *dstPP = ((char*) gDstP) + gDstOffset;
+ // We only allow the entire buffer to be compressed at once.
+ // That's the only way this gets used. If you don't do that, this
+ // function will report that nothing was compressed.
+ Bytef* srcP = (Bytef*) *srcPP;
+ Bytef* dstP = (Bytef*) *dstPP;
+ uLongf mydstBytes = dstBytes;
+ if (compress(dstP, &mydstBytes, srcP, srcBytes) == Z_OK)
+ {
+ *srcPP = srcP + srcBytes;
+ *dstPP = dstP + mydstBytes;
+ }
}
@@ -1781,22 +1686,17 @@
void GzipDecode (void** srcPP, void** dstPP, long srcBytes, long dstBytes)
{
- gSrcP = *srcPP;
- gDstP = *dstPP;
- gSrcBytes = srcBytes;
- gDstBytes = dstBytes;
- gSrcOffset = 0;
- gDstOffset = 0;
-
- clear_bufs ();
-
- read_buf = &::PrvGzipReadProc;
- write_buf_proc = &::PrvGzipWriteProc;
-
- inflate ();
-
- *srcPP = ((char*) gSrcP) + gSrcOffset;
- *dstPP = ((char*) gDstP) + gDstOffset;
+ // We only allow the entire buffer to be decompressed at once.
+ // That's the only way this gets used. If you don't do that, this
+ // function will report that nothing was decompressed.
+ Bytef* srcP = (Bytef*) *srcPP;
+ Bytef* dstP = (Bytef*) *dstPP;
+ uLongf mydstBytes = dstBytes;
+ if (uncompress(dstP, &mydstBytes, srcP, srcBytes) == Z_OK)
+ {
+ *srcPP = srcP + srcBytes;
+ *dstPP = dstP + mydstBytes;
+ }
}
@@ -1814,69 +1714,12 @@
long GzipWorstSize (long srcBytes)
{
- long maxDestBytes = srcBytes * 2;
-
- return maxDestBytes;
-}
-
-
-/***********************************************************************
- *
- * FUNCTION: PrvGzipReadProc
- *
- * DESCRIPTION: .
- *
- * PARAMETERS: .
- *
- * RETURNED: .
- *
- ***********************************************************************/
-
-int PrvGzipReadProc (char* buf, unsigned size)
-{
- if (gSrcOffset == gSrcBytes)
- return EOF;
-
- if (size > (unsigned) (gSrcBytes - gSrcOffset))
- size = gSrcBytes - gSrcOffset;
-
- if (size > 0)
- {
- memcpy (buf, ((char*) gSrcP) + gSrcOffset, size);
- gSrcOffset += size;
- }
-
- return size;
-}
-
-
-/***********************************************************************
- *
- * FUNCTION: PrvGzipWriteProc
- *
- * DESCRIPTION: .
- *
- * PARAMETERS: .
- *
- * RETURNED: .
- *
- ***********************************************************************/
-
-int PrvGzipWriteProc (char* buf, unsigned size)
-{
- if (gDstOffset == gDstBytes)
- return EOF;
-
- if (size > (unsigned) (gDstBytes - gDstOffset))
- size = gDstBytes - gDstOffset;
-
- if (size > 0)
- {
- memcpy (((char*) gDstP) + gDstOffset, buf, size);
- gDstOffset += size;
- }
-
- return size;
+ // "the destination buffer... must be at least 0.1% larger than
+ // sourceLen plus 12 bytes." --zlib manual
+
+ // We'll make it a generous 1% larger.
+ srcBytes += 12;
+ return (srcBytes + (srcBytes / 100));
}
Only in pose-3.5: _build
diff -ru pose-3.5-old/debian/control pose-3.5/debian/control
--- pose-3.5-old/debian/control 2005-05-25 17:10:13.000000000 -0700
+++ pose-3.5/debian/control 2005-05-25 15:52:06.000000000 -0700
@@ -3,7 +3,7 @@
Priority: optional
Maintainer: Lucas Wall <[EMAIL PROTECTED]>
Standards-Version: 3.6.1
-Build-Depends: debhelper (>= 4.0.0), autotools-dev, dpatch, libfltk-dev,
fluid, xlibs-dev (>= 4.2)
+Build-Depends: debhelper (>= 4.0.0), autotools-dev, dpatch, libfltk-dev,
fluid, xlibs-dev (>= 4.2), libz-dev
Package: pose
Architecture: any
Only in pose-3.5/debian/patches: BuildUnix