bad_alloc error in slicerfreesurfer on 5.2.1 Linux

Hi, I have trouble using FreeSurfer Importer provided with the SlicerFreSurfer extension.

Problem: When I try to load segmentation, it cuases bad_alloc error. The error message is below.

“Slicer has caught an application error, please save your work and restart.\n\nThe application has run out of memory. Increasing swap size in system settings or adding more RAM may fix this issue.\n\nIf you have a repeatable sequence of steps that causes this message, please report the issue following instructions available at https://slicer.org\n\n\nThe message detail is:\n\nException thrown in event: std::bad_alloc”
QXcbConnection: XCB error: 3 (BadWindow), sequence: 4707, resource id: 14695233, major code: 40 (TranslateCoords), minor code: 0

  • I can load Volumes (e.g. brainmask.mgz) and Models (e.g. lh.pial) without any problem. I cannot load only Segmentations.

  • This problem occurs only in Linux version of Slicer 5.x. I tried with both 5.0.3 and 5.2.1, and got the same error.

  • My workstation has 192GB RAM. Though the error message says it has run out of memory, but I feel that is not the problem.

The result of free:

$ free -h
              total        used        free      shared  buff/cache   available
Mem:          187Gi        41Gi       138Gi       328Mi       8.3Gi       144Gi
Swap:         2.0Gi          0B       2.0Gi

I feel there may be a bug in loading segmentation in SlicerFreeSurfer. If you have any workarounds, please let me know.

My circumstance is the following;

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION=“Ubuntu 20.04.5 LTS”

$ uname -a
Linux ubuntu 5.15.0-56-generic #62~20.04.1-Ubuntu SMP Tue Nov 22 21:24:20 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Thanks for reporting this.

QXcbConnection: XCB error: 3 (BadWindow)... message is just a warning (seems to be a known Qt bug). Probably it is not the root cause of the serious std::bad_alloc error, but the QXcbConnection error may be triggered by the display of the modal error popup.

The memory allocation may fail because of the segmentation file contains some unexpected/misinterpreted content, which makes Slicer want to allocate an enormous amount of memory.

Can you share a data set that you have problem with and instructions for reproducing the issue?

Thank you for the prompt reply.

I have this problem with even “bert” data shipped with FreeSurfer 7.3.2.
(None of aseg.mgz(s) cannot be loaded)

This is what I did.

  • Copy bert to my home directory
mkdir -p ~/freesurfer/7.3.2/subjects
cp -r $FRESURFER_HOME/subjects/bert ~/freesurfer/7.3.2/subjects
  • Run Slicer

  • Modules → Utilities → FreSurferImporter

    • FreeSurfer directory: ~/freesurfer/7.3.2/subjects/bert
    • Volumes: brainmask.mgz
    • Segmentation: aseg.mgz
  • Click Load → Error

  • If I select only Volumes (brainmask.mgz) and Models (lh.pial), then it works fine.

I have no problems on Windows and macOS, so I feel something is wrong with Linux.

Thank you for your support!

Kiyotaka

I have not been able to reproduce this issue using the steps above in
the following setup:

  • OS: Ubuntu 22.04
  • Slicer version: 5.3.0-2022-12-03 (self-built)
  • Slicer revision: 31346
  • SlicerFreeSurfer: master branch

@kytk, you could give a try to the preview release (5.3.0) and see if it
works. From all the changes you could do to approach a working
environment, this is the easiest.

Thank you for checking. Now I know that something is wrong in my environment.
Though the preview release resulted in the same error, I will try to build Slicer for my environment and see if it works.

1 Like