** On entry to DLASCLS parameter number 4 had an illegal value

I have some code that works perfectly when run sequentially. But when I decorate a for loop with Threads.@threads I get a scrambled error message which I presume is the following written several times by different threads:

** On entry to DLASCLS parameter number 4 had an illegal value

The code uses a number of packages, but am I correct in assuming that the error message could stem from e.g. LinearAlgebra or LoopVectorization?

Sorry about the lack of detail. The code is rather extensive and I don’t have a clue where to start. The error message doesn’t provide me with a line where things go wrong. In fact, if I run the code directly from the command prompt with julia --threads=auto myscript.jl then the code just fails quietly without any error message.

DLASCL is an internal subroutine of LAPACK, i.e. one normally invoked only by other LAPACK routines. (I presume the extra ‘S’ is due to the thread scrambling.) From this internal property two things follow: 1) it calls LAPACK’s primitive error handler rather than returning an error code which would let Julia be more helpful. 2) the mistake is almost certainly a failure of thread safety in the LAPACK implementation or in a Julia wrapper. I suspect someone is misusing a static or global variable.

Are you using Openblas (the default provider of LAPACK for Julia)? If so, I suggest trying the MKL.jl package.

If you’re up for chasing bugs, you can run Julia under GDB and get a full stack trace by setting a breakpoint on (probably) xerbla_64_.

1 Like

Thank you! Now I have somewhere to start :heart: