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

**URL:** <https://discourse.julialang.org/t/on-entry-to-dlascls-parameter-number-4-had-an-illegal-value/80657>\
**Category:** New to Julia\
**Tags:** debug, multithreading, linearalgebra, loopvectorization\
**Created:** [May 7, 2022, 11:08am UTC](https://discourse.julialang.org/t/on-entry-to-dlascls-parameter-number-4-had-an-illegal-value/80657 "2022-05-07T11:08:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredrikpaues](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikpaues/32/34080_2.png) [@fredrikpaues](https://discourse.julialang.org/u/fredrikpaues)\
**Post date:** [May 7, 2022, 11:08am UTC](https://discourse.julialang.org/t/on-entry-to-dlascls-parameter-number-4-had-an-illegal-value/80657/1 "2022-05-07T11:08:11Z")

</div>

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:

```julia
** 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.

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [May 7, 2022, 7:12pm UTC](https://discourse.julialang.org/t/on-entry-to-dlascls-parameter-number-4-had-an-illegal-value/80657/2 "2022-05-07T19:12:34Z")

</div>

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](https://github.com/JuliaLinearAlgebra/MKL.jl).

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_`.

---

<div class="post-metadata">

**Author:** ![fredrikpaues](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikpaues/32/34080_2.png) [@fredrikpaues](https://discourse.julialang.org/u/fredrikpaues)\
**Post date:** [May 14, 2022, 5:37am UTC](https://discourse.julialang.org/t/on-entry-to-dlascls-parameter-number-4-had-an-illegal-value/80657/3 "2022-05-14T05:37:05Z")

</div>

Thank you! Now I have somewhere to start ❤
