Mrview segmentation fault: invalid memory access


#1

Hi everyone, I’m unsure where this should be posted so apologies in advance.

Anyways, simply trying to open a DICOM series with mrview causes this failure. The following is the -debug output.

mrview: [DEBUG] No config file found at "/etc/mrtrix.conf"
mrview: [DEBUG] No config file found at "~/.mrtrix.conf"
mrview: [INFO] GL renderer:  GeForce GTX 285/PCIe/SSE2
mrview: [INFO] GL version:   3.3.0 NVIDIA 340.104
mrview: [INFO] GL vendor:    NVIDIA Corporation
mrview: [DEBUG] loading font into OpenGL texture...
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec2 pos;
layout(location = 1) in vec2 font_pos;
uniform float scale_x;
uniform float scale_y;
out vec2 tex_coord;
void main () {
  gl_Position = vec4 (pos[0]*scale_x-1.0, pos[1]*scale_y-1.0, 0.0, 1.0);
  tex_coord = font_pos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
in vec2 tex_coord;
uniform sampler2D sampler;
uniform float red, green, blue;
out vec4 color;
void main () {
  color.ra = texture (sampler, tex_coord).rg;
  color.rgb = color.r * vec3 (red, green, blue);
}

mrview: [DEBUG] font loaded
mrview: [INFO] opening image "~/Ser5"...
mrview: [DEBUG] memory-mapping file "~/Ser5/E7037S5I418.MR.dcm"...
mrview: [DEBUG] file "~/Ser5/E7037S5I418.MR.dcm" mapped at 0x7f1029403000, size 145404 (read-only)
mrview: [INFO] initialising DICOM dictionary

mrview: [SYSTEM FATAL CODE: SIGSEGV (11)] Segmentation fault: Invalid memory access

I had zero problems configuring or installing the software, however a few warnings did appear during CC stages, but no errors. I’m not sure what I could be doing wrong since it’s just a simple file open.

Any help is much appreciated!
Thank-you.


#2

OK, that’s not cool… This looks similar to issues we had earlier, due to incompatibilities with Eigen 3.3. But these have been resolved for some time, and should no longer happen with any recent version of MRtrix3. So let’s rule that out first: what does this report:

mrview -version

You’d need version 3.0_RC1 or later to ensure that’s not the issue. If you’re running an old version, try updating first, see if that fixes the issue:

git checkout master
git pull
./configure
./build

Otherwise, I suspect the crash happens in the image loading backend, so you’d see it with a simple

mrinfo data.mif

If that doesn’t crash, try

mrstats data.mif

If one of the above crashes, that would already give us a pretty good idea where the problem might be…


#3

Say, this reminds me of something that I once thought of: would it be useful to have any command run with -debug also output the version automatically? It’s not the first time I see a user report a debug output, only to have to follow up with a version request.


#4

Yep, I had the exact same thought myself… :+1:


#5
mrview -version
== mrview 3.0_RC2-73-gf4d3e52c ==
64 bit release version, built Oct 30 2017, using Eigen 3.3.3
Author(s): J-Donald Tournier (jdtournier@gmail.com), Dave Raffelt (david.raffelt@florey.edu.au), Robert E. Smith (robert.smith@florey.edu.au), Rami Tabbara (rami.tabbara@florey.edu.au), Max Pietsch (maximilian.pietsch@kcl.ac.uk), Thijs Dhollander (thijs.dhollander@gmail.com)
Copyright (c) 2008-2017 the MRtrix3 contributors.

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, you can obtain one at http://mozilla.org/MPL/2.0/.

MRtrix is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

For more details, see http://www.mrtrix.org/.

As for the other two I don’t have a .mif file to open. I can open up a NIFTI file, but still I cannot import any DICOM series.

Maybe it’s worth noting that the same segmentation fault: invalid memory access appears if I try to run mrconvert on a DICOM series as well. That seems to be where the issue is located.


#6

Ok, this is a recent version, and as I suspected, it looks like the issue lies within the image handling backend somewhere, since mrconvert also crashes out. Any chance you could send me the problematic dataset?


#7

If you’re feeling adventurous, instructions for providing more comprehensive debugging information (which are probably the first steps that @jdtournier will be performing if provided with the data) are here.


#8
(gdb) r
Starting program: ~/src/mrtrix3/bin/mrview -debug
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
mrview: [DEBUG] No config file found at "/etc/mrtrix.conf"
mrview: [DEBUG] No config file found at "~/.mrtrix.conf"
mrview: [INFO] GL renderer:  GeForce GTX 1050 Ti/PCIe/SSE2
mrview: [INFO] GL version:   3.3.0 NVIDIA 375.82
mrview: [INFO] GL vendor:    NVIDIA Corporation
mrview: [DEBUG] loading font into OpenGL texture...
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec2 pos;
layout(location = 1) in vec2 font_pos;
uniform float scale_x;
uniform float scale_y;
out vec2 tex_coord;
void main () {
  gl_Position = vec4 (pos[0]*scale_x-1.0, pos[1]*scale_y-1.0, 0.0, 1.0);
  tex_coord = font_pos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
in vec2 tex_coord;
uniform sampler2D sampler;
uniform float red, green, blue;
out vec4 color;
void main () {
  color.ra = texture (sampler, tex_coord).rg;
  color.rgb = color.r * vec3 (red, green, blue);
}

mrview: [DEBUG] font loaded
[New Thread 0x7fffddd79700 (LWP 9545)]
[New Thread 0x7fffdd578700 (LWP 9546)]
[New Thread 0x7fffdcb43700 (LWP 9547)]
[New Thread 0x7fffcffff700 (LWP 9548)]
[New Thread 0x7fffcf38d700 (LWP 9549)]
[Thread 0x7fffdcb43700 (LWP 9547) exited]
[Thread 0x7fffcffff700 (LWP 9548) exited]
[New Thread 0x7fffcffff700 (LWP 9550)]
[New Thread 0x7fffdcb43700 (LWP 9551)]
[New Thread 0x7fffceb8c700 (LWP 9552)]
[New Thread 0x7fffce38b700 (LWP 9553)]
[Thread 0x7fffceb8c700 (LWP 9552) exited]
[Thread 0x7fffce38b700 (LWP 9553) exited]
[Thread 0x7fffdcb43700 (LWP 9551) exited]
[Thread 0x7fffcf38d700 (LWP 9549) exited]
[New Thread 0x7fffcf38d700 (LWP 9561)]
[Thread 0x7fffcffff700 (LWP 9550) exited]
[New Thread 0x7fffcffff700 (LWP 9562)]
[Thread 0x7fffcf38d700 (LWP 9561) exited]
[New Thread 0x7fffcf38d700 (LWP 9564)]
[Thread 0x7fffcffff700 (LWP 9562) exited]
mrview: [INFO] opening image "~/phd/experiments/maps/exam_5878"...
mrview: [DEBUG] memory-mapping file "~/exam_5878/Ser1/E5878S1I027.MR.dcm"...
mrview: [DEBUG] file "~/exam_5878/Ser1/E5878S1I027.MR.dcm" mapped at 0x7fffdc04b000, size 537914 (read-only)
/usr/include/c++/7/debug/vector:417:
Error: attempt to subscript container with out-of-bounds index 0, but 
container only holds 0 elements.

Objects involved in the operation:
    sequence "this" @ 0x0x7fffffff9f90 {
      type = std::__debug::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >;
    }

Thread 1 "mrview" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

#9

Ok, there’s a bug in there somewhere. But it’s only triggered by your data, so there’s something about it that breaks our assumptions. We’d get more information about exactly where the problem occurs if you could type bt after that crash within thegdb session. But ultimately, I think I’ll need access to your data so I can reproduce and fix this…