Why does MATLAB crash when trying to execute a Python script with "execfile" function
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 9 Apr. 2018
Beantwortet: MathWorks Support Team
am 9 Mai 2018
When trying to execute any python script ( for example "foo.py") from MATLAB by using the following command:
>> py.execfile("foo.py")
MATLAB crashes with the following stack trace:
Stack Trace (from fault):
[ 0] 0x000000002c3713d7 C:\windows\system32\python27.dll+00660439 PyDict_GetItem+00000007
[ 1] 0x000000002c373673 C:\windows\system32\python27.dll+00669299 PyDict_GetItemString+00000051
[ 2] 0x000000002c3d9c39 C:\windows\system32\python27.dll+01088569 PyAST_FromNode+00004313
[ 3] 0x000000002c390959 C:\windows\system32\python27.dll+00788825 PyCFunction_Call+00000105
[ 4] 0x000000002c35adf5 C:\windows\system32\python27.dll+00568821 PyObject_Call+00000101
[ 5] 0x000000002c20529f bin\win64\pycli.dll+00086687
[ 6] 0x000000002c2019ab bin\win64\pycli.dll+00072107
[ 7] 0x000000002c228b8b bin\win64\pycli.dll+00232331
[ 8] 0x0000000011364e82 bin\win64\pgo\mcos_impl.dll+00347778
[ 9] 0x0000000011364727 bin\win64\pgo\mcos_impl.dll+00345895
[ 10] 0x0000000011364151 bin\win64\pgo\mcos_impl.dll+00344401
[ 11] 0x0000000011363a50 bin\win64\pgo\mcos_impl.dll+00342608
[ 12] 0x000000001134afa9 bin\win64\pgo\mcos_impl.dll+00241577
[ 13] 0x000000001134ae16 bin\win64\pgo\mcos_impl.dll+00241174
[ 14] 0x000000000c7f9be1 bin\win64\pgo\m_dispatcher.dll+00039905 Mfh_MATLAB_fn::dispatch_fh+00000641
[ 15] 0x00000000113481e4 bin\win64\pgo\mcos_impl.dll+00229860
[ 16] 0x000000000c7f98fd bin\win64\pgo\m_dispatcher.dll+00039165 Mfunction_handle::dispatch+00001037
[ 17] 0x0000000012298cea bin\win64\pgo\m_lxe.dll+00232682
[ 18] 0x00000000123d88c6 bin\win64\pgo\m_lxe.dll+01542342 boost::archive::detail::iserializer<boost::archive::binaryTerm_iarchive,std::vector<MathWorks::lxe::MatlabIrTree * __ptr64,std::allocator<MathWorks::lxe::MatlabIrTree * __ptr64> > >::load_object_data+00040150
[ 19] 0x00000000123d8a7b bin\win64\pgo\m_lxe.dll+01542779 boost::archive::detail::iserializer<boost::archive::binaryTerm_iarchive,std::vector<MathWorks::lxe::MatlabIrTree * __ptr64,std::allocator<MathWorks::lxe::MatlabIrTree * __ptr64> > >::load_object_data+00040587
[ 20] 0x00000000123d89de bin\win64\pgo\m_lxe.dll+01542622 boost::archive::detail::iserializer<boost::archive::binaryTerm_iarchive,std::vector<MathWorks::lxe::MatlabIrTree * __ptr64,std::allocator<MathWorks::lxe::MatlabIrTree * __ptr64> > >::load_object_data+00040430
[ 21] 0x00000000122826c9 bin\win64\pgo\m_lxe.dll+00141001
[ 22] 0x00000000122832f3 bin\win64\pgo\m_lxe.dll+00144115
[ 23] 0x000000001228474c bin\win64\pgo\m_lxe.dll+00149324
[ 24] 0x0000000012285288 bin\win64\pgo\m_lxe.dll+00152200
[ 25] 0x000000001228498f bin\win64\pgo\m_lxe.dll+00149903
[ 26] 0x0000000012278c4b bin\win64\pgo\m_lxe.dll+00101451
[ 27] 0x000000001228004a bin\win64\pgo\m_lxe.dll+00131146
[ 28] 0x000000001227f7d0 bin\win64\pgo\m_lxe.dll+00128976
[ 29] 0x00000000123d5d0f bin\win64\pgo\m_lxe.dll+01531151 boost::archive::detail::iserializer<boost::archive::binaryTerm_iarchive,std::vector<MathWorks::lxe::MatlabIrTree * __ptr64,std::allocator<MathWorks::lxe::MatlabIrTree * __ptr64> > >::load_object_data+00028959
[ 30] 0x00000000123d52d3 bin\win64\pgo\m_lxe.dll+01528531 boost::archive::detail::iserializer<boost::archive::binaryTerm_iarchive,std::vector<MathWorks::lxe::MatlabIrTree * __ptr64,std::allocator<MathWorks::lxe::MatlabIrTree * __ptr64> > >::load_object_data+00026339
[ 31] 0x00000000123d51b9 bin\win64\pgo\m_lxe.dll+01528249 boost::archive::detail::iserializer<boost::archive::binaryTerm_iarchive,std::vector<MathWorks::lxe::MatlabIrTree * __ptr64,std::allocator<MathWorks::lxe::MatlabIrTree * __ptr64> > >::load_object_data+00026057
[ 32] 0x0000000012460ea9 bin\win64\pgo\m_lxe.dll+02100905 boost::archive::detail::iserializer<boost::archive::binaryTerm_iarchive,MathWorks::lxe::MatlabIrTree>::load_object_data+00015609
[ 33] 0x0000000012460e32 bin\win64\pgo\m_lxe.dll+02100786 boost::archive::detail::iserializer<boost::archive::binaryTerm_iarchive,MathWorks::lxe::MatlabIrTree>::load_object_data+00015490
[ 34] 0x00000000123d30dd bin\win64\pgo\m_lxe.dll+01519837 boost::archive::detail::iserializer<boost::archive::binaryTerm_iarchive,std::vector<MathWorks::lxe::MatlabIrTree * __ptr64,std::allocator<MathWorks::lxe::MatlabIrTree * __ptr64> > >::load_object_data+00017645
[ 35] 0x000000000cfad0cb bin\win64\pgo\m_interpreter.dll+00446667 inEvalCmdWithLocalReturn+00000063
[ 36] 0x00000000fb60923d bin\win64\libmwbridge.dll+00102973 mnGetPrompt+00013165
[ 37] 0x00000000fb60a2f3 bin\win64\libmwbridge.dll+00107251 mnParser+00001107
[ 38] 0x000000000dc375f1 bin\win64\mcr.dll+00226801 mcr::runtime::setInterpreterThreadSingletonToCurrent+00027889
[ 39] 0x000000000dc364e7 bin\win64\mcr.dll+00222439 mcr::runtime::setInterpreterThreadSingletonToCurrent+00023527
[ 40] 0x000000000dc36563 bin\win64\mcr.dll+00222563 mcr::runtime::setInterpreterThreadSingletonToCurrent+00023651
[ 41] 0x000000000dc36e81 bin\win64\mcr.dll+00224897 mcr::runtime::setInterpreterThreadSingletonToCurrent+00025985
[ 42] 0x00000000fd01e647 bin\win64\iqm.dll+00583239 iqm::UserEvalPlugin::pre+00030695
[ 43] 0x00000000fd02af8c bin\win64\iqm.dll+00634764 iqm::UserEvalPlugin::pre+00082220
[ 44] 0x00000000fd018770 bin\win64\iqm.dll+00558960 iqm::UserEvalPlugin::pre+00006416
[ 45] 0x00000000fd02de9a bin\win64\iqm.dll+00646810 iqm::UserEvalPlugin::pre+00094266
[ 46] 0x00000000fcffad17 bin\win64\iqm.dll+00437527 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000727
[ 47] 0x00000000fcffb36f bin\win64\iqm.dll+00439151 iqm::PackagedTaskPlugin::execute+00000575
[ 48] 0x00000000fcffad89 bin\win64\iqm.dll+00437641 iqm::PackagedTaskPlugin::PackagedTaskPlugin+00000841
[ 49] 0x00000000fcffb1e4 bin\win64\iqm.dll+00438756 iqm::PackagedTaskPlugin::execute+00000180
[ 50] 0x00000000fcfd111a bin\win64\iqm.dll+00266522 iqm::Iqm::setupIqmFcnPtrs+00072250
[ 51] 0x00000000fcfd0ff3 bin\win64\iqm.dll+00266227 iqm::Iqm::setupIqmFcnPtrs+00071955
[ 52] 0x00000000fcfb7b95 bin\win64\iqm.dll+00162709 iqm::Iqm::deliver+00003349
[ 53] 0x00000000fcfb8815 bin\win64\iqm.dll+00165909 iqm::Iqm::deliver+00006549
[ 54] 0x0000000004756383 bin\win64\libmwservices.dll+01074051 services::system_events::PpeDispatchHook::dispatchOne+00019811
[ 55] 0x000000000475abe3 bin\win64\libmwservices.dll+01092579 sysq::addProcessPendingEventsUnitTestHook+00002099
[ 56] 0x000000000475add0 bin\win64\libmwservices.dll+01093072 sysq::addProcessPendingEventsUnitTestHook+00002592
[ 57] 0x000000000475c095 bin\win64\libmwservices.dll+01097877 sysq::getCondition+00003269
[ 58] 0x000000000475cf8f bin\win64\libmwservices.dll+01101711 svWS_ProcessPendingEvents+00000287
[ 59] 0x000000000dc3795e bin\win64\mcr.dll+00227678 mcr::runtime::setInterpreterThreadSingletonToCurrent+00028766
[ 60] 0x000000000dc38046 bin\win64\mcr.dll+00229446 mcr::runtime::setInterpreterThreadSingletonToCurrent+00030534
[ 61] 0x000000000dc2e832 bin\win64\mcr.dll+00190514 mcr_process_events+00010210
[ 62] 0x000000000dc30782 bin\win64\mcr.dll+00198530 mcr_process_events+00018226
[ 63] 0x000000000c76c21e bin\win64\MVMLocal.dll+00246302 mvm_server::inproc::LocalFactory::terminate+00073982
[ 64] 0x00000000fa95a3d9 bin\win64\mvm.dll+01221593 mvm::detail::initLocalMvmHack+00000521
[ 65] 0x00000000fa95ab25 bin\win64\mvm.dll+01223461 mvm::detail::SessionImpl::privateSession+00000533
[ 66] 0x00000000fa95ad31 bin\win64\mvm.dll+01223985 mvm::detail::SessionImpl::privateSession+00001057
[ 67] 0x0000000140006fd5 bin\win64\MATLAB.exe+00028629
[ 68] 0x0000000140007661 bin\win64\MATLAB.exe+00030305
[ 69] 0x00000000772959cd C:\windows\system32\kernel32.dll+00088525 BaseThreadInitThunk+00000013
[ 70] 0x00000000774f383d C:\windows\SYSTEM32\ntdll.dll+00342077 RtlUserThreadStart+00000029
Akzeptierte Antwort
MathWorks Support Team
am 9 Apr. 2018
The observed crash is a known Python bug in Python versions which support the "execfile" function. The reason for this bug seems to be because of the optional second parameter of the "execfile" function being empty. Please refer to the following link for the Python bug report:
One of the workarounds to avoid the crash is to add a dummy variable as a second parameter to "execfile" function. It can be done by changing the command to execute the Python file from:
>> py.execfile('foo.py') % foo.py can be any python script
to
>> py.execfile('foo.py',struct) % foo.py can be any python script
where the second parameter "struct" creates an empty struct variable and we pass it to the "execfile" function to avoid the crash. Since the bug is in the Python source code, kindly follow the bug report link above for updates related to the bug.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!