juliamatlab / mexjulia

embedding Julia in the MATLAB process.
MIT License
52 stars 14 forks source link

Error using mex unresolved externals #22

Closed musm closed 7 years ago

musm commented 7 years ago

Error using mex

jlcall.obj : error LNK2019: unresolved external symbol __imp_jl_tls_states referenced in function mexFunction ........\mexjulia\m\jlcall.mexw64 : fatal error LNK1120: 1 unresolved externals

julia v0.5 Matlab r2016a

twadleigh commented 7 years ago

I think you might be looking at master. Check out the rebranding branch and give it another try.

musm commented 7 years ago

ah yes. Thank you for the package.

musm commented 7 years ago
MATLAB crash file:C:\Users\Mus\AppData\Local\Temp\matlab_crash_dump.16492-1:

------------------------------------------------------------------------
          Access violation detected at Fri Oct 14 14:07:37 2016
------------------------------------------------------------------------

Configuration:
  Crash Decoding      : Disabled
  Crash Mode          : continue (default)
  Current Graphics Driver: Unknown hardware 
  Default Encoding    : windows-1252
  Graphics card 1     : NVIDIA ( 0x10de ) NVIDIA GeForce 840M Version 21.21.13.7290
  Graphics card 2     : Intel Corporation ( 0x8086 ) Intel(R) HD Graphics Family Version 10.18.15.4256
  Host Name           : mus-laptop
  MATLAB Architecture : win64
  MATLAB Root         : C:\Program Files\MATLAB\R2016a
  MATLAB Version      : 9.0.0.341360 (R2016a)
  OpenGL              : hardware
  Operating System    : Microsoft Windows 10 Pro Insider Preview
  Processor ID        : x86 Family 6 Model 69 Stepping 1, GenuineIntel
  Virtual Machine     : Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
  Window System       : Version 10.0 (Build 14946)

Fault Count: 1

Abnormal termination:
Access violation

Register State (from fault):
  RAX = 0000000000000010  RBX = 0000000000000000
  RCX = 0000000000000010  RDX = 000000008e530008
  RSP = 00000000043fb230  RBP = 00000000043fb300
  RSI = 000000008e530008  RDI = 0000000036afabc0

   R8 = 0000000000000000   R9 = 0000000000000000
  R10 = ff51afd7ed558ccd  R11 = 000000008e530020
  R12 = 00000000043fc268  R13 = 0000000000000001
  R14 = 00000000043fb380  R15 = 0000000000000000

  RIP = 000000008ea13288  EFL = 00010206

   CS = 0033   FS = 0053   GS = 002b

Stack Trace (from fault):
[  0] 0x000000008ea13288         C:\Julia\Julia-0.5-latest\bin\libjulia.dll+00864904 jl_clock_now+00000904
[  1] 0x000000008e967754         C:\Julia\Julia-0.5-latest\bin\libjulia.dll+00161620 jl_get_binding_wr+00000324
[  2] 0x000000008e968f70         C:\Julia\Julia-0.5-latest\bin\libjulia.dll+00167792 jl_get_global+00000016
[  3] 0x00007ffb31ee1221      C:\Users\Mus\Desktop\mexjulia\mexjulia.mexw64+00004641 mexFunction+00000225
[  4] 0x00000000fc5f77d1 C:\Program Files\MATLAB\R2016a\bin\win64\libmex.dll+00096209 mexRunMexFile+00000129
[  5] 0x00000000fc5f6d12 C:\Program Files\MATLAB\R2016a\bin\win64\libmex.dll+00093458 inSwapMexfileReader+00000434
[  6] 0x00000000fc5f6966 C:\Program Files\MATLAB\R2016a\bin\win64\libmex.dll+00092518 mexUnlock+00004774
[  7] 0x00000000157d5d1f C:\Program Files\MATLAB\R2016a\bin\win64\m_dispatcher.dll+00089375 Mfh_file::dispatch_fh_impl+00000527
[  8] 0x00000000157d5f0e C:\Program Files\MATLAB\R2016a\bin\win64\m_dispatcher.dll+00089870 Mfh_file::dispatch_fh+00000062
[  9] 0x00000000157d3e15 C:\Program Files\MATLAB\R2016a\bin\win64\m_dispatcher.dll+00081429 Mfunction_handle::dispatch+00000933
[ 10] 0x0000000016c22033 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00335923
[ 11] 0x0000000016dc3e0d C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+02047501 boost::serialization::singleton<boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,ir::IrTree> >::get_instance+00665693
[ 12] 0x0000000016dc3d6a C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+02047338 boost::serialization::singleton<boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,ir::IrTree> >::get_instance+00665530
[ 13] 0x0000000016dc3e48 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+02047560 boost::serialization::singleton<boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,ir::IrTree> >::get_instance+00665752
[ 14] 0x0000000016ca428f C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00869007 boost::serialization::singleton<boost::archive::detail::pointer_iserializer<boost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00069131
[ 15] 0x0000000016ca4ef6 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00872182 boost::serialization::singleton<boost::archive::detail::pointer_iserializer<boost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00072306
[ 16] 0x0000000016ca6237 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00877111 boost::serialization::singleton<boost::archive::detail::pointer_iserializer<boost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00077235
[ 17] 0x0000000016ca6c05 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00879621 boost::serialization::singleton<boost::archive::detail::pointer_iserializer<boost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00079745
[ 18] 0x0000000016ca642f C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00877615 boost::serialization::singleton<boost::archive::detail::pointer_iserializer<boost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00077739
[ 19] 0x0000000016ca613a C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00876858 boost::serialization::singleton<boost::archive::detail::pointer_iserializer<boost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00076982
[ 20] 0x0000000016c9de5b C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00843355 boost::serialization::singleton<boost::archive::detail::pointer_iserializer<boost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00043479
[ 21] 0x0000000016c9bd27 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00834855 boost::serialization::singleton<boost::archive::detail::pointer_iserializer<boost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00034979
[ 22] 0x0000000016c9b1c2 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00831938 boost::serialization::singleton<boost::archive::detail::pointer_iserializer<boost::archive::binaryTerm_iarchive,ir::IrTree> >::get_instance+00032062
[ 23] 0x0000000016c29d47 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00367943
[ 24] 0x0000000016c29681 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00366209
[ 25] 0x0000000016c29810 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00366608
[ 26] 0x0000000016ddd395 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+02151317 boost::serialization::singleton<boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,ir::IrTree> >::get_instance+00769509
[ 27] 0x0000000016ddd31e C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+02151198 boost::serialization::singleton<boost::archive::detail::pointer_oserializer<boost::archive::binaryTerm_oarchive,ir::IrTree> >::get_instance+00769390
[ 28] 0x0000000016bfdad1 C:\Program Files\MATLAB\R2016a\bin\win64\m_lxe.dll+00187089
[ 29] 0x0000000015960241 C:\Program Files\MATLAB\R2016a\bin\win64\m_interpreter.dll+00787009 inEvalCmdWithLocalReturn+00000065
[ 30] 0x00000000fb6056cd C:\Program Files\MATLAB\R2016a\bin\win64\libmwbridge.dll+00087757 mnGetPrompt+00005933
[ 31] 0x00000000fb606473 C:\Program Files\MATLAB\R2016a\bin\win64\libmwbridge.dll+00091251 mnParser+00001091
[ 32] 0x0000000015bd99d1   C:\Program Files\MATLAB\R2016a\bin\win64\mcr.dll+00235985 mcr::runtime::setInterpreterThreadToCurrent+00025585
[ 33] 0x0000000015bd8967   C:\Program Files\MATLAB\R2016a\bin\win64\mcr.dll+00231783 mcr::runtime::setInterpreterThreadToCurrent+00021383
[ 34] 0x0000000015bd89e3   C:\Program Files\MATLAB\R2016a\bin\win64\mcr.dll+00231907 mcr::runtime::setInterpreterThreadToCurrent+00021507
[ 35] 0x0000000015bd92d1   C:\Program Files\MATLAB\R2016a\bin\win64\mcr.dll+00234193 mcr::runtime::setInterpreterThreadToCurrent+00023793
[ 36] 0x00000000fd01ea57   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00584279 iqm::UserEvalPlugin::pre+00030535
[ 37] 0x00000000fd02b3ac   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00635820 iqm::UserEvalPlugin::pre+00082076
[ 38] 0x00000000fd018bf0   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00560112 iqm::UserEvalPlugin::pre+00006368
[ 39] 0x00000000fd02ddaa   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00646570 iqm::UserEvalPlugin::pre+00092826
[ 40] 0x00000000fcffbd07   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00441607 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000727
[ 41] 0x00000000fcffc35f   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00443231 iqm::PackagedTaskPlugin::execute+00000575
[ 42] 0x00000000fcffbd79   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00441721 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000841
[ 43] 0x00000000fcffc1d4   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00442836 iqm::PackagedTaskPlugin::execute+00000180
[ 44] 0x0000000015beb4a5   C:\Program Files\MATLAB\R2016a\bin\win64\mcr.dll+00308389 mcrRegisterExternalFunction+00024629
[ 45] 0x00000000fcfd62ea   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00287466 iqm::Iqm::setupIqmFcnPtrs+00069674
[ 46] 0x00000000fcfd61d7   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00287191 iqm::Iqm::setupIqmFcnPtrs+00069399
[ 47] 0x00000000fcfbbae1   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00178913 iqm::Iqm::deliver+00003409
[ 48] 0x00000000fcfbc9df   C:\Program Files\MATLAB\R2016a\bin\win64\iqm.dll+00182751 iqm::Iqm::deliver+00007247
[ 49] 0x00000001001a14d3 C:\Program Files\MATLAB\R2016a\bin\win64\libmwservices.dll+01774803 services::system_events::PpeDispatchHook::dispatchOne+00031459
[ 50] 0x00000001001ae933 C:\Program Files\MATLAB\R2016a\bin\win64\libmwservices.dll+01829171 sysq::addProcessPendingEventsUnitTestHook+00005491
[ 51] 0x00000001001aeb10 C:\Program Files\MATLAB\R2016a\bin\win64\libmwservices.dll+01829648 sysq::addProcessPendingEventsUnitTestHook+00005968
[ 52] 0x00000001001b0665 C:\Program Files\MATLAB\R2016a\bin\win64\libmwservices.dll+01836645 sysq::getCondition+00003813
[ 53] 0x00000001001b2422 C:\Program Files\MATLAB\R2016a\bin\win64\libmwservices.dll+01844258 svWS_ProcessPendingEvents+00000162
[ 54] 0x0000000015bd9d0d   C:\Program Files\MATLAB\R2016a\bin\win64\mcr.dll+00236813 mcr::runtime::setInterpreterThreadToCurrent+00026413
[ 55] 0x0000000015bda3fa   C:\Program Files\MATLAB\R2016a\bin\win64\mcr.dll+00238586 mcr::runtime::setInterpreterThreadToCurrent+00028186
[ 56] 0x0000000015bd1a05   C:\Program Files\MATLAB\R2016a\bin\win64\mcr.dll+00203269 mcr_process_events+00008629
[ 57] 0x0000000015bd3462   C:\Program Files\MATLAB\R2016a\bin\win64\mcr.dll+00210018 mcr_process_events+00015378
[ 58] 0x0000000013ac93be C:\Program Files\MATLAB\R2016a\bin\win64\MVMLocal.dll+00234430 mvm_server::inproc::LocalFactory::terminate+00071182
[ 59] 0x00000000fa93cd89   C:\Program Files\MATLAB\R2016a\bin\win64\mvm.dll+01101193 mvm::detail::initLocalMvmHack+00000521
[ 60] 0x00000000fa93d355   C:\Program Files\MATLAB\R2016a\bin\win64\mvm.dll+01102677 mvm::detail::SessionImpl::privateSession+00000373
[ 61] 0x00000000fa93d561   C:\Program Files\MATLAB\R2016a\bin\win64\mvm.dll+01103201 mvm::detail::SessionImpl::privateSession+00000897
[ 62] 0x0000000140006fd5 C:\Program Files\MATLAB\R2016a\bin\win64\MATLAB.exe+00028629
[ 63] 0x0000000140007661 C:\Program Files\MATLAB\R2016a\bin\win64\MATLAB.exe+00030305
[ 64] 0x00007ffb3b79ef44                   C:\WINDOWS\System32\KERNEL32.DLL+00061252 BaseThreadInitThunk+00000020
[ 65] 0x00007ffb3bfdddd1                      C:\WINDOWS\SYSTEM32\ntdll.dll+00450001 RtlUserThreadStart+00000033

This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.

If this problem is reproducible, please submit a Service Request via:
    http://www.mathworks.com/support/contact_us/

A technical support engineer might contact you with further information.

Thank you for your help.
musm commented 7 years ago

Any tips here? I really don't understand why it's crashing matlab so bad. jlcall used to work back in v0.4. Pretty bummed out I can't use it anymore since I just came across work where I would love to use it.

twadleigh commented 7 years ago

What code were you trying to invoke when this happened?

musm commented 7 years ago

I cloned again the rebranding branch and tried to build again


>> Jl.build
The path of the Julia configuration script is C:\Julia\julia-0.5-latest\share\julia\julia-config.jl
Building with 'Microsoft Visual C++ 2015 Professional'.
MEX completed successfully.
Ensuring the MATLAB package is installed...
INFO: Nothing to be done
Ensuring the MATLAB package is on master...
INFO: Checking out MATLAB master...
INFO: Pulling MATLAB latest master...
INFO: No packages to install, update or remove
Is the boot file loadable without error?
Severe:
The program '[3256] C:\Julia\julia-0.5-latest\bin\julia.exe: Native' has exited with code 1 (0x1).
Internal Error: A primary message table for module 77 was already registered with a differing collection of error messages.Error using Jl.build (line 157)
Assertion failed.
musm commented 7 years ago

I keep getting: Internal Error: A primary message table for module 77 was already registered with a differing collection of error messages.Severe: when I try to build mexjulia (note :I'm executing Jl.configure; Jl.build)

what works I commented out % assert(exit_code == 0); on line 157. Then Jl.build

And then tried the examples, which all seem to be working....


It's super mysterious what is going on with the error Internal Error: A primary message table for module 77 was already registered with a differing collection of error messages.Severe:

Which I have been able to reproduce using MATLAB.jl several times in different contexts.


However, since mexjulia seems to be working after commenting out the troublesome assertion, I guess I can't complain since it now at least works.

Maybe I should download the new matlab and test if i still get the error.

twadleigh commented 7 years ago

If you make any headway on this, I'd appreciate hearing about it. Also, you mention you've been able to duplicate it with MATLAB.jl a few ways. Would you mind sharing some of those? I'd like to be able to reproduce it myself, if I can.

musm commented 7 years ago

I just installed matlab 2016b, same problem

Well Pkg.test("MATLAB") leads to the mysterious module 77 was already registered error.

I can get mexjulia to work despite this error by commenting out the assertion on line 157.

INFO: No packages to install, update or remove
Is the boot file loadable without error?
Severe:
The program '[14992] C:\Julia\julia-0.5-latest\bin\julia.exe: Native' has exited with code 1 (0x1).
Internal Error: A primary message table for module 77 was already registered with a differing collection of error messages.Yes.
Is C:\Users\Mus\Documents\MATLAB\mexjulia on the MATLAB path?
Yes.
musm commented 7 years ago

The only error I now get is:

The program '[8856] C:\Julia\julia-0.5-latest\bin\julia.exe: Native' has exited with code 1 (0x1).
Internal Error: A primary message table for module 77 was already registered with a differing collection of error messages.Error using Jl.build (line 157)
Assertion failed.

This is the famous module 77 error.

See: https://www.mathworks.com/matlabcentral/answers/305877-what-is-the-primary-message-table-for-module-77

Is mexjulia calling Pkg.test("MATLAB") ?

musm commented 7 years ago

After my updates to MATLAB.jl I this is no longer a problem.