Need help with this so much = mrview: [SYSTEM FATAL CODE: SIGSEGV (11)] Segmentation fault: Invalid memory access (prior discussions did not work))

mrview sub-01_den_preproc_unbiased.mif -overlay.load 5tt_nocoreg.mif -overlay.colourmap 2 -overlay.load 5tt_coreg.mif -overlay.colourmap 1

after running this command, it is trying to load overlays but then it shuts itself

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

df -h
Filesystem Size Used Avail Use% Mounted on
none 5.9G 4.0K 5.9G 1% /mnt/wsl
none 954G 692G 262G 73% /usr/lib/wsl/drivers
none 5.9G 0 5.9G 0% /usr/lib/modules
none 5.9G 0 5.9G 0% /usr/lib/modules/5.15.146.1-microsoft-standard-WSL2
/dev/sdc 1007G 64G 893G 7% /
none 5.9G 136K 5.9G 1% /mnt/wslg
none 5.9G 0 5.9G 0% /usr/lib/wsl/lib
rootfs 5.9G 1.9M 5.9G 1% /init
none 5.9G 968K 5.9G 1% /run
none 5.9G 0 5.9G 0% /run/lock
none 5.9G 0 5.9G 0% /run/shm
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
none 5.9G 412K 5.9G 1% /mnt/wslg/versions.txt
none 5.9G 412K 5.9G 1% /mnt/wslg/doc
overflow 47G 8.1M 47G 1% /tmp
C:\ 954G 692G 262G 73% /mnt/c
snapfuse 75M 75M 0 100% /snap/core22/1122
snapfuse 128K 128K 0 100% /snap/bare/5
snapfuse 74M 74M 0 100% /snap/core22/864
snapfuse 268M 268M 0 100% /snap/firefox/3941
snapfuse 505M 505M 0 100% /snap/gnome-42-2204/172
snapfuse 92M 92M 0 100% /snap/gtk-common-themes/1535
snapfuse 41M 41M 0 100% /snap/snapd/20290
snapfuse 40M 40M 0 100% /snap/snapd/21184
snapfuse 132M 132M 0 100% /snap/ubuntu-desktop-installer/1276
snapfuse 132M 132M 0 100% /snap/ubuntu-desktop-installer/1286

I myself mounted 50GB on tmp file. It is still giving error. What should I do in this situation. I examined prior discussions but notting helped.

Windows 11
Ubuntu 22.04

mrview works normally, but overlay command gives error

Ok, this is unlikely to have anything to do with temporary file storage – as implied in your other (presumably related) thread. It’s also very unlikely to have anything to do with raw memory storage either, since all 3 files will be accessed via memory mapping, and if there were an out-of-memory issue, I’d expect that to lead to the program being killed, without producing a segmentation fault error.

In general, a segmentation fault means some part of our code has tried to access a memory region is does not have access to – either because it is an invalid region, or because it doesn’t permission. This typically means there’s a bug in the code somewhere… But getting to the root of the problem can be difficult – there’s a whole wiki article on how to debug such problems if you have the time.

But before you do that, there are a few things you do to try to isolate the issue:

  • post the output of mrinfo on each of your input files – just so we can see how big they are and whether that might contribute to the issue.

  • run the mrview command with the -debug flag, and copy/paste the full terminal output this produces right up to the crash back on this thread. That should at least give us a hint as to where the program got to before it crashed.

  • try running mrview without command-line arguments, open your sub-01_den_preproc_unbiased.mif image using the File → open menu, then load each overlay image using the Overlay tool, then apply the desired colourmap to each. If that works without crashing, then that will give us a fairly strong hint as to where the problem might be…

  • simplify the command-line until it doesn’t crash:

    • Start by removing one of the -overlay.colourmap N options, then the other, then both.
    • If that still crashes, try also removing one of the -overlay.load image options, then the other, then both.
    • if that still crashes, then you’re left with just a straight mrview sub-01_den_preproc_unbiased.mif, which ought to work according to your post…

Hopefully that process will give us a hint as to where to look in the code for any issues that could cause such a crash…

All the best,
Donald.

mrinfo 5tt_coreg.mif

************************************************
Image name:          "5tt_coreg.mif"
************************************************
  Dimensions:        335 x 382 x 273 x 5
  Voxel size:        0.4297 x 0.4297 x 0.5 x ?
  Data strides:      [ 2 3 4 1 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:               0.9998    -0.01747  -0.0009263      -67.43
                          0.01743      0.9994    -0.03052      -94.96
                         0.001458      0.0305      0.9995      -56.18
  command_history:   mrconvert T1w.nii.gz anat.mif  (version=3.0.4-62-g325dcc12-dirty)
                     /home/emre/mrtrix3/bin/5ttgen fsl anat.mif 5tt_nocoreg.mif  (version=3.0.4-62-g325dcc12-dirty)
                     mrtransform 5tt_nocoreg.mif -linear diff2struct_mrtrix.txt -inverse 5tt_coreg.mif  (version=3.0.4-62-g325dcc12-dirty)
  comments:          TE=3.3;Time=134919.000
                     transform modified
  mrtrix_version:    3.0.4-62-g325dcc12-dirty

mrinfo 5tt_nocoreg.mif

************************************************
Image name:          "5tt_nocoreg.mif"
************************************************
  Dimensions:        335 x 382 x 273 x 5
  Voxel size:        0.4297 x 0.4297 x 0.5 x ?
  Data strides:      [ 2 3 4 1 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0      -68.21
                               -0           1           0      -97.08
                               -0           0           1      -55.57
  command_history:   mrconvert T1w.nii.gz anat.mif  (version=3.0.4-62-g325dcc12-dirty)
                     /home/emre/mrtrix3/bin/5ttgen fsl anat.mif 5tt_nocoreg.mif  (version=3.0.4-62-g325dcc12-dirty)
  comments:          TE=3.3;Time=134919.000
  mrtrix_version:    3.0.4-62-g325dcc12-dirty

mrinfo dwi_preproc_unbiased.mif

************************************************
Image name:          "dwi_preproc_unbiased.mif"
************************************************
  Dimensions:        256 x 256 x 62 x 39
  Voxel size:        1.0156 x 1.0156 x 2 x 10
  Data strides:      [ -1 2 3 4 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1    -0.00139    0.001483        -127
                          0.00156      0.9923     -0.1235      -131.7
                          -0.0013      0.1235      0.9923      -62.63
  command_history:   mrconvert dti.nii.gz raw_dwi.mif -fslgrad dti.bvec dti.bval  (version=3.0.4-62-g325dcc12-dirty)
                     dwidenoise raw_dwi.mif dwi_den.mif -noise noise_AP.mif  (version=3.0.4-62-g325dcc12-dirty)
                     mrdegibbs dwi_den.mif dwi_den_unr.mif -axes '0,2'  (version=3.0.4-62-g325dcc12-dirty)
                     /home/emre/mrtrix3/bin/dwifslpreproc dwi_den_unr.mif dwi_preproc.mif -nocleanup -pe_dir PA -rpe_none -eddy_options ' --slm=linear --data_is_shelled'  (version=3.0.4-62-g325dcc12-dirty)
                     /home/emre/mrtrix3/bin/dwibiascorrect ants dwi_preproc.mif dwi_preproc_unbiased.mif -bias bias_PA.mif  (version=3.0.4-62-g325dcc12-dirty)
  comments:          TE=1.1e+02;Time=134203.000;mb=2
  dw_scheme:         0.0,0.0,0.0,0.0
  [39 entries]       0.0,0.0,0.0,0.0
                     ...
                     -0.7027476569,-0.4814515879,0.5237844014,1000.0
                     -0.9135502072,-0.2166386931,0.3442291322,1000.0
  mrtrix_version:    3.0.4-62-g325dcc12-dirty
mrview -debug dwi_preproc_unbiased.mif -overlay.load 5tt_nocoreg.mif -
overlay.colourmap 2 -overlay.load 5tt_coreg.mif -overlay.colourmap 1

mrview: [DEBUG] No config file found at "/etc/mrtrix.conf"
mrview: [INFO] reading config file "/home/emre/.mrtrix.conf"...
mrview: [DEBUG] reading key/value file "/home/emre/.mrtrix.conf"...
mrview: [INFO] GL renderer:  llvmpipe (LLVM 15.0.7, 256 bits)
mrview: [INFO] GL version:   4.5 (Core Profile) Mesa 23.2.1-1ubuntu3.1~22.04.2
mrview: [INFO] GL vendor:    Mesa
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 "dwi_preproc_unbiased.mif"...
mrview: [DEBUG] reading key/value file "dwi_preproc_unbiased.mif"...
mrview: [DEBUG] sanitising image information...
mrview: [INFO] image "dwi_preproc_unbiased.mif" opened with dimensions 256x256x62x39, voxel spacing 1.0156000000000001x1.0156000000000001x2x10, datatype Float32LE
mrview: [DEBUG] memory-mapping file "dwi_preproc_unbiased.mif"...
mrview: [DEBUG] file "dwi_preproc_unbiased.mif" mapped at 0x7fc99637f000, size 633864192 (read-only)
mrview: [DEBUG] image "dwi_preproc_unbiased.mif" loaded
mrview: [DEBUG] image "dwi_preproc_unbiased.mif" initialised with strides = [ -1 256 65536 4063232 ], start = 255, using indirect IO
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec2 pos;
void main () {
  gl_Position = vec4 (pos, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec4 color;
void main () {
  color = vec4 (0.5, 0.5, 0.0, 1.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec3 data;
uniform float scale_x, scale_y;
out float amplitude;
void main () {
  gl_Position = vec4 (data.x*scale_x-1.0, data.y*scale_y-1.0, 0.0, 1.0);
  amplitude = data.z;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
in float amplitude;
out vec3 color;
uniform vec3 colourmap_colour;
void main () {
  color.rgb = vec3 (amplitude);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3(1.0, 1.0, 0.0);
}

mrview: [INFO] opening image "5tt_nocoreg.mif"...
mrview: [DEBUG] reading key/value file "5tt_nocoreg.mif"...
mrview: [DEBUG] sanitising image information...
mrview: [INFO] image "5tt_nocoreg.mif" opened with dimensions 335x382x273x5, voxel spacing 0.42970000000000003x0.42970000000000003x0.5xnan, datatype Float32LE
mrview: [DEBUG] memory-mapping file "5tt_nocoreg.mif"...
mrview: [DEBUG] file "5tt_nocoreg.mif" mapped at 0x7fc96c925000, size 698716200 (read-only)
mrview: [DEBUG] image "5tt_nocoreg.mif" loaded
mrview: [DEBUG] image "5tt_nocoreg.mif" initialised with strides = [ 5 1675 639850 1 ], start = 0, using indirect IO
mrview: [INFO] mrview: loading image data
mrview: [INFO] opening image "5tt_coreg.mif"...
mrview: [DEBUG] reading key/value file "5tt_coreg.mif"...
mrview: [DEBUG] sanitising image information...
mrview: [INFO] image "5tt_coreg.mif" opened with dimensions 335x382x273x5, voxel spacing 0.42970000000000003x0.42970000000000003x0.5xnan, datatype Float32LE
mrview: [DEBUG] memory-mapping file "5tt_coreg.mif"...
mrview: [DEBUG] file "5tt_coreg.mif" mapped at 0x7fc93a86c000, size 698716200 (read-only)
mrview: [DEBUG] image "5tt_coreg.mif" loaded
mrview: [DEBUG] image "5tt_coreg.mif" initialised with strides = [ 5 1675 639850 1 ], start = 0, using indirect IO
mrview: [INFO] mrview: loading image data [done]
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform float alpha_scale;
uniform float alpha_offset;
uniform float alpha;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  if (amplitude < alpha_offset) discard;
  color.a = clamp ((amplitude - alpha_offset) * alpha_scale, 0, alpha);
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = 1.0 - (vec3 (2.7213 * (1.0 - amplitude), 2.7213 * (1.0 - amplitude) - 1.0, 3.7727 * (1.0 - amplitude) - 2.7727));
}

mrview: [INFO] mrview: loading image data
mrview: [INFO] mrview: loading image data [done]
mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location = 0) in vec3 vertpos;
layout(location = 1) in vec3 texpos;
uniform mat4 MVP;
out vec3 texcoord;
void main() {
  gl_Position =  MVP * vec4 (vertpos,1);
  texcoord = texpos;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
uniform float offset;
uniform float scale;
uniform float alpha_scale;
uniform float alpha_offset;
uniform float alpha;
uniform sampler3D tex;
in vec3 texcoord;
out vec4 color;
void main() {
  if (texcoord.s < 0.0 || texcoord.s > 1.0 ||
      texcoord.t < 0.0 || texcoord.t > 1.0 ||
      texcoord.p < 0.0 || texcoord.p > 1.0) discard;
  color = texture (tex, texcoord.stp);
  float amplitude = color.r;
  if (isnan(amplitude) || isinf(amplitude)) discard;
  if (amplitude < alpha_offset) discard;
  color.a = clamp ((amplitude - alpha_offset) * alpha_scale, 0, alpha);
  amplitude = clamp ( scale * (amplitude - offset), 0.0, 1.0);
  color.rgb = vec3 (2.7213 * amplitude, 2.7213 * amplitude - 1.0, 3.7727 * amplitude - 2.7727);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec3 data;
uniform float scale_x, scale_y;
out float amplitude;
void main () {
  gl_Position = vec4 (data.x*scale_x-1.0, data.y*scale_y-1.0, 0.0, 1.0);
  amplitude = data.z;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
in float amplitude;
out vec3 color;
uniform vec3 colourmap_colour;
void main () {
  color.rgb = 1.0 - (vec3 (2.7213 * (1.0 - amplitude), 2.7213 * (1.0 - amplitude) - 1.0, 3.7727 * (1.0 - amplitude) - 2.7727));
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3(1.0, 1.0, 0.0);
}

mrview: [DEBUG] compiling OpenGL vertex shader:
#version 330 core
layout(location=0) in vec3 data;
uniform float scale_x, scale_y;
out float amplitude;
void main () {
  gl_Position = vec4 (data.x*scale_x-1.0, data.y*scale_y-1.0, 0.0, 1.0);
  amplitude = data.z;
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
in float amplitude;
out vec3 color;
uniform vec3 colourmap_colour;
void main () {
  color.rgb = vec3 (2.7213 * amplitude, 2.7213 * amplitude - 1.0, 3.7727 * amplitude - 2.7727);
}

mrview: [DEBUG] compiling OpenGL fragment shader:
#version 330 core
out vec3 color;
void main () {
  color = vec3(1.0, 1.0, 0.0);
}


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

Overlaying manually just works! Incredible, I wouldnt think that’d work

I will definitely check your debugging tutorial also, thank you very much.

I am so grateful for your help in the MRtrix community, I appreciate it

OK, I’ve been able to reproduce the issue on my own WSL2 install, and (with some fudging) on my Linux system.

Briefly, it seems the crash is triggered by the -overlay.load option, but only if the image load to GPU operation takes long enough for the progress bar to be displayed. By default, a progress bar is shown if the load takes longer than 1 second (I think…). We have had lots of issues with this progress bar ever since Qt decided to switch to OpenGL for their own rendering, as it then started to interfere with our own rendering (some discussion about that on GitHub, dating back to 2015…).

I’ll investigate further and see if there’s a simple fix we can release for this. In the meantime, you can avoid the issue by adding the -quiet option to the mrview command-line, which will suppress any progress bars from being shown in the first place…

Yeah, bar loads for 1 minute approximately and then gives crash.

Thank you very mouch Donald