[solved] Failed to map segment from shared object


#1

Hello,

I am trying to run a the cross compilation rpc example on a tizen system, I get the error:

Traceback (most recent call last):
  File "tutorials/cross_compilation_and_rpc.py", line 164, in <module>
    func = remote.load_module('lib.tar')
  File "/home/SERILOCAL/n.perto/Documents/tvm/python/tvm/rpc/client.py", line 132, in load_module
    return base._LoadRemoteModule(self._sess, path)
  File "/home/SERILOCAL/n.perto/Documents/tvm/python/tvm/_ffi/_ctypes/function.py", line 185, in __call__
    ctypes.byref(ret_val), ctypes.byref(ret_tcode)))
  File "/home/SERILOCAL/n.perto/Documents/tvm/python/tvm/_ffi/base.py", line 71, in check_call
    raise TVMError(py_str(_LIB.TVMGetLastError()))
tvm._ffi.base.TVMError: Except caught from RPC call: TVMCall CFunc Error:
Traceback (most recent call last):
  File "/opt/usr/tvm/python/tvm/_ffi/_ctypes/function.py", line 55, in cfun
    rv = local_pyfunc(*pyargs)
  File "/opt/usr/tvm/python/tvm/rpc/server.py", line 50, in load_module
    m = _load_module(path)
  File "/opt/usr/tvm/python/tvm/module.py", line 244, in load
    return _LoadFromFile(path, fmt)
  File "/opt/usr/tvm/python/tvm/_ffi/_ctypes/function.py", line 185, in __call__
    ctypes.byref(ret_val), ctypes.byref(ret_tcode)))
  File "/opt/usr/tvm/python/tvm/_ffi/base.py", line 71, in check_call
    raise TVMError(py_str(_LIB.TVMGetLastError()))
TVMError: [09:38:19] /home/abuild/rpmbuild/BUILD/tvm-runtime-0.5.0/src/runtime/dso_module.cc:93: Check failed: lib_handle_ != nullptr Failed to load dynamic shared library /tmp/tmpFacQDy/lib.tar.so /tmp/tmpFacQDy/lib.tar.so: failed to map segment from shared object

Stack trace returned 10 entries:
[bt] (0) /usr/lib/libtvm_runtime.so(+0x8fc2) [0xb5205fc2]
[bt] (1) /usr/lib/libtvm_runtime.so(+0x29d02) [0xb5226d02]
[bt] (2) /usr/lib/libtvm_runtime.so(tvm::runtime::Module::LoadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x301) [0xb52209ca]
[bt] (3) /usr/lib/libtvm_runtime.so(+0x25ab2) [0xb5222ab2]
[bt] (4) /usr/lib/libtvm_runtime.so(TVMFuncCall+0x3b) [0xb522a644]
[bt] (5) /usr/lib/python2.7/lib-dynload/_ctypes.so(ffi_call_SYSV+0x34) [0xb60612c8]
[bt] (6) /usr/lib/python2.7/lib-dynload/_ctypes.so(ffi_call+0xf7) [0xb6061964]
[bt] (7) /usr/lib/python2.7/lib-dynload/_ctypes.so(_ctypes_callproc+0x2e3) [0xb605c6a4]
[bt] (8) /usr/lib/python2.7/lib-dynload/_ctypes.so(+0x7036) [0xb6058036]
[bt] (9) /usr/lib/libpython2.7.so.1.0(PyObject_Call+0x2b) [0xb66462d4]

I checked that the file are effectively exported to the device and they are, so it’s not a problem of file not there.
I never ran into that error before, could someone help me to figure out what is happening please?


#2

Okay I solved it:
I don’t have the exec flag on the /tmp partition which leads to this error (although cat /proc/mounts is not showing the noexec flag…).
Since I cannot remount the partition, I tried changing the temp dir location for python by setting TMPDIR/TEMP/TMP environments before executing the server, unfortunately it is not taken into account by python on my system.
So I added at the beginning of rpc_server.py (should be done for rpc_tracker.py as well):

import tempfile
tempfile.tempdir = '/root/tmp'

and now everything works fine.