Add a patch, which disables a call to atexit() to register libjasper's

own clean-up routine (jas_cleanup). The call would be of limited
use anyway, as freeing memory at exit is useful only for tracking
down memory leaks. Removing the atexit call eliminates crashes in
ImageMagick and GraphicsMagick, when they are compiled with modules
support -- when a library is dlclosed, calling its cleanup routine is
certain death...

When compiling with gcc, declare the routine with ``__attribute__
(destructor)'' as per kan's otherwise obnoxious and inflammatory
e-mails. This will make sure, the routine is invoked, when libjasper
is dlclosed(). The only known apps that do that are ImageMagick and
GraphicsMagick (when built with modules support). They both call
the routine explicitly anyway...

While here enable parallel build of jasper itself, and eliminate the
most threatening warnings.

Bump PORTREVISION.
This commit is contained in:
Mikhail Teterin 2007-08-05 22:14:08 +00:00
parent bb297fd6d1
commit 9c8a79bceb
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=197182
2 changed files with 33 additions and 1 deletions

View file

@ -7,7 +7,7 @@
PORTNAME= jasper
PORTVERSION= 1.900.1
PORTREVISION= 5
PORTREVISION= 6
CATEGORIES= graphics
MASTER_SITES= http://www.ece.uvic.ca/~mdadams/jasper/software/ \
${MASTER_SITE_IMAGEMAGICK}
@ -18,6 +18,7 @@ COMMENT= An implementation of the codec specified in the JPEG-2000 standard
LIB_DEPENDS= jpeg:${PORTSDIR}/graphics/jpeg
MAKE_ARGS+= -j`${SYSCTL} -n hw.ncpu`
USE_AUTOTOOLS= libtool:15
USE_ZIP= yes
USE_GNOME= gnometarget lthack

View file

@ -0,0 +1,31 @@
When compiling with gcc don't register jas_cleanup with atexit.
Instead, mark it as a destructor using a gcc-only extension.
This will avoid crashes, when an application, which has explicitly
dlclosed() libjasper, exits.
If a similar method exists for other compilers, it should be used
too. Or, maybe, something can be done with __cxa_atexit() here...
-mi
--- src/libjasper/include/jasper/jas_init.h 2007-01-19 16:43:04.000000000 -0500
+++ src/libjasper/include/jasper/jas_init.h 2007-08-05 11:42:41.000000000 -0400
@@ -75,5 +75,9 @@
int jas_init(void);
+#ifdef __GNUC__
+void jas_cleanup(void) __attribute__ ((destructor));
+#else
void jas_cleanup(void);
+#endif
#ifdef __cplusplus
--- src/libjasper/base/jas_init.c 2007-01-19 16:43:05.000000000 -0500
+++ src/libjasper/base/jas_init.c 2007-08-05 11:44:00.000000000 -0400
@@ -152,5 +152,4 @@
as it ensures that the JasPer exit handler is called before the
debug memory allocator exit handler. */
- atexit(jas_cleanup);
return 0;