vistalab / vistasoft

VISTASOFT is the main software repository of the VISTA lab at Stanford University.
http://vistalab.stanford.edu
148 stars 142 forks source link

Crash when loading dt6 file on Windows 10, MATLAB 2017a #279

Open jonclayden opened 6 years ago

jonclayden commented 6 years ago

Thanks for making VISTASOFT available to the community. I find mrDiffusion very easy to use, and I'm trying to use it for demonstration in my teaching.

However, when I load my dt6 file (or even the one from the example dataset) from the file menu in dtiFiberUI, I'm seeing persistent MATLAB crashes. This is on my university's managed installation of Windows 10 Enterprise with MATLAB 2017a. Switching between SPM12 and SPM8 makes no difference.

The crash logs aren't very informative (example below), and I initially thought it was a bug in MATLAB itself, but when I step through the code I see the crash at this line, which makes me wonder if the mex version of dtiSplitTensor is the cause. Unfortunately I can't recompile the source files because the installation does not include the compiler toolchain.

Is this likely to be the issue? Are there any incompatibilities that you know of that might underlie this? Thanks in advance.

------------------------------------------------------------------------
          Access violation detected at Wed Feb 07 10:56:55 2018
------------------------------------------------------------------------

Configuration:
  Crash Decoding      : Disabled - No sandbox or build area path
  Crash Mode          : continue (default)
  Current Graphics Driver: Unknown hardware 
  Default Encoding    : windows-1252
  Deployed            : false
  Graphics card 1     : Intel Corporation ( 0x8086 ) Intel(R) HD Graphics 630 Version 21.20.16.4574
  MATLAB Architecture : win64
  MATLAB Root         : C:\Program Files\MATLAB\R2017a
  MATLAB Version      : 9.2.0.538062 (R2017a)
  OpenGL              : hardware
  Operating System    : Microsoft Windows 10 Enterprise
  Processor ID        : x86 Family 6 Model 158 Stepping 9, 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 14393)

Fault Count: 3

Abnormal termination:
Access violation

Register State (from fault):
  RAX = 0000000020000000  RBX = 0000000020000000
  RCX = 0000000020000001  RDX = 000000000000004d
  RSP = 00000000cf72f7e0  RBP = 0000000b043f5b48
  RSI = 0000000000000000  RDI = 0000000100000003

   R8 = 0000000020000000   R9 = 0000000b043f5b48
  R10 = 0000000000000000  R11 = 0000000020000000
  R12 = 00000000043f59b0  R13 = 00000000043f5538
  R14 = 00000000cf72fa58  R15 = 0000000800000018

  RIP = 00000000b92b3ea2  EFL = 00010246

   CS = 0033   FS = 0053   GS = 002b

Stack Trace (from fault):
[  0] 0x00000000b92b3ea2   C:\Program Files\MATLAB\R2017a\bin\win64\mkl.dll+19676834 XERBLA+13995458
[  1] 0x00000000b8ba2592   C:\Program Files\MATLAB\R2017a\bin\win64\mkl.dll+12264850 XERBLA+06583474
[  2] 0x00000000b836816c   C:\Program Files\MATLAB\R2017a\bin\win64\mkl.dll+03637612 mkl_cbwr_set+00805004
[  3] 0x00007ff9cfa236cc C:\Program Files\MATLAB\R2017a\bin\win64\libiomp5md.dll+00603852 _kmp_invoke_microtask+00000140
[  4] 0x00007ff9cf9e8cc3 C:\Program Files\MATLAB\R2017a\bin\win64\libiomp5md.dll+00363715 _kmp_acquire_nested_drdpa_lock+00043875
[  5] 0x00007ff9cf9e7ce4 C:\Program Files\MATLAB\R2017a\bin\win64\libiomp5md.dll+00359652 _kmp_acquire_nested_drdpa_lock+00039812
[  6] 0x00007ff9cfa2625e C:\Program Files\MATLAB\R2017a\bin\win64\libiomp5md.dll+00615006 _kmp_launch_worker+00000446
[  7] 0x00007ff9f2e68364                   C:\WINDOWS\System32\KERNEL32.DLL+00033636 BaseThreadInitThunk+00000020
[  8] 0x00007ff9f35b7091                      C:\WINDOWS\SYSTEM32\ntdll.dll+00422033 RtlUserThreadStart+00000033

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.
wandell commented 6 years ago

Others can help more than me, but please note: The c-code is in mrDiffusion/src/dtiSplitTensor.c

There is also a routine that compiles mex functions (but I forget which one). A good step would be to find the routine (mexcompile? makemex?) and see if you can create the mex file on your operating system and version of Matlab.

jonclayden commented 6 years ago

Thanks. I did try that, but the compilation failed, probably due to a problem with the system configuration or a lack of suitable compilers. For the time being I’m working around it by deleting the Win64 mex file and falling back on the slower interpreted version of this function, but if I can get the recompilation to work I’ll post an update.

jonclayden commented 6 years ago

To follow up as promised: I couldn't get dtiCompileMex to work on this platform, but after rebuilding dtiSplitTensor.c by hand using mex, and loading the dt6 file again, I see a new error:

An error occurred in mrDiffusion:
Tensor data must be a real XxYxZx6xN array (ie. 6 elements per voxel).
Thrown in:
[...]\vistasoft\mrDiffusion\file\dt6\dtiLoadDt6Gui.m line 69

Mathworks Technical Support encountered the same error. (I had a ticket open with them as I initially thought the crash was from MATLAB itself.)

To reiterate, the interpreted MATLAB version of this function works as expected, without errors, although of course it is slower.

ec3233 commented 6 years ago

Hello! Did you ever solve the issue that caused the new error? I've been trying to use MrDiffusion and have been encountering the same problem.

jonclayden commented 6 years ago

@rexscience No, I just reverted to the interpreted version of the function. I only use Windows when teaching, and speed isn't critical in that context, so the interpreted version was fine for my purposes.

airab commented 6 years ago

I have the same problem. Using the dtiSplitTensor complied on my old computer (windows 8, matlab 2012) works most of the time anyway - I couldn't get the mesh to work on MATLAB 2017 and so installed MATLAB 2012....

I'll be glad to hear f you find a better solution

Dongcui763 commented 2 years ago

I've encountered the same problem on Windows 10, MATLAB 2017b. The MATLAB crashes with the original dtiSplitTensor.mexw64. And it throws out an error relating to data size and type saying that Tensor data must be a real XxYxZx6xN array when utilizing the locally mexified dtiSplitTensor.mexw64. Any updates on the solutions?

iPsych commented 2 years ago

Do people still encounter this issue? I digged a bit, and it seems the error happens in the dtiSplitTensor.c. In matlab, the tensor data XxYxZx6x1 is treated same as XxYxZx6. (Maybe order version of Matlab treat it difference.) So, the dtiSplitTensor.m works just fine, after deleting dtiSplitTensor.mexci64 (or dtiSplitTensor.mexw64). But it's EXTREMLY slow, so almost impossible to use.

@Dongcui763 In my case, manually, re-compile with below code worked. mex -v -compatibleArrayDims dtiSplitTensor.c

Dongcui763 commented 2 years ago

@iPsych Thanks for your reply. It really helps me a lot. The dtiSplitTensor.mexw64 generated from your example code works for me. It turns out that the mex option -compatibleArrayDims has been missed out during my previous re-compilations.