Diff for /wikisrc/users/leot/aarch64_problems.mdwn between versions 1.4 and 1.9

version 1.4, 2018/06/28 09:10:49 version 1.9, 2018/07/28 19:14:29
Line 7  investigation in order to write proper P Line 7  investigation in order to write proper P
 ## `mpv` and NetBSD crashes  ## `mpv` and NetBSD crashes
 Just by invoking `mpv` via:  Just by invoking `mpv` via:
   
     $ mpv      % mpv
   
 It is possible to completely crash NetBSD on aarch64. Investigate why and if  It SEGV as follows:
 possible get a complete backtrace.  
   
 (Is it PaX MPROTECT related?)      % mpv
       /usr/pkg/lib/ffmpeg4/libavcodec.so.58: text relocations
       mpv 0.29.0 Copyright © 2000-2018 mpv/MPlayer/mplayer2 projects
        built on Sat Jul 28 21:02:57 CEST 2018
       ffmpeg library versions:
          libavutil       56.14.100
          libavcodec      58.18.100
          libavformat     58.12.100
          libswscale      5.1.100
          libavfilter     7.16.100
          libswresample   3.1.100
       ffmpeg version: 4.0.2
       
       Usage:   mpv [options] [url|path/]filename
       
       Basic options:
        --start=<time>    seek to given (percent, seconds, or hh:mm:ss) position
        --no-audio        do not play sound
        --no-video        do not play video
        --fs              fullscreen playback
        --sub-file=<file> specify subtitle file to use
        --playlist=<file> specify playlist file
       
        --list-options    list all mpv options
        --h=<string>      print options which contain the given string in their name
       
       [1]   Segmentation fault (core dumped) /usr/pkg/bin/mpv...
       % gdb -core mpv.core /usr/pkg/bin/mpv
       Reading symbols from /usr/pkg/bin/mpv...done.
       [New process 5]
       [New process 6]
       [New process 4]
       [New process 3]
       [New process 2]
       [New process 1]
       Core was generated by `mpv'.
       Program terminated with signal SIGSEGV, Segmentation fault.
       #0  0x0000f96f727f40b0 in memcpy () from /usr/lib/libc.so.12
       [Current thread is 1 (process 5)]
       (gdb) bt
       #0  0x0000f96f727f40b0 in memcpy () from /usr/lib/libc.so.12
       #1  0x00000002001cba34 in __memcpy_ichk (len=18446744073709551615, src=0xf96f6e10fec0, dst=<optimized out>)
           at /usr/include/ssp/string.h:82
       #2  strndup_append_at (str=str@entry=0xf96f6f4ff348, at=0, append=0xf96f6e10fec0 "speed", append_len=<optimized out>,
           append_len@entry=18446744073709551615) at ../ta/ta_utils.c:113
       #3  0x00000002001cbea4 in ta_strdup_append_buffer (str=str@entry=0xf96f6f4ff348, a=<optimized out>) at ../ta/ta_utils.c:165
       #4  0x00000002001cb7b8 in ta_talloc_strdup_append_buffer (s=<optimized out>, s@entry=0x0, a=<optimized out>) at ../ta/ta_talloc.c:31
       #5  0x0000000200157eec in print_str_list (opt=<optimized out>, src=<optimized out>) at ../options/m_option.c:1477
       #6  0x000000020015db90 in m_option_print (val_ptr=0xf96f6f4ff3c0, opt=0xf96f6f4ff430) at ../options/m_option.h:496
       #7  m_property_do (log=0xf96f71045130, prop_list=0xf96f71081040, name=name@entry=0xf96f6e139218 "property-list",
           action=action@entry=6, arg=arg@entry=0xf96f6f4ff598, ctx=ctx@entry=0xf96f71011040) at ../options/m_property.c:127
       #8  0x000000020016f9f8 in mp_property_do_silent (name=0xf96f6e139218 "property-list", action=6, val=0xf96f6f4ff598, ctx=0xf96f71011040)
           at ../player/command.c:4167
       #9  0x0000000200171014 in mp_property_do (name=0xf96f6e139218 "property-list", action=action@entry=6, val=<optimized out>,
           val@entry=0xf96f6f4ff5c8, ctx=0xf96f71011040) at ../player/command.c:4177
       #10 0x00000002001637bc in getproperty_fn (arg=0xf96f6f4ff5d8, arg@entry=0xf96f6f4ff5e8) at ../player/client.c:1261
       #11 0x00000002001655b0 in run_locked (fn_data=0xf96f6f4ff5e8, fn=0x200163648 <getproperty_fn>, ctx=0xf96f6f5071c0)
           at ../player/client.c:1003
       #12 mpv_get_property (ctx=0xf96f6f5071c0, name=name@entry=0xf96f6e139218 "property-list", format=format@entry=MPV_FORMAT_STRING,
           data=data@entry=0xf96f6f4ff668) at ../player/client.c:1335
       #13 0x0000000200179b4c in script_get_property (L=0xf96f6e103400) at ../player/lua.c:794
       #14 0x0000f96f72b2cb80 in luaD_precall () from /usr/pkg/lib/liblua5.2.so.5
       #15 0x0000f96f72b3877c in luaV_execute () from /usr/pkg/lib/liblua5.2.so.5
       #16 0x0000f96f72b2cf04 in luaD_call () from /usr/pkg/lib/liblua5.2.so.5
       #17 0x0000f96f72b28e40 in lua_callk () from /usr/pkg/lib/liblua5.2.so.5
       #18 0x0000000200178270 in load_builtin (L=0xf96f6e103400) at ../player/lua.c:214
       #19 0x0000f96f72b2cb80 in luaD_precall () from /usr/pkg/lib/liblua5.2.so.5
       #20 0x0000f96f72b2cef8 in luaD_call () from /usr/pkg/lib/liblua5.2.so.5
       #21 0x0000f96f72b28e40 in lua_callk () from /usr/pkg/lib/liblua5.2.so.5
       #22 0x0000f96f72b43900 in ll_require () from /usr/pkg/lib/liblua5.2.so.5
       #23 0x0000f96f72b2cb80 in luaD_precall () from /usr/pkg/lib/liblua5.2.so.5
       ---Type <return> to continue, or q <return> to quit---
       #24 0x0000f96f72b3877c in luaV_execute () from /usr/pkg/lib/liblua5.2.so.5
       #25 0x0000f96f72b2cf04 in luaD_call () from /usr/pkg/lib/liblua5.2.so.5
       #26 0x0000f96f72b28e40 in lua_callk () from /usr/pkg/lib/liblua5.2.so.5
       #27 0x0000000200179524 in require (L=L@entry=0xf96f6e103400, name=name@entry=0xf96f6f503420 "@stats.lua") at ../player/lua.c:232
       #28 0x000000020017963c in load_scripts (L=0xf96f6e103400) at ../player/lua.c:260
       #29 0x0000f96f72b2cb80 in luaD_precall () from /usr/pkg/lib/liblua5.2.so.5
       #30 0x0000f96f72b2cef8 in luaD_call () from /usr/pkg/lib/liblua5.2.so.5
       #31 0x0000f96f72b2c4b8 in luaD_rawrunprotected () from /usr/pkg/lib/liblua5.2.so.5
       #32 0x0000f96f72b2d19c in luaD_pcall () from /usr/pkg/lib/liblua5.2.so.5
       #33 0x0000f96f72b28f14 in lua_pcallk () from /usr/pkg/lib/liblua5.2.so.5
       #34 0x000000020017b020 in run_lua (L=0xf96f6e103400) at ../player/lua.c:354
       #35 0x0000f96f72b2cb80 in luaD_precall () from /usr/pkg/lib/liblua5.2.so.5
       #36 0x0000f96f72b2cef8 in luaD_call () from /usr/pkg/lib/liblua5.2.so.5
       #37 0x0000f96f72b2c4b8 in luaD_rawrunprotected () from /usr/pkg/lib/liblua5.2.so.5
       #38 0x0000f96f72b2d19c in luaD_pcall () from /usr/pkg/lib/liblua5.2.so.5
       #39 0x0000f96f72b28f14 in lua_pcallk () from /usr/pkg/lib/liblua5.2.so.5
       #40 0x000000020017b4c8 in mp_cpcall (func=0x20017abd0 <run_lua>, ud=0xf96f6e1010c0, L=0xf96f6e103400) at ../player/lua.c:99
       #41 load_lua (client=<optimized out>, fname=0xf96f6f503420 "@stats.lua") at ../player/lua.c:387
       #42 0x00000002001815c0 in script_thread (p=0xf96f6f5050c0) at ../player/scripting.c:95
       #43 0x0000f96f743ec588 in pthread__create_tramp (cookie=0xf96f6f515000) at /usr/src/lib/libpthread/pthread.c:593
       #44 0x0000f96f727385ec in _lwp_makecontext (u=0x0, start=0x0, arg=0x0, private=0xff00000014,
           stack_base=0x1 <error: Cannot access memory at address 0x1>, stack_size=8589934592) at /usr/src/lib/libc/arch/aarch64/gen/_lwp.c:47
       #45 0x0000f96f743df000 in ?? ()
       #46 0x544a8f02d40034c1 in ?? ()
       Backtrace stopped: previous frame identical to this frame (corrupt stack?)
   
   
 ## Python `import requests` SIGILLs  ## Python `import requests` SIGILLs
Line 22  Doing a (please note that also `python36 Line 117  Doing a (please note that also `python36
     Illegal instruction (core dumped)      Illegal instruction (core dumped)
     Exit 132      Exit 132
   
 leads to a SIGILL. Trying to reduce the test case this also happens with just a:  ...where:
   
     $ python2.7 -c 'import OpenSSL'      % gdb -core python2.7.core `which python2.7`
     Illegal instruction (core dumped)      Reading symbols from /usr/pkg/bin/python2.7...(no debugging symbols found)...done.
     Exit 132      [New process 1]
       Core was generated by `python2.7'.
 Trying to debug this a bit further we can see:      Program terminated with signal SIGILL, Illegal instruction.
       #0  0x0000f42f5fd00000 in ?? ()
     % cat asi.py      (gdb) bt 5
     import OpenSSL      #0  0x0000f42f5fd00000 in ?? ()
     % python2.7 -m trace --trace asi.py      #1  0x0000f42f5fd0a3d0 in restore_errno_only () at c/misc_thread_common.h:43
     [...]      #2  0x0000f42f5fbf0f90 in _cffi_f_SSL_library_init (self=<optimized out>, noarg=<optimized out>)
     binding.py(88):     for attr in dir(lib):          at build/temp.netbsd-8.99.22-evbarm-2.7/_openssl.c:51839
     binding.py(89):         if attr not in excluded_names:      #3  0x0000f42f617606ac in PyEval_EvalFrameEx () from /usr/pkg/lib/libpython2.7.so.1.0
     binding.py(90):             setattr(conditional_lib, attr, getattr(lib, attr))      #4  0x0000f42f6175e5c0 in PyEval_EvalCodeEx () from /usr/pkg/lib/libpython2.7.so.1.0
     binding.py(88):     for attr in dir(lib):      (More stack frames follow...)
     binding.py(89):         if attr not in excluded_names:      (gdb) f 2
     binding.py(90):             setattr(conditional_lib, attr, getattr(lib, attr))      #2  0x0000f42f5fbf0f90 in _cffi_f_SSL_library_init (self=<optimized out>, noarg=<optimized out>)
     binding.py(88):     for attr in dir(lib):          at build/temp.netbsd-8.99.22-evbarm-2.7/_openssl.c:51839
     binding.py(89):         if attr not in excluded_names:      warning: Source file is more recent than executable.
     binding.py(90):             setattr(conditional_lib, attr, getattr(lib, attr))      51839     _cffi_restore_errno();
     binding.py(88):     for attr in dir(lib):      (gdb) list
     binding.py(92):     return conditional_lib      51834   _cffi_f_SSL_library_init(PyObject *self, PyObject *noarg)
     binding.py(126):                 cls._lib_loaded = True      51835   {
     binding.py(128):                 cls.lib.SSL_library_init()      51836     int result;
     Illegal instruction (core dumped)      51837
     Exit 132      51838     Py_BEGIN_ALLOW_THREADS
       51839     _cffi_restore_errno();
 Please also note that this problem seems limited to `OpenSSL`, `ssl` module      51840     { result = SSL_library_init(); }
 works.      51841     _cffi_save_errno();
       51842     Py_END_ALLOW_THREADS
       51843
       (gdb) f 1
       #1  0x0000f42f5fd0a3d0 in restore_errno_only () at c/misc_thread_common.h:43
       43      static void restore_errno_only(void) { errno = cffi_saved_errno; }
       (gdb) list
       38         syntactically valid to use "__thread" with this C compiler. */
       39      #ifdef USE__THREAD
       40
       41      static __thread int cffi_saved_errno = 0;
       42      static void save_errno_only(void) { cffi_saved_errno = errno; }
       43      static void restore_errno_only(void) { errno = cffi_saved_errno; }
       44
       45      #else
       46
       47      static void save_errno_only(void)
       (gdb) disas
       Dump of assembler code for function restore_errno_only:
          0x0000f42f5fd0a3b0 <+0>:     str     x30, [sp, #-16]!
          0x0000f42f5fd0a3b4 <+4>:     bl      0xf42f5fd075c0 <__errno@plt>
          0x0000f42f5fd0a3b8 <+8>:     mov     x2, x0
          0x0000f42f5fd0a3bc <+12>:    mrs     x1, tpidr_el0
          0x0000f42f5fd0a3c0 <+16>:    adrp    x0, 0xf42f5fd34000
          0x0000f42f5fd0a3c4 <+20>:    ldr     x3, [x0, #4088]
          0x0000f42f5fd0a3c8 <+24>:    add     x0, x0, #0xff8
          0x0000f42f5fd0a3cc <+28>:    blr     x3
       => 0x0000f42f5fd0a3d0 <+32>:    ldr     w0, [x1, x0]
          0x0000f42f5fd0a3d4 <+36>:    str     w0, [x2]
          0x0000f42f5fd0a3d8 <+40>:    ldr     x30, [sp], #16
          0x0000f42f5fd0a3dc <+44>:    ret
       End of assembler dump.
       (gdb) info reg
       x0             0xf42f5fd34ff8   268484308324344
       x1             0xf42f61875080   268484336898176
       x2             0xf42f6186c848   268484336863304
       x3             0xf42f5fd00000   268484308107264
       x4             0xf42f5ff3c0b8   268484310450360
       x5             0xf42f60000570   268484311254384
       x6             0x65000000000000 28428972647776256
       x7             0x65     101
       x8             0xf42f6185e000   268484336803840
       x9             0xf42f6185e668   268484336805480
       x10            0xf42f6185e668   268484336805480
       x11            0x1      1
       x12            0x30     48
       x13            0xffffff9264f0   281474969527536
       x14            0x65     101
       x15            0x3      3
       x16            0xf42f615bd730   268484334049072
       x17            0xf42f615ec2c8   268484334240456
       x18            0xf42f615ca1a0   268484334100896
       x19            0xf42f5fc9cea8   268484307701416
       x20            0xf42f5fd9c3c0   268484308747200
       x21            0xf42f61307090   268484331204752
       x22            0xf42f5fcd38e8   268484307925224
       x23            0xf42f5fcd10a0   268484307914912
       x24            0xf42f5fb8c5a8   268484306585000
       x25            0xf42f5fd9c3c0   268484308747200
       x26            0xf42f5fbf0f70   268484306997104
       x27            0xf42f5fdd467e   268484308977278
       x28            0xf42f61307090   268484331204752
       x29            0x0      0
       x30            0xf42f5fd0a3d0   268484308149200
       sp             0xffffff926760   0xffffff926760
       pc             0xf42f5fd0a3d0   0xf42f5fd0a3d0 <restore_errno_only+32>
       cpsr           0x60000000       [ EL=0 C Z ]
       fpsr           0x3000000        50331648
       fpcr           0x10     16
       (gdb) quit
   
   ...and `_cffi_restore_errno` and `_cffi_save_errno` are defined in
   `cffi/_cffi_include.h` as follows:
   
       #define _cffi_restore_errno                                              \
           ((void(*)(void))_cffi_exports[13])
       #define _cffi_save_errno                                                 \
           ((void(*)(void))_cffi_exports[14])
   
   The following patch workaround the issue:
   
       $NetBSD: aarch64_problems.mdwn,v 1.8 2018/07/24 00:09:53 wiki Exp $
       
       Kludge for NetBSD/aarch64 SIGILL.
       
       --- setup.py.orig   2018-02-27 18:15:41.000000000 +0000
       +++ setup.py
       @@ -70,7 +70,7 @@ def ask_supports_thread():
            ok = (sys.platform != 'win32' and
                  config.try_compile('__thread int some_threadlocal_variable_42;'))
            if ok:
       -        define_macros.append(('USE__THREAD', None))
       +        pass
            else:
                ok1 = config.try_compile('int some_regular_variable_42;')
                if not ok1:
   
   
   ## polkitd crashes
   
       pinebook# /usr/pkg/lib/polkit-1/polkitd
       Successfully changed to user polkitd
       Error loading /var/run/ConsoleKit/database: Error statting file /var/run/ConsoleKit/database: No such file or directory[1]   Segmentation fault      /usr/pkg/lib/polkit-1/polkitd

Removed from v.1.4  
changed lines
  Added in v.1.9


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb