From: VandeVondele Joost (joost.vandevondele_at_mat.ethz.ch)
Date: Sat May 25 2013 - 11:38:14 CDT

Loading a large cube file (Grid size: 900x900x900 (11123 MB)) leads to a crash of VMD (1.9) with the error message:

Info) Computing volume gradient map for smooth shading
terminate called after throwing an instance of 'std::bad_alloc'
  what(): std::bad_alloc
Abort

The machine has plenty of free memory (Free system memory: 113902MB), and this is the AMD64 VMD binary, so I suspect this is triggered by some intermediate 32bit integer overflow.

To facilitate reproducing this error, I have added a little script that generates a cube file of the proper size. The crash does happen with 900 points but not with 720 points per direction. Unfortunately it takes a while to read/write these cubes.

==== Error output =====
> vmd test_900.cube
Info) VMD for LINUXAMD64, version 1.9 (March 14, 2011)
Info) http://www.ks.uiuc.edu/Research/vmd/
Info) Email questions and bug reports to vmd_at_ks.uiuc.edu
Info) Please include this reference in published work using VMD:
Info) Humphrey, W., Dalke, A. and Schulten, K., `VMD - Visual
Info) Molecular Dynamics', J. Molec. Graphics 1996, 14.1, 33-38.
Info) -------------------------------------------------------------
Info) Multithreading available, 32 CPUs detected.
Info) Free system memory: 113902MB (88%)
Info) No CUDA accelerator devices available.
Warning) Detected X11 'Composite' extension: if incorrect display occurs
Warning) try disabling this optional X server feature.
Info) OpenGL renderer: GeForce GTX 460/PCIe/SSE2
Info) Features: STENCIL MSAA(16) MDE MTX NPOT PP PS
Info) GLSL rendering mode is NOT available.
Info) Textures: 2-D (16384x16384), 3-D (2048x2048x2048), Multitexture (4)
Info) Dynamically loaded 2 plugins in directory:
Info) /usr/local/lib/vmd/plugins/LINUXAMD64/molfile
Info) File loading in progress, please wait.
Info) Using plugin cube for structure file test_900.cube
cubeplugin) trying to read cube data set 0
Info) Analyzing Volume...
Info) Grid size: 900x900x900 (11123 MB)
Info) Total voxels: 729000000
Info) Min: -0.800000 Max: 1.200000 Range: 2.000000
Info) Computing volume gradient map for smooth shading
terminate called after throwing an instance of 'std::bad_alloc'
  what(): std::bad_alloc
Abort

==== Bash script to generate cube ====
# run as ./do_generate_cube > test_900.cube
# number of points (input multiplied by 6 for easier writing)
# input=150 triggers a crash, 120 not yet
input=150
n_points=$((input*6))
printf "%s\n" "Test with $n_points points in each direction"
printf "%s\n" "VMD crash test"
printf "%5d%12.6f%12.6f%12.6f\n" 8 0 0 0
printf "%5d%12.6f%12.6f%12.6f\n" $n_points 0.1 0 0
printf "%5d%12.6f%12.6f%12.6f\n" $n_points 0.0 0.1 0
printf "%5d%12.6f%12.6f%12.6f\n" $n_points 0.0 0.0 0.1
for i in 0 1 ; do
for j in 0 1 ; do
for k in 0 1 ; do
  x=$((i*n_points/10))
  y=$((j*n_points/10))
  z=$((k*n_points/10))
  printf "%5d%12.6f%12.6f%12.6f%12.6f\n" 2 0 $x $y $z
done
done
done
echo "go" | \
 awk -v n=$n_points '{ \
   for(i=1;i<=n;i++) { for(j=1;j<=n;j++) {for(k=1;k<=n;k++){ \
   printf("%13.5e",0.2+cos(i*12.566368/n)*cos(j*12.566368/n)*cos(k*12.566368/n));if(k%6==0)printf("\n") \
 }}}}'