Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error #67974

Closed
petriborg mannequin opened this issue Mar 26, 2015 · 19 comments
Closed
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) tests Tests in the Lib/test dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@petriborg
Copy link
Mannequin

petriborg mannequin commented Mar 26, 2015

BPO 23786
Nosy @jcea, @mdickinson, @vstinner, @tiran, @serhiy-storchaka, @iritkatriel
Files
  • fnv_memcpy.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-06-16.20:30:58.658>
    created_at = <Date 2015-03-26.13:47:27.932>
    labels = ['interpreter-core', 'tests', 'type-crash']
    title = 'test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error'
    updated_at = <Date 2021-06-16.20:30:58.657>
    user = 'https://bugs.python.org/petriborg'

    bugs.python.org fields:

    activity = <Date 2021-06-16.20:30:58.657>
    actor = 'petriborg'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-06-16.20:30:58.658>
    closer = 'petriborg'
    components = ['Interpreter Core', 'Tests']
    creation = <Date 2015-03-26.13:47:27.932>
    creator = 'petriborg'
    dependencies = []
    files = ['38709']
    hgrepos = []
    issue_num = 23786
    keywords = ['patch']
    message_count = 19.0
    messages = ['239330', '239347', '239348', '239351', '239352', '239354', '239360', '239384', '239385', '239386', '239387', '239393', '239397', '239399', '239917', '239930', '240033', '395954', '395958']
    nosy_count = 7.0
    nosy_names = ['jcea', 'mark.dickinson', 'vstinner', 'christian.heimes', 'serhiy.storchaka', 'petriborg', 'iritkatriel']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue23786'
    versions = ['Python 3.4', 'Python 3.5']

    @petriborg
    Copy link
    Mannequin Author

    petriborg mannequin commented Mar 26, 2015

    I compiled Python 3.4.3 on Solaris 11, and when I ran the regression test, I get a core dump when the hash() function was being used. I went through the bug database looking for something similar but couldn't find anything.

    Tests like:
    test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error

    Current thread 0x00000001 (most recent call first):
    File "/usr/local/lib/python3.4/test/test_hash.py", line 89 in test_unaligned_buffers
    File "/usr/local/lib/python3.4/unittest/case.py", line 577 in run
    File "/usr/local/lib/python3.4/unittest/case.py", line 625 in __call__
    File "/usr/local/lib/python3.4/unittest/suite.py", line 122 in run
    File "/usr/local/lib/python3.4/unittest/suite.py", line 84 in __call__
    File "/usr/local/lib/python3.4/unittest/suite.py", line 122 in run
    File "/usr/local/lib/python3.4/unittest/suite.py", line 84 in __call__
    File "/usr/local/lib/python3.4/unittest/suite.py", line 122 in run
    File "/usr/local/lib/python3.4/unittest/suite.py", line 84 in __call__
    File "/usr/local/lib/python3.4/unittest/runner.py", line 168 in run
    File "/usr/local/lib/python3.4/test/support/init.py", line 1769 in _run_suite
    File "/usr/local/lib/python3.4/test/support/init.py", line 1803 in run_unittest
    File "/usr/local/lib/python3.4/test/regrtest.py", line 1279 in test_runner
    File "/usr/local/lib/python3.4/test/regrtest.py", line 1280 in runtest_inner
    File "/usr/local/lib/python3.4/test/regrtest.py", line 978 in runtest
    File "/usr/local/lib/python3.4/test/regrtest.py", line 763 in main
    File "/usr/local/lib/python3.4/test/regrtest.py", line 1564 in main_in_temp_cwd
    File "/usr/local/lib/python3.4/test/main.py", line 3 in <module>
    File "/usr/local/lib/python3.4/runpy.py", line 85 in _run_code
    File "/usr/local/lib/python3.4/runpy.py", line 170 in _run_module_as_main
    Bus Error (core dumped)

    and

    test_hash_equality (test.datetimetester.TestTime_Fast) ... Fatal Python error: Bus error

    Current thread 0x00000001 (most recent call first):
    File "/usr/local/lib/python3.4/test/datetimetester.py", line 2155 in test_hash_equality
    File "/usr/local/lib/python3.4/unittest/case.py", line 577 in run
    File "/usr/local/lib/python3.4/unittest/case.py", line 625 in __call__
    File "/usr/local/lib/python3.4/unittest/suite.py", line 122 in run
    File "/usr/local/lib/python3.4/unittest/suite.py", line 84 in __call__
    File "/usr/local/lib/python3.4/unittest/suite.py", line 122 in run
    File "/usr/local/lib/python3.4/unittest/suite.py", line 84 in __call__
    File "/usr/local/lib/python3.4/unittest/runner.py", line 168 in run
    File "/usr/local/lib/python3.4/test/support/init.py", line 1769 in _run_suite
    File "/usr/local/lib/python3.4/test/support/init.py", line 1803 in run_unittest
    File "/usr/local/lib/python3.4/test/test_datetime.py", line 45 in test_main
    File "/usr/local/lib/python3.4/test/regrtest.py", line 1280 in runtest_inner
    File "/usr/local/lib/python3.4/test/regrtest.py", line 978 in runtest
    File "/usr/local/lib/python3.4/test/regrtest.py", line 763 in main
    File "/usr/local/lib/python3.4/test/regrtest.py", line 1564 in main_in_temp_cwd
    File "/usr/local/lib/python3.4/test/main.py", line 3 in <module>
    File "/usr/local/lib/python3.4/runpy.py", line 85 in _run_code
    File "/usr/local/lib/python3.4/runpy.py", line 170 in _run_module_as_main
    Bus Error (core dumped)

    I then ran the same test through gdb:
    $ gdb /usr/local/bin/python3.4
    GNU gdb (GDB) 7.8.1
    <snip>
    (gdb) run -m test -v test_hash
    Starting program: /usr/local/bin/python3.4 -m test -v test_hash
    [Thread debugging using libthread_db enabled]
    [New Thread 1 (LWP 1)]
    == CPython 3.4.3 (default, Mar 25 2015, 17:35:25) [GCC 4.6.2]
    == Solaris-2.11-sun4v-sparc-32bit-ELF big-endian
    == hash algorithm: fnv 32bit
    == /tmp/test_python_12329
    Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_
    site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
    [1/1] test_hash
    test_empty_string (test.test_hash.BytesHashRandomizationTests) ... ok
    test_fixed_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_long_fixed_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_null_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_randomized_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_randomized_hash (test.test_hash.DatetimeDateTests) ... ok
    test_randomized_hash (test.test_hash.DatetimeDatetimeTests) ... FAIL
    test_randomized_hash (test.test_hash.DatetimeTimeTests) ... FAIL
    test_hashes (test.test_hash.HashBuiltinsTestCase) ... ok
    test_hash_distribution (test.test_hash.HashDistributionTestCase) ... ok
    test_coerced_floats (test.test_hash.HashEqualityTestCase) ... ok
    test_coerced_integers (test.test_hash.HashEqualityTestCase) ... ok
    test_numeric_literals (test.test_hash.HashEqualityTestCase) ... ok
    test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ...
    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 1 (LWP 1)]
    0xff25d14c in fnv (src=0x1d2289, len=127) at Python/pyhash.c:267
    267 x = (_PyHASH_MULTIPLIER * x) ^ block.value;
    (gdb) bt
    #0 0xff25d14c in fnv (src=0x1d2289, len=127) at Python/pyhash.c:267
    #1 0xff25d3f8 in _Py_HashBytes (src=0x1d2289, len=127) at Python/pyhash.c:186
    #2 0xff1a7ce4 in memory_hash (self=0xfdff5570) at Objects/memoryobject.c:2793
    #3 0xff1afa40 in PyObject_Hash (v=0xfdff5570) at Objects/object.c:757
    #4 0xff22b6fc in builtin_hash (self=0xfee23600, v=0xfdff5570) at Python/bltinmodule.c:1269
    #5 0xff236a70 in call_function (oparg=<optimized out>, pp_stack=0xffbfcc94) at Python/ceval.c:4224
    #6 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2838
    #7 0xff237790 in fast_function (nk=<optimized out>, na=<optimized out>, n=1, pp_stack=0xffbfcd8c,
    func=<optimized out>) at Python/ceval.c:4334
    <snip>

    (gdb) list
    262
    263 x = (Py_uhash_t) _Py_HashSecret.fnv.prefix;
    264 x ^= (Py_uhash_t) *p << 7;
    265 while (blocks--) {
    266 PY_UHASH_CPY(block.bytes, p);
    267 x = (_PyHASH_MULTIPLIER * x) ^ block.value;
    268 p += SIZEOF_PY_UHASH_T;
    269 }
    270 /* add remainder */
    271 for (; remainder > 0; remainder--)

    Further info:
    $ uname -a
    SunOS vstrlily1d 5.11 11.1 sun4v sparc sun4v Solaris

    $ gcc --verbose
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/sparc-sun-solaris2.11/4.6.2/lto-wrapper
    Target: sparc-sun-solaris2.11
    Configured with: ../gcc-4.6.2/configure --prefix=/usr/local --enable-languages=c,c++ --disable-nls --with-gnu-as --with-gnu-ld --target=sparc-sun-solaris2.11
    Thread model: posix
    gcc version 4.6.2 (GCC)

    @petriborg petriborg mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) tests Tests in the Lib/test dir type-crash A hard crash of the interpreter, possibly with a core dump labels Mar 26, 2015
    @petriborg
    Copy link
    Mannequin Author

    petriborg mannequin commented Mar 26, 2015

    I went and recompiled with:
    $ ./configure --prefix=/usr/local --enable-shared --with-hash-algorithm=siphash24

    But this crashed as well.

    test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... Fatal Python error: Bus error

    Current thread 0x00000001 (most recent call first):
    File "/usr/local/src/Python-3.4.3/Lib/test/test_hash.py", line 89 in test_unaligned_buffers
    File "/usr/local/src/Python-3.4.3/Lib/unittest/case.py", line 577 in run
    File "/usr/local/src/Python-3.4.3/Lib/unittest/case.py", line 625 in __call__
    File "/usr/local/src/Python-3.4.3/Lib/unittest/suite.py", line 122 in run
    File "/usr/local/src/Python-3.4.3/Lib/unittest/suite.py", line 84 in __call__
    File "/usr/local/src/Python-3.4.3/Lib/unittest/suite.py", line 122 in run
    File "/usr/local/src/Python-3.4.3/Lib/unittest/suite.py", line 84 in __call__
    File "/usr/local/src/Python-3.4.3/Lib/unittest/suite.py", line 122 in run
    File "/usr/local/src/Python-3.4.3/Lib/unittest/suite.py", line 84 in __call__
    File "/usr/local/src/Python-3.4.3/Lib/unittest/runner.py", line 168 in run
    File "/usr/local/src/Python-3.4.3/Lib/test/support/init.py", line 1769 in _run_suite
    File "/usr/local/src/Python-3.4.3/Lib/test/support/init.py", line 1803 in run_unittest
    File "/usr/local/src/Python-3.4.3/Lib/test/regrtest.py", line 1279 in test_runner
    File "/usr/local/src/Python-3.4.3/Lib/test/regrtest.py", line 1280 in runtest_inner
    File "/usr/local/src/Python-3.4.3/Lib/test/regrtest.py", line 978 in runtest
    File "/usr/local/src/Python-3.4.3/Lib/test/regrtest.py", line 763 in main
    File "/usr/local/src/Python-3.4.3/Lib/test/regrtest.py", line 1564 in main_in_temp_cwd
    File "/usr/local/src/Python-3.4.3/Lib/test/main.py", line 3 in <module>
    File "/usr/local/src/Python-3.4.3/Lib/runpy.py", line 85 in _run_code
    File "/usr/local/src/Python-3.4.3/Lib/runpy.py", line 170 in _run_module_as_main
    Bus Error (core dumped)

    test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ...
    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 1 (LWP 1)]
    0xff25d3d8 in siphash24 (src=0x1d2809, src_sz=<optimized out>) at Python/pyhash.c:387
    387 PY_UINT64_T mi = _le64toh(*in);
    (gdb) bt
    #0 0xff25d3d8 in siphash24 (src=0x1d2809, src_sz=<optimized out>) at Python/pyhash.c:387
    #1 0xff25dfa0 in _Py_HashBytes (src=0x1d2809, len=127) at Python/pyhash.c:186
    #2 0xff1a7ce4 in memory_hash (self=0xfdfc5dc0) at Objects/memoryobject.c:2793
    #3 0xff1afa40 in PyObject_Hash (v=0xfdfc5dc0) at Objects/object.c:757
    #4 0xff22b6fc in builtin_hash (self=0xfee23600, v=0xfdfc5dc0) at Python/bltinmodule.c:1269
    #5 0xff236a70 in call_function (oparg=<optimized out>, pp_stack=0xffbfcd64) at Python/ceval.c:4224
    #6 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2838
    #7 0xff237790 in fast_function (nk=<optimized out>, na=<optimized out>, n=1, pp_stack=0xffbfce5c,
    func=<optimized out>) at Python/ceval.c:4334

    (gdb) list
    382 PY_UINT64_T t;
    383 PY_UINT8_T *pt;
    384 PY_UINT8_T *m;
    385
    386 while (src_sz >= 8) {
    387 PY_UINT64_T mi = _le64toh(*in);
    388 in += 1;
    389 src_sz -= 8;
    390 v3 ^= mi;
    391 DOUBLE_ROUND(v0,v1,v2,v3);

    @serhiy-storchaka
    Copy link
    Member

    Siphash24 implementation is not designed to work on platforms that require aligned access. But I'm surprised that fnv implementation crashes. I don't see anything wrong. May be gcc needs some special options to produce correct binaries on this platform?

    @petriborg
    Copy link
    Mannequin Author

    petriborg mannequin commented Mar 26, 2015

    I've compiled Python 3.3.6 using the same options (./configure --prefix=/usr/local --enable-shared) and build system and that passes almost all the tests (test_uuid fails for an ignorable reason).

    Specifically test_hash passes fully:

    $ LD_LIBRARY_PATH=/usr/local/src/Python-3.3.6 ./python -m test -v test_hash
    == CPython 3.3.6 (default, Mar 26 2015, 15:35:36) [GCC 4.6.2]
    ==   Solaris-2.11-sun4v-sparc-32bit-ELF big-endian
    ==   /usr/local/src/Python-3.3.6/build/test_python_4539
    Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1)
    [1/1] test_hash
    test_empty_string (test.test_hash.BytesHashRandomizationTests) ... ok
    test_fixed_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_null_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_randomized_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_randomized_hash (test.test_hash.DatetimeDateTests) ... ok
    test_randomized_hash (test.test_hash.DatetimeDatetimeTests) ... ok
    test_randomized_hash (test.test_hash.DatetimeTimeTests) ... ok
    test_hashes (test.test_hash.HashBuiltinsTestCase) ... ok
    test_coerced_floats (test.test_hash.HashEqualityTestCase) ... ok
    test_coerced_integers (test.test_hash.HashEqualityTestCase) ... ok
    test_numeric_literals (test.test_hash.HashEqualityTestCase) ... ok
    test_unaligned_buffers (test.test_hash.HashEqualityTestCase) ... ok
    test_default_hash (test.test_hash.HashInheritanceTestCase) ... ok
    test_error_hash (test.test_hash.HashInheritanceTestCase) ... ok
    test_fixed_hash (test.test_hash.HashInheritanceTestCase) ... ok
    test_hashable (test.test_hash.HashInheritanceTestCase) ... ok
    test_not_hashable (test.test_hash.HashInheritanceTestCase) ... ok
    test_empty_string (test.test_hash.MemoryviewHashRandomizationTests) ... ok
    test_fixed_hash (test.test_hash.MemoryviewHashRandomizationTests) ... ok
    test_null_hash (test.test_hash.MemoryviewHashRandomizationTests) ... ok
    test_randomized_hash (test.test_hash.MemoryviewHashRandomizationTests) ... ok
    test_empty_string (test.test_hash.StrHashRandomizationTests) ... ok
    test_fixed_hash (test.test_hash.StrHashRandomizationTests) ... ok
    test_null_hash (test.test_hash.StrHashRandomizationTests) ... ok
    test_randomized_hash (test.test_hash.StrHashRandomizationTests) ... ok

    Ran 25 tests in 1.356s

    OK
    1 test OK.

    So any ideas what I should look for? Or perhaps it would be helpful if I posted config.log, etc.

    @serhiy-storchaka
    Copy link
    Member

    Yes, 3.3 uses less efficient implementation.

    Try to compile Python with gcc option -mno-unaligned-access.

    @petriborg
    Copy link
    Mannequin Author

    petriborg mannequin commented Mar 26, 2015

    That's not a valid option on SPARC, (see https://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html ) the flag is only available on ARM it seems.

    @tiran
    Copy link
    Member

    tiran commented Mar 26, 2015

    I'm puzzled about the segfault. I'm pretty sure that I've compiled and tested the code on big endian machines as well as a SPARC machines that doesn't allow unaligned memory access. The FNV code copies the blocks to an aligned buffer to prevent exactly this bug. Serhiy spent days to optimize the code as humanly possible.

    Please recompile Python again. This time create a debug build (--with-pydebug) and use the default hash function FNV for your platform. The debug build helps to pin point the bug.

    @serhiy-storchaka
    Copy link
    Member

    What if add double field in the block union? (And may be compile with -munaligned-doubles)

    diff -r a417d89fbc38 Python/pyhash.c
    --- a/Python/pyhash.c   Thu Mar 26 09:37:23 2015 +0100
    +++ b/Python/pyhash.c   Fri Mar 27 11:52:25 2015 +0200
    @@ -247,6 +247,7 @@ fnv(const void *src, Py_ssize_t len)
         union {
             Py_uhash_t value;
             unsigned char bytes[SIZEOF_PY_UHASH_T];
    +        double double_value;
         } block;
     
     #ifdef Py_DEBUG

    What if add the __aligned__ attribute?

    diff -r a417d89fbc38 Python/pyhash.c
    --- a/Python/pyhash.c   Thu Mar 26 09:37:23 2015 +0100
    +++ b/Python/pyhash.c   Fri Mar 27 11:58:30 2015 +0200
    @@ -247,7 +247,7 @@ fnv(const void *src, Py_ssize_t len)
         union {
             Py_uhash_t value;
             unsigned char bytes[SIZEOF_PY_UHASH_T];
    -    } block;
    +    } block __attribute__ ((__aligned__(SIZEOF_PY_UHASH_T)));
     
     #ifdef Py_DEBUG
         assert(_Py_HashSecret_Initialized);

    @serhiy-storchaka
    Copy link
    Member

    Or may be better to use explicit alignment 8 if this is 32-bit platform.

    diff -r a417d89fbc38 Python/pyhash.c
    --- a/Python/pyhash.c   Thu Mar 26 09:37:23 2015 +0100
    +++ b/Python/pyhash.c   Fri Mar 27 12:02:55 2015 +0200
    @@ -247,7 +247,7 @@ fnv(const void *src, Py_ssize_t len)
         union {
             Py_uhash_t value;
             unsigned char bytes[SIZEOF_PY_UHASH_T];
    -    } block;
    +    } block __attribute__ ((__aligned__(8)));
     
     #ifdef Py_DEBUG
         assert(_Py_HashSecret_Initialized);

    @vstinner
    Copy link
    Member

    The union trick is not portable, using memcpy() is safer. Compilers should be able to optimize it. Use Py_MEMCPY() for the stupid Visual Studio compiler unable to optimize memcpy() for small sizes.

    @serhiy-storchaka
    Copy link
    Member

    AFAIK it conforms the C standard and should be portable (but weird compiler bugs or misconfiguration can make it broken).

    With Py_MEMCPY() the code is less optimal. Don't add regression on common platforms.

    @petriborg
    Copy link
    Mannequin Author

    petriborg mannequin commented Mar 27, 2015

    OK I recompiled with "./configure --prefix=/usr/local --enable-shared --with-pydebug" and reran the test, unfortunately...

    $ LD_LIBRARY_PATH=/usr/local/src/Python-3.4.3 ./python -m test  test_hash
    [1/1] test_hash
    1 test OK.

    I then applied the patch in msg239385, this resulted in the same crash, I couldn't see any difference in gdb.

    I then tried each of the patches in msg239384, with -munaligned-doubles and with -mnounaligned-doubles, again no difference.

    I did notice that two tests failed in test_hash prior to the core dump, so here are the outputs from those in case that helps.

    <3.4.3 ./python -m test  -v test_hash.DatetimeDatetimeTests test_hash.DatetimeTimeTests
    == CPython 3.4.3 (default, Mar 27 2015, 08:45:04) [GCC 4.6.2]
    ==   Solaris-2.11-sun4v-sparc-32bit-ELF big-endian
    ==   hash algorithm: fnv 32bit
    ==   /usr/local/src/Python-3.4.3/build/test_python_10340
    Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
    [1/2] test_hash.DatetimeDatetimeTests
    test test_hash.DatetimeDatetimeTests crashed -- Traceback (most recent call last):
      File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
    AttributeError: 'module' object has no attribute '__path__'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/src/Python-3.4.3/Lib/test/regrtest.py", line 1271, in runtest_inner
        the_module = importlib.import_module(abstest)
      File "/usr/local/src/Python-3.4.3/Lib/importlib/__init__.py", line 109, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
      File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
      File "<frozen importlib._bootstrap>", line 2221, in _find_and_load_unlocked
    ImportError: No module named 'test.test_hash.DatetimeDatetimeTests'; 'test.test_hash' is not a package
    
    [2/2/1] test_hash.DatetimeTimeTests
    test test_hash.DatetimeTimeTests crashed -- Traceback (most recent call last):
      File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
    AttributeError: 'module' object has no attribute '__path__'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/src/Python-3.4.3/Lib/test/regrtest.py", line 1271, in runtest_inner
        the_module = importlib.import_module(abstest)
      File "/usr/local/src/Python-3.4.3/Lib/importlib/__init__.py", line 109, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
      File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
      File "<frozen importlib._bootstrap>", line 2221, in _find_and_load_unlocked
    ImportError: No module named 'test.test_hash.DatetimeTimeTests'; 'test.test_hash' is not a package

    2 tests failed:
    test_hash.DatetimeDatetimeTests test_hash.DatetimeTimeTests

    Thanks guys!

    @petriborg
    Copy link
    Mannequin Author

    petriborg mannequin commented Mar 27, 2015

    Sorry I copied the wrong term buffer :-)
    This is the output after I commented out the HashEqualityTestCase class which causes the core dump.

    LD_LIBRARY_PATH=/usr/local/src/Python-3.4.3 ./python -m test -v test_hash
    == CPython 3.4.3 (default, Mar 27 2015, 08:45:04) [GCC 4.6.2]
    == Solaris-2.11-sun4v-sparc-32bit-ELF big-endian
    == hash algorithm: fnv 32bit
    == /usr/local/src/Python-3.4.3/build/test_python_10730
    Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_
    site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
    [1/1] test_hash
    test_empty_string (test.test_hash.BytesHashRandomizationTests) ... ok
    test_fixed_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_long_fixed_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_null_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_randomized_hash (test.test_hash.BytesHashRandomizationTests) ... ok
    test_randomized_hash (test.test_hash.DatetimeDateTests) ... ok
    test_randomized_hash (test.test_hash.DatetimeDatetimeTests) ... FAIL
    test_randomized_hash (test.test_hash.DatetimeTimeTests) ... FAIL
    test_hashes (test.test_hash.HashBuiltinsTestCase) ... ok
    test_hash_distribution (test.test_hash.HashDistributionTestCase) ... ok
    test_default_hash (test.test_hash.HashInheritanceTestCase) ... ok
    test_error_hash (test.test_hash.HashInheritanceTestCase) ... ok
    test_fixed_hash (test.test_hash.HashInheritanceTestCase) ... ok
    test_hashable (test.test_hash.HashInheritanceTestCase) ... ok
    test_not_hashable (test.test_hash.HashInheritanceTestCase) ... ok
    test_empty_string (test.test_hash.MemoryviewHashRandomizationTests) ... ok
    test_fixed_hash (test.test_hash.MemoryviewHashRandomizationTests) ... ok
    test_long_fixed_hash (test.test_hash.MemoryviewHashRandomizationTests) ... ok
    test_null_hash (test.test_hash.MemoryviewHashRandomizationTests) ... ok
    test_randomized_hash (test.test_hash.MemoryviewHashRandomizationTests) ... ok
    test_empty_string (test.test_hash.StrHashRandomizationTests) ... ok
    test_fixed_hash (test.test_hash.StrHashRandomizationTests) ... ok
    test_long_fixed_hash (test.test_hash.StrHashRandomizationTests) ... ok
    test_null_hash (test.test_hash.StrHashRandomizationTests) ... ok
    test_randomized_hash (test.test_hash.StrHashRandomizationTests) ... ok
    test_ucs2_string (test.test_hash.StrHashRandomizationTests) ... ok

    ======================================================================
    FAIL: test_randomized_hash (test.test_hash.DatetimeDatetimeTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/usr/local/src/Python-3.4.3/Lib/test/test_hash.py", line 193, in test_randomized_hash
        run1 = self.get_hash(self.repr_, seed='random')
      File "/usr/local/src/Python-3.4.3/Lib/test/test_hash.py", line 187, in get_hash
        **env)
      File "/usr/local/src/Python-3.4.3/Lib/test/script_helper.py", line 106, in assert_python_ok
        return _assert_python(True, *args, **env_vars)
      File "/usr/local/src/Python-3.4.3/Lib/test/script_helper.py", line 92, in _assert_python
        err.decode('ascii', 'ignore')))
    AssertionError: Process return code is -10, command line was: ['/usr/local/src/Python-3.4.3/python', '-X', 'faulthandle
    r', '-c', 'import datetime; print(hash(datetime.datetime(1, 2, 3, 4, 5, 6, 7)))'], stderr follows:
    Fatal Python error: Bus error

    Current thread 0x00000001 (most recent call first):
    File "<string>", line 1 in <module>

    ======================================================================
    FAIL: test_randomized_hash (test.test_hash.DatetimeTimeTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/usr/local/src/Python-3.4.3/Lib/test/test_hash.py", line 193, in test_randomized_hash
        run1 = self.get_hash(self.repr_, seed='random')
      File "/usr/local/src/Python-3.4.3/Lib/test/test_hash.py", line 187, in get_hash
        **env)
      File "/usr/local/src/Python-3.4.3/Lib/test/script_helper.py", line 106, in assert_python_ok
        return _assert_python(True, *args, **env_vars)
      File "/usr/local/src/Python-3.4.3/Lib/test/script_helper.py", line 92, in _assert_python
        err.decode('ascii', 'ignore')))
    AssertionError: Process return code is -10, command line was: ['/usr/local/src/Python-3.4.3/python', '-X', 'faulthandle
    r', '-c', 'import datetime; print(hash(datetime.time(0, 0)))'], stderr follows:
    Fatal Python error: Bus error

    Current thread 0x00000001 (most recent call first):
    File "<string>", line 1 in <module>

    ----------------------------------------------------------------------
    Ran 26 tests in 3.429s

    FAILED (failures=2)
    test test_hash failed

    @petriborg
    Copy link
    Mannequin Author

    petriborg mannequin commented Mar 27, 2015

    Hi haypo,

    I just realized you had created a patch too, the fnv_memcpy.patch worked!

    $ LD_LIBRARY_PATH=/usr/local/src/Python-3.4.3 ./python -m test test_hash
    [1/1] test_hash
    1 test OK.

    Running the full regression test now, but I bet everything passes.

    @petriborg
    Copy link
    Mannequin Author

    petriborg mannequin commented Apr 2, 2015

    So this morning I got around to rebuilding the tool chain using GCC 4.9.2 and I'm happy to report that this problem goes away (no patch required)! So it must be some sort of problem with the 4.6 GCC.

    I've still got the old tool chain around, and I'm happy to further patch / test if anyone at Python wants me to.

    $ gcc --verbose
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/sparc-sun-solaris2.11/4.9.2/lto-wrapper
    Target: sparc-sun-solaris2.11
    Configured with: ../gcc-4.9.2/configure --prefix=/usr/local --enable-languages=c,c++ --disable-nls --with-gnu-as --with-gnu-ld --target=sparc-sun-solaris2.11
    Thread model: posix
    gcc version 4.9.2 (GCC)

    @serhiy-storchaka
    Copy link
    Member

    Just interesting, what is the result of str(memoryview(b'abcdefghijklmnopqrstuvwxyz')[1:], 'ascii') with old and new toolchains.

    @petriborg
    Copy link
    Mannequin Author

    petriborg mannequin commented Apr 3, 2015

    Test 1
    Python 3.4.3 built by GCC 4.9.2 is:
    >>> str(memoryview(b'abcdefghijklmnopqrstuvwxyz')[1:], 'ascii')
    'bcdefghijklmnopqrstuvwxyz'
    
    
    Test 2
    Python 3.4.3 built by GCC 4.6.2 is (no patches applied)
    This build will core dump if I run -m test test_hash.
    >>> str(memoryview(b'abcdefghijklmnopqrstuvwxyz')[1:], 'ascii')
    'bcdefghijklmnopqrstuvwxyz'

    @iritkatriel
    Copy link
    Member

    Can this be close (as third party?) or is there anything left to do?

    @petriborg
    Copy link
    Mannequin Author

    petriborg mannequin commented Jun 16, 2021

    We've migrated our python process off Solaris.

    @petriborg petriborg mannequin closed this as completed Jun 16, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) tests Tests in the Lib/test dir type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants