From: Ben Pfaff Date: Mon, 21 Oct 2024 17:49:00 +0000 (-0700) Subject: MATRIX: Fix test for very large matrix. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=395ff81461c2f58e9e700ee777f28ffd16241bf1;p=pspp MATRIX: Fix test for very large matrix. I kept getting processes killed as out-of-memory for the "MATRIX - very large matrices" test. Somehow, GSL was really trying to allocate a matrix with 230,000,000,000 elements, which would require 1.84 PB of memory, which I don't have. This makes the matrix allocator report out-of-memory if a sequence would have more than about 2 billion elements, fixing my OOM killer problem. --- diff --git a/src/language/commands/matrix.c b/src/language/commands/matrix.c index acbef18df0..8747992b10 100644 --- a/src/language/commands/matrix.c +++ b/src/language/commands/matrix.c @@ -3500,7 +3500,7 @@ matrix_expr_evaluate_seq (const struct matrix_expr *e, long int n = (end >= start && by > 0 ? (end - start + by) / by : end <= start && by < 0 ? (start - end - by) / -by : 0); - gsl_matrix *m = gsl_matrix_alloc (1, n); + gsl_matrix *m = n <= (long) INT32_MAX ? gsl_matrix_alloc (1, n) : NULL; if (m == NULL) { msg_at (SE, matrix_expr_location (e),