Why does MATLAB crash in textstream.dll when calling 'readtable' on several CSV files?

I am running a MATLAB program where I am calling 'readtable' on several CSV files. MATLAB R2017b crashes with one of the following stack traces:
Stack Trace (from fault):
[ 0] 0x00000000d0ab218c bin\win64\textstream.dll+00205196 textio::Strategy::inspect_datatypes+00000428
[ 1] 0x00000000d0ab4708 bin\win64\textstream.dll+00214792 textio::Strategy::valuation+00000904
[ 2] 0x00000000d0ab7a71 bin\win64\textstream.dll+00227953 textio::detection::StrategySelector::~StrategySelector+00006609
[ 3] 0x00000000d0ab86fb bin\win64\textstream.dll+00231163 textio::detection::StrategySelector::delimiters+00001931
[ 4] 0x00000000d0ab9020 bin\win64\textstream.dll+00233504 textio::detection::StrategySelector::pick_strategy+00000560
[ 5] 0x00000000d09e8c7e bin\win64\textio_mli.dll+01346686
[ 6] 0x00000000d09e9012 bin\win64\textio_mli.dll+01347602
[ 7] 0x00000000153c4b52 bin\win64\mcos.dll+00084818 mcos::COSPackage::getPackageInterface+00000322
[ 8] 0x000000001e54705d bin\win64\pgo\mcos_impl.dll+00553053
Stack Trace (from fault):
[  0] 0x00000000a1e8218c    bin\win64\textstream.dll+00205196 textio::Strategy::inspect_datatypes+00000428
[  1] 0x00000000a1e84708    bin\win64\textstream.dll+00214792 textio::Strategy::valuation+00000904
[  2] 0x00000000a1d98d73    bin\win64\textio_mli.dll+01346931
[  3] 0x00000000a1d99012    bin\win64\textio_mli.dll+01347602
[  4] 0x00000000152b4b52    bin\win64\mcos.dll+00084818 mcos::COSPackage::getPackageInterface+00000322
[  5] 0x000000001e52705d    bin\win64\pgo\mcos_impl.dll+00553053

 Accepted Answer

This is a bug in R2017b that concerns the CSV file detection, which has been fixed in MATLAB R2018a and later releases.
Workaround for R2017a:
If all the CSV files have the same format, calling 'readtable' with saved import options might avoid the crash, and probably show some performance improvements as well.
Do this once:
>>opts = detectImportOptions(file) % assuming this doesn't crash
>>% make any modifications
>>save('options.mat','opts') % Make sure each 'readtable'/loop/parfor worker has access to this file
In the code calling 'readtable', load the saved import options:
s = load('options.mat','opts')
T = readtable(filename,s.opts)

More Answers (0)

Categories

Products

Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!