freebsd-ports/graphics/jasper/files/patch-atexit
Mikhail Teterin 9c8a79bceb 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.
2007-08-05 22:14:08 +00:00

31 lines
1,002 B
Text

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;