[Bug report] BLAS : Bad memory unallocation!


I encountered the following bug:
I use a div-conforming HDG to solve the vector-Poisson equation. (see attached code)
When using a high-order version (order >= 8), the assembly of stiffness matrix using TaskManager() give me an error message

with TaskManager():
>> BLAS : Bad memory unallocation! 

And the returned results are incorrect.

(1) This bug is not observed for lower order HDG cases (order <8), or other high order methods like VectorH1 space. (When condensation is turned off, the bug is also not observed)
(2) This bug is not observed when TaskManager is turned off.
(3) TaskManager is also not compatible with DG stiffness matrices.

I am using NGSolve-6.2.2004-128-gc8324807


Attachment: testAssemble_2020-05-22.py

Hi Guosheng,

This error seems to come from openblas ( just found this: BLAS : Program is Terminated. Because you tried to allocate too many memory regions. · Issue #1882 · xianyi/OpenBLAS · GitHub )

How many threads are you running?
Does it run if you set the environment variable NGS_NUM_THREADS to 1? If so, what’s the maximum number without errors?

Did you compile the version yourself or are you using the Ubuntu nightly build?


Hi Matthias,

I compile the code myself. The machine has 8 dual cores. The blacs/lapack library was found within intel MKL.

With 4 threads, the code runs without error.
With 8 threads, the code runs without error most of time, but occasionally (roughly 1 out of 6 runs) it produces the bug.


I cannot reproduces the issue with a 8x2 core machine (also linking with Intel MKL).

Did you set MKL_THREADING_LAYER (either “gnu”, “intel” or “sequential”) or MKL_NUM_THREADS? Try different settings and check, if it makes any difference. If MKL_NUM_THREADS=1 is not working either, I guess the error message is from another blas library.

To check your build settings, please attach my_build_dir/CMakeLists.txt and my_build_dir/ngsolve/CMakeLists.txt and the output of
ldd which ngs