Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

OpenBSD: tests fail: "Magick: Failed to close module" #108

Open
jwilk opened this issue Aug 20, 2015 · 11 comments
Open

OpenBSD: tests fail: "Magick: Failed to close module" #108

jwilk opened this issue Aug 20, 2015 · 11 comments
Labels

Comments

@jwilk
Copy link
Member

jwilk commented Aug 20, 2015

Issue reported by @juanfra684:

===>  Regression tests for pdf2djvu-0.8.1
gmake -C tests/
gmake[1]: Entering directory '/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests'
nosetests -v
test-1px-font.test.test ... ok
test-antialias-off.test.test ... ok
test-antialias-on.test.test ... ok
test-crop-text.test.test_crop ... ok
test-crop-text.test.test_no_crop ... ok
test-dpi-detection.test.test ... ok
test-duplicate-pages.test.test_bundled ... ok
test-duplicate-pages.test.test_indirect ... ok
test-empty-outline.test.test ... ok
test-fg-colors-gm.test.test(1, 2) ... FAIL
test-fg-colors-gm.test.test(2, 3) ... FAIL
test-fg-colors-gm.test.test(4, 5) ... FAIL
test-fg-colors-gm.test.test(255, 241) ... FAIL
test-fg-colors-gm.test.test(256, (245, 256)) ... FAIL
test-fg-colors-gm.test.test(652, (245, 325)) ... FAIL
test-fg-colors.test.test('default', 325) ... ok
test-fg-colors.test.test('web', 43) ... ok
test-fg-colors.test.test('black', 2) ... ok
test-hyperlinks.test.test ... ok
test-interpolation.test.test ... SKIP: https://bugs.freedesktop.org/show_bug.cgi?id=68360
test-monochrome.test.test ... ok
test-multipage.test.test ... ok
test-nfkc-apf.test.test_nfkc ... ok
test-nfkc-apf.test.test_no_nfkc ... ok
test-nfkc.test.test_nfkc ... ok
test-nfkc.test.test_no_nfkc ... ok
test-no-meta.test.test ... ok
test-outline.test.test_multi_page ... ok
test-outline.test.test_single_page ... ok
test-overwrite.test.test_overwrite ... ok
test-rotated-page.test.test ... ok
test-solid-nonwhite-background.test.test ... ok
test-subsample.test.test_11 ... ok
test-subsample.test.test_12 ... ok
test-utf16-meta.test.test ... ok
test-xmp-broken.test.test_no_verbatim ... ok
test-xmp-broken.test.test_verbatim ... ok
test-xmp-mediatype.test.test_no_verbatim ... ok
test-xmp-mediatype.test.test_verbatim ... ok
test-xmp-recreate.test.test_no_verbatim ... ok
test-xmp-recreate.test.test_verbatim ... ok

======================================================================
FAIL: test-fg-colors-gm.test.test(1, 2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module (": Invalid handle").\n' != ''
- Magick: Failed to close module (": Invalid handle").


======================================================================
FAIL: test-fg-colors-gm.test.test(2, 3)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module (": Invalid handle").\n' != ''
- Magick: Failed to close module (": Invalid handle").


======================================================================
FAIL: test-fg-colors-gm.test.test(4, 5)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module (": Invalid handle").\n' != ''
- Magick: Failed to close module (": Invalid handle").


======================================================================
FAIL: test-fg-colors-gm.test.test(255, 241)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module (": Invalid handle").\n' != ''
- Magick: Failed to close module (": Invalid handle").


======================================================================
FAIL: test-fg-colors-gm.test.test(256, (245, 256))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module (": Invalid handle").\n' != ''
- Magick: Failed to close module (": Invalid handle").


======================================================================
FAIL: test-fg-colors-gm.test.test(652, (245, 325))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module (": Invalid handle").\n' != ''
- Magick: Failed to close module (": Invalid handle").


----------------------------------------------------------------------
Ran 41 tests in 14.660s

FAILED (SKIP=1, failures=6)

@jwilk
Copy link
Member Author

jwilk commented Aug 21, 2015

Thanks for the bug report.

This smells like a bug in GraphicsMagick.

I will investigate further.

@jwilk
Copy link
Member Author

jwilk commented Aug 21, 2015

The error message Magick: Failed to close module (": Invalid handle") comes from GraphicsMagick's function UnloadModule.

There's certainly a bug in UnloadModule that makes the message unhelpful:
https://sourceforge.net/p/graphicsmagick/bugs/312/

But I don't know why this error crops up in the first place. It doesn't show up here (on Linux).

I suspect it's a bug in GraphicsMagick itself, because pdf2djvu doesn't load or unload any modules explicitly.

@jwilk
Copy link
Member Author

jwilk commented Aug 22, 2015

Do you get this error with other programs linking to GraphicsMagick?

Could you try applying the attached patch (cherry-picked from GM's hg repo)? It might make the error message more helpful.


diff --git a/magick/module.c b/magick/module.c
--- a/magick/module.c
+++ b/magick/module.c
@@ -2168,8 +2170,7 @@
 UnloadModule(const CoderInfo *coder_info,ExceptionInfo *exception)
 {
   char
-    message[MaxTextExtent],
-    name[MaxTextExtent];
+    message[MaxTextExtent];
 
   unsigned int
     status=True;
@@ -2193,7 +2194,8 @@
     {
       if (lt_dlclose((ModuleHandle) coder_info->handle))
         {
-          FormatString(message,"\"%.1024s: %.1024s\"",name,lt_dlerror());
+          FormatString(message,"\"%.1024s: %.1024s\"",coder_info->tag,
+                       lt_dlerror());
           ThrowException(exception,ModuleError,FailedToCloseModule,message);
           status=False;
         }

@jwilk
Copy link
Member Author

jwilk commented Aug 22, 2015

Comment submitted by @juanfra684:

I'm not aware of similar problems with other software linked to GM, but not every OpenBSD maintainer runs tests against their packages, so I don't have a real answer for that.

Tests with your patch applied:

===>  Regression tests for pdf2djvu-0.8.1
gmake -C tests/
gmake[1]: Entering directory '/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests'
nosetests -v
test-1px-font.test.test ... ok
test-antialias-off.test.test ... ok
test-antialias-on.test.test ... ok
test-crop-text.test.test_crop ... ok
test-crop-text.test.test_no_crop ... ok
test-dpi-detection.test.test ... ok
test-duplicate-pages.test.test_bundled ... ok
test-duplicate-pages.test.test_indirect ... ok
test-empty-outline.test.test ... ok
test-fg-colors-gm.test.test(1, 2) ... FAIL
test-fg-colors-gm.test.test(2, 3) ... FAIL
test-fg-colors-gm.test.test(4, 5) ... FAIL
test-fg-colors-gm.test.test(255, 241) ... FAIL
test-fg-colors-gm.test.test(256, (245, 256)) ... FAIL
test-fg-colors-gm.test.test(652, (245, 325)) ... FAIL
test-fg-colors.test.test('default', 325) ... ok
test-fg-colors.test.test('web', 43) ... ok
test-fg-colors.test.test('black', 2) ... ok
test-hyperlinks.test.test ... ok
test-interpolation.test.test ... SKIP: https://bugs.freedesktop.org/show_bug.cgi?id=68360
test-monochrome.test.test ... ok
test-multipage.test.test ... ok
test-nfkc-apf.test.test_nfkc ... ok
test-nfkc-apf.test.test_no_nfkc ... ok
test-nfkc.test.test_nfkc ... ok
test-nfkc.test.test_no_nfkc ... ok
test-no-meta.test.test ... ok
test-outline.test.test_multi_page ... ok
test-outline.test.test_single_page ... ok
test-overwrite.test.test_overwrite ... ok
test-rotated-page.test.test ... ok
test-solid-nonwhite-background.test.test ... ok
test-subsample.test.test_11 ... ok
test-subsample.test.test_12 ... ok
test-utf16-meta.test.test ... ok
test-xmp-broken.test.test_no_verbatim ... ok
test-xmp-broken.test.test_verbatim ... ok
test-xmp-mediatype.test.test_no_verbatim ... ok
test-xmp-mediatype.test.test_verbatim ... ok
test-xmp-recreate.test.test_no_verbatim ... ok
test-xmp-recreate.test.test_verbatim ... ok

======================================================================
FAIL: test-fg-colors-gm.test.test(1, 2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module ("XC: Invalid handle").\n' != ''
- Magick: Failed to close module ("XC: Invalid handle").


======================================================================
FAIL: test-fg-colors-gm.test.test(2, 3)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module ("XC: Invalid handle").\n' != ''
- Magick: Failed to close module ("XC: Invalid handle").


======================================================================
FAIL: test-fg-colors-gm.test.test(4, 5)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module ("XC: Invalid handle").\n' != ''
- Magick: Failed to close module ("XC: Invalid handle").


======================================================================
FAIL: test-fg-colors-gm.test.test(255, 241)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module ("XC: Invalid handle").\n' != ''
- Magick: Failed to close module ("XC: Invalid handle").


======================================================================
FAIL: test-fg-colors-gm.test.test(256, (245, 256))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module ("XC: Invalid handle").\n' != ''
- Magick: Failed to close module ("XC: Invalid handle").


======================================================================
FAIL: test-fg-colors-gm.test.test(652, (245, 325))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/test-fg-colors-gm.py", line 40, in _test
    '--fg-colors={0}'.format(i)
  File "/usr/write-ports/pobj/pdf2djvu-0.8.1/pdf2djvu-0.8.1/tests/common.py", line 95, in assert_
    assert_multi_line_equal(self.stderr, stderr)
AssertionError: 'Magick: Failed to close module ("XC: Invalid handle").\n' != ''
- Magick: Failed to close module ("XC: Invalid handle").


----------------------------------------------------------------------
Ran 41 tests in 13.589s

FAILED (SKIP=1, failures=6)

@jwilk
Copy link
Member Author

jwilk commented Aug 23, 2015

OK, I reproduced the bug on OpenBSD 5.7.

Still no idea why it happens.

@jwilk
Copy link
Member Author

jwilk commented Aug 23, 2015

Minimal program that triggers the error:

#include <Magick++.h>

int main(int argc, char **argv)
{
        Magick::InitializeMagick("");
        Magick::Image image(Magick::Geometry(23, 37), Magick::Color());
}

@jwilk
Copy link
Member Author

jwilk commented Aug 28, 2015

Work-around to make the tests pass despite the error message on stderr:

diff --git a/tests/common.py b/tests/common.py
--- a/tests/common.py
+++ b/tests/common.py
@@ -133,6 +133,9 @@
             env=env,
         )
         stdout, stderr = child.communicate()
+        if sys.platform.startswith('openbsd'):
+            # FIXME: https://github.com/jwilk/pdf2djvu/issues/108
+            stderr = re(r'Magick: Failed to close module [(]"\w*: Invalid handle\"[)].\n').sub('', stderr)
         stderr = re(r'^(?:  \S+ --> \S+ \(\d+ bytes\)\n)+$').sub('', stderr)  # strip djvuextract cruft
         return ipc_result(stdout, stderr, child.returncode)
 

@jwilk
Copy link
Member Author

jwilk commented Aug 31, 2015

Comment submitted by @juanfra684:

Sorry for the delay and thanks for taking care of the bug.

I will apply your patch to the OpenBSD port. I have a question, the problem doesn't affect to the conversion to djvu, right?.

@jwilk
Copy link
Member Author

jwilk commented Sep 1, 2015

Yes, this bug doesn't affect conversion.

@jwilk
Copy link
Member Author

jwilk commented Sep 28, 2015

I've committed the work-around as 4ce17b3.
It will be part of pdf2djvu 0.9.1, to be released soon.

No progress in figuring out what's the root cause. :-(

@jwilk
Copy link
Member Author

jwilk commented Oct 1, 2015

Comment submitted by @juanfra684:

The tests work fine on Bitrig (a derivative of OpenBSD with a different toolchain). Maybe the problem is in the OpenBSD side.

@jwilk jwilk added the bug label Dec 6, 2016
@jwilk jwilk changed the title pdf2djvu 0.8.1: the tests fail on OpenBSD OpenBSD: tests fail: "Magick: Failed to close module" Dec 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

1 participant