Repository navigation
Description
Summary
Threaded double-precision SYRK in the SkylakeX kernel of the OpenBLAS build bundled with NumPy returns incorrect results and corrupts heap memory for sufficiently large matrices at some thread counts.
For an all-ones matrix A of shape (K, N) = (749, 39601), column-major lower-triangle transpose SYRK should produce C[i,j] = 749 throughout the computed triangle. With 12 threads, it instead produces values such as 375, followed by double free or corruption (out) and SIGABRT during cleanup.
I reproduced this also in a standalone C executable that loads the OpenBLAS shared library and calls its ILP64 CBLAS entry point directly.
Environment
-
Linux x86-64, Intel Xeon Platinum 8488C (AWS c7i.4xlarge, 16 vCPUs).
-
OpenBLAS bundled with NumPy 2.5.4.
-
NumPy's library filename:
libscipy_openblas64_-f48b354e.so. -
openblas_get_configreports:OpenBLAS 0.3.34.106.0 USE64BITINT DYNAMIC_ARCH NO_AFFINITY SkylakeX MAX_THREADS=64 -
The diagnostic job had a 30 GiB memory limit. The numerical error and allocator corruption are observed before any external timeout.
-
I have not yet reproduced this against a pristine upstream source build or tested a newer development revision. The exact upstream commit/build provenance of the bundled library is not established.
Reproducer
This C program uses the symbol names exported by NumPy's bundled ILP64 OpenBLAS. It deliberately disables core dumps to avoid writing a very large core file. For a differently packaged OpenBLAS, the symbol names and integer ABI would need adjusting.
Save as repro.c:
#include <dlfcn.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>
typedef void (*syrk_function)(int, int, int, int64_t, int64_t, double,
const double *, int64_t, double, double *, int64_t);
typedef const char *(*config_function)(void);
int main(int argc, char **argv) {
struct rlimit limit = {0, 0};
if (setrlimit(RLIMIT_CORE, &limit) != 0) {
perror("setrlimit");
return 1;
}
if (argc != 4) {
fprintf(stderr, "Usage: %s /path/to/NumPy-ILP64-OpenBLAS.so N K\n", argv[0]);
return 1;
}
char *end_n, *end_k;
int64_t n = strtoll(argv[2], &end_n, 10);
int64_t k = strtoll(argv[3], &end_k, 10);
if (*end_n || *end_k || n < 1 || n > 60000 || k < 1 || k > 4096) {
fprintf(stderr, "Invalid dimensions\n");
return 1;
}
void *library = dlopen(argv[1], RTLD_NOW | RTLD_LOCAL);
if (!library) {
fprintf(stderr, "dlopen: %s\n", dlerror());
return 1;
}
syrk_function syrk = (syrk_function)dlsym(library, "scipy_cblas_dsyrk64_");
config_function config = (config_function)dlsym(library, "scipy_openblas_get_config64_");
if (!syrk || !config) {
fprintf(stderr, "Missing NumPy ILP64 OpenBLAS symbols\n");
return 1;
}
printf("%s\nN=%" PRId64 " K=%" PRId64 "\n", config(), n, k);
double *a = malloc((size_t)k * n * sizeof(double));
double *c = calloc((size_t)n * n, sizeof(double));
if (!a || !c) {
perror("allocation");
return 1;
}
for (int64_t i = 0; i < k * n; ++i) {
a[i] = 1.0;
}
fflush(stdout);
/* Column-major, lower triangle, transpose; all computed values must equal K. */
syrk(102, 122, 112, n, k, 1.0, a, k, 0.0, c, n);
int failures = 0;
for (int64_t column = 0; column < n && failures < 8; ++column) {
for (int64_t row = column; row < n && failures < 8; ++row) {
double value = c[column * n + row];
if (value != (double)k) {
printf("WRONG C[%" PRId64 ",%" PRId64 "]=%.17g expected=%" PRId64 "\n",
row, column, value, k);
++failures;
}
}
}
printf("%s\n", failures ? "NUMERICAL FAILURE" : "ALL COMPUTED ELEMENTS VERIFIED");
fflush(stdout);
free(a);
free(c);
dlclose(library);
return failures ? 2 : 0;
}Compile and run on an AVX-512-capable CPU:
cc -O2 -Wall -Wextra -Werror repro.c -ldl -o repro
OPENBLAS_CORETYPE=SkylakeX OPENBLAS_NUM_THREADS=12 \
./repro /path/to/numpy.libs/libscipy_openblas64_-f48b354e.so 39601 749The output allocation is approximately 11.7 GiB of virtual address space; only one triangle is computed. A machine with sufficient RAM is required.
Actual output:
OpenBLAS 0.3.34.106.0 USE64BITINT DYNAMIC_ARCH NO_AFFINITY SkylakeX MAX_THREADS=64
N=39601 K=749
WRONG C[0,0]=375 expected=749
WRONG C[1,0]=375 expected=749
WRONG C[2,0]=375 expected=749
WRONG C[3,0]=375 expected=749
WRONG C[4,0]=375 expected=749
WRONG C[5,0]=375 expected=749
WRONG C[6,0]=375 expected=749
WRONG C[7,0]=375 expected=749
NUMERICAL FAILURE
double free or corruption (out)
The standalone C failure was also reproduced under GDB. The main thread stops on SIGABRT in free(), called from main(), after the incorrect values above have been printed.
Controls and size dependence
For N=39601, K=749:
| Route | Kernel | Threads | Result |
|---|---|---|---|
| Standalone C DSYRK | SkylakeX | 12 | Incorrect values and SIGABRT |
| Standalone C DSYRK | SkylakeX | 16 | Entire computed triangle verified correct |
| Standalone C DSYRK | Haswell | 12 | Entire computed triangle verified correct |
NumPy np.dot(A.T, A, out=C) |
SkylakeX | 1 | Entire result verified correct |
NumPy np.dot(A.T, A, out=C) |
SkylakeX | 16 | Entire result verified correct |
| Direct CBLAS DGEMM via ctypes, same NumPy OpenBLAS library | SkylakeX | 12 | Entire result verified correct |
Additional direct calls to the same ILP64 DSYRK entry point through ctypes, with column-major A, lda=K, ldc=N:
- At 12 threads and
K=749,N=32768,32769,33124, and36000all pass. - At 12 threads and
K=749,N=39601fails. - At 4 threads and
K=749,N=8192and16384pass, while24576and32768return incorrect values and abort. - At 12 threads and
N=39601,K=1,64,256, and512all pass. - The failing NumPy dot case also reproduces with C-order input and with explicitly controlled input/output address offsets of 0, 16, and 32 bytes modulo 64.
All passing cases above were checked numerically, not just for successful exit. The ctypes sweep ran each passing case twice in its subprocess.
Diagnosis so far
This appears specific to threaded SYRK in this SkylakeX build, rather than a general inability to allocate the output or a NumPy transpose-view issue. Explicit DGEMM in the same library is a working control.
The dimension/thread-count dependence suggests packed-panel scratch-buffer sizing or partitioning as a possible cause, but I have not established the exact defective source line or commit. I am reporting the observed numerical corruption and heap corruption, not claiming a proven source-level explanation.
Activity
martin-frbg commentedon Nov 4, 2026
I cannot reproduce this with current HEAD so far, and there's reason to assume it was fixed by the thread buffer slot assignment rewrite in #6105
martin-frbg commentedon Nov 4, 2026
Newer snapshots of OpenBLAS built for Scipy are available at https://anaconda.org/channels/scientific-python-nightly-wheels/packages/scipy-openblas64/files
apullin commentedon Nov 6, 2026
This still reproduces on current develop (c2fc6cf, which includes #6105) when OpenBLAS is built like scipy-openblas, with
BUFFERSIZE=20(32 MiB work areas instead of the default 128 MiB).With such a build, the program from the issue crashes at 12 threads with the SkylakeX kernels (run under Intel SDE), and DSYRK with N=23000 and 2 threads crashes with the Haswell kernels.
Each thread of the threaded SYRK/HERK driver packs one K block for its whole row range into its work area, and nothing limits that to the work area's size, so for large N it writes past the end (in the report, into C and its malloc header).
A default build has four times the space, which is why the issue's case does not fail there.
I have a fix with regression tests and will open a PR shortly.
Fix work buffer overflow in threaded SYRK/HERK for large N
utest: exactness tests for threaded SYRK/HERK and POTRF
utest: check that threaded SYRK stays inside its work area