Closed yurivict closed 2 years ago
For some reason the relative imports fail. They could simply be replaced by absolute ones and the tests should work. It is still strange that this fails because the test module is a submodule of clingo.
What is more worrisome are the messages of form:
__cxa_thread_call_dtors: dtr <address> from unloaded dso, skipping
This means some memory might be leaked. I am not sure, I can do anything about it.
I found this discussion that seems related: https://www.spinics.net/lists/ceph-devel/msg42456.html.
I also found the following:
This is the backing feature to implement C++11 thread storage duration
specified by the thread_local keyword. A destructor for given
thread-local object is registered to be executed at the thread
termination time using __cxa_thread_atexit(). Libc calls the
__cxa_thread_calls_dtors() during exit(3), before finalizers and
atexit functions, and libthr calls the function at the thread
termination time, after the stack unwinding and thread-specific key
destruction.
There are several uncertainties in the API which lacks a formal
specification. Among them:
- is it allowed to register destructors during destructing;
we allow, but limiting the nesting level. If too many iterations
detected, a diagnostic is issued to stderr and thread forcibly
terminates for now.
- how to handle destructors which belong to an unloading dso;
for now, we ignore destructor calls for such entries, and
issue a diagnostic. Linux does prevent dso unload until all
threads with destructors from the dso terminated.
It is supposed that the diagnostics allow to detect real-world
applications relying on the above details and possibly adjust
our implementation. Right now the choices were to provide the slim
API (but that rarely stands the practice test).
Tests are added to check generic functionality and to specify some of
the above implementation choices.
So this is something that should be addressed in BSDs libc implementation.
I just saw that you are calling python -m unittest
directly from the tests directory. It is not intended to be used like this. It should be called from the libpyclingo
directory. Otherwise, imports won't work.
Using ctest
, the tests are called like this:
Test command: /usr/bin/python3.8 "-m" "unittest"
Environment variables:
PYTHONPATH=<MODPATH>
Test timeout computed to be: 10000000
................................................................
----------------------------------------------------------------------
Ran 64 tests in 1.252s
OK
Note that the PYTHONPATH
is set to the location where the _clingo.*.so
python module is located.
Adding the invalid label. I think everything is fine with clingo.
It should be called from the libpyclingo directory.
It fails to find the 'clingo' module because libpyclingo has the subdirectory clingo which python picks up:
===> Testing for py39-clingo-5.6.0
===> py39-clingo-5.6.0 depends on file: /usr/local/bin/python3.9 - found
cd /disk-samsung/freebsd-ports/math/py-clingo/work-py39/clingo-5.6.0/libpyclingo && /usr/bin/env XDG_DATA_HOME=/disk-samsung/freebsd-ports/math/py-clingo/work-py39 XDG_CONFIG_HOME=/disk-samsung/freebsd-ports/math/py-clingo/work-py39 XDG_CACHE_HOME=/disk-samsung/freebsd-ports/math/py-clingo/work-py39/.cache HOME=/disk-samsung/freebsd-ports/math/py-clingo/work-py39 PATH=/usr/local/libexec/ccache:/disk-samsung/freebsd-ports/math/py-clingo/work-py39/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin PKG_CONFIG_LIBDIR=/disk-samsung/freebsd-ports/math/py-clingo/work-py39/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig NO_PIE=yes MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES LDSHARED="cc -shared" PYTHONDONTWRITEBYTECODE= PYTHONOPTIMIZE= PREFIX=/usr/local LOCALBASE=/usr/local CC="cc" CFLAGS="-O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing " CPP="cpp" CPPFLAGS="-fno-omit-frame-pointer" LDFLAGS=" -fstack-protector-strong " LIBS="" CXX="c++" CXXFLAGS="-O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer " MANPREFIX="/usr/local" CCACHE_DIR="/tmp/.ccache" BSD_INSTALL_PROGRAM="install -s -m 555" BSD_INSTALL_LIB="install -s -m 0644" BSD_INSTALL_SCRIPT="install -m 555" BSD_INSTALL_DATA="install -m 0644" BSD_INSTALL_MAN="install -m 444" PYTHONPATH=/disk-samsung/freebsd-ports/math/py-clingo/work-py39/stage/usr/local/lib/python3.9/site-packages /usr/local/bin/python3.9 -m unittest -v
clingo (unittest.loader._FailedTest) ... ERROR
======================================================================
ERROR: clingo (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: clingo
Traceback (most recent call last):
File "/disk-samsung/freebsd-ports/math/py-clingo/work-py39/clingo-5.6.0/libpyclingo/clingo/_internal.py", line 18, in <module>
from _clingo import ffi as _ffi, lib as _lib # type: ignore # pylint: disable=no-name-in-module
ModuleNotFoundError: No module named '_clingo'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/unittest/loader.py", line 470, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/local/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/disk-samsung/freebsd-ports/math/py-clingo/work-py39/clingo-5.6.0/libpyclingo/clingo/__init__.py", line 100, in <module>
from .core import *
File "/disk-samsung/freebsd-ports/math/py-clingo/work-py39/clingo-5.6.0/libpyclingo/clingo/core.py", line 8, in <module>
from ._internal import _cb_error_panic, _ffi, _lib, _to_str
File "/disk-samsung/freebsd-ports/math/py-clingo/work-py39/clingo-5.6.0/libpyclingo/clingo/_internal.py", line 20, in <module>
from ._clingo import ffi as _ffi, lib as _lib # type: ignore # pylint: disable=no-name-in-module
ModuleNotFoundError: No module named 'clingo._clingo'
----------------------------------------------------------------------
Ran 1 test in 0.000s
It fails to find the 'clingo' module because libpyclingo has the subdirectory clingo which python picks up:
Like I said, you have to point the PYTHONPATH to the C module. The test
target takes care of this. You can just run
cmake --build <BUILDDIR> --target test
Ok, thank you for your help. It works fine now.
Version: 5.6.0 Python-3.9 clang-14 FreeBSD 13.1