Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[workspace] Refresh our patch to spral_internal #22417

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

34 changes: 34 additions & 0 deletions tools/workspace/spral_internal/patches/upstream/pr222.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[spral] Cherry-pick of https://github.com/ralna/spral/pull/222

We can drop this patch once we upgrade to a release that contains it.

From: Jeremy Nimmer <[email protected]>
Date: Tue, 7 Jan 2025 10:09:01 -0800
Subject: [PATCH] Fix undefined behavior in LDLT

When m==n the failed_rect.data() is nullptr, but then we still
subtract some small integer from it. Doing arithmetic on a null
pointer is undefined behavior. Clang's undefined Behavior sanitizer
says ldlt_app.cxx:2420:38: runtime error: applying non-zero offset
18446744073709551536 to null pointer

The copy_failed_rect ends up being a no-op because m==rfrom, but it's
still UB to do arithmetic on nullptr, even if never de-referenced.

--- src/ssids/cpu/kernels/ldlt_app.cxx
+++ src/ssids/cpu/kernels/ldlt_app.cxx
@@ -2415,10 +2415,10 @@ class LDLT {
// Rectangular part
// (be careful with blocks that contain both diag and rect parts)
copy_failed_rect(
- get_nrow(nblk-1, m, block_size), get_ncol(jblk, n, block_size),
- get_ncol(nblk-1, n, block_size), cdata[jblk],
- failed_rect.data() + (jfail*(m-n)+(nblk-1)*block_size-n), m-n,
- &a[jblk*block_size*lda+(nblk-1)*block_size], lda
+ get_nrow(nblk-1, m, block_size) - get_nrow(nblk-1, n, block_size),
+ get_ncol(jblk, n, block_size), 0, cdata[jblk],
+ failed_rect.data() + jfail*(m-n), m-n,
+ &a[jblk*block_size*lda+n], lda
);
for(int iblk=nblk; iblk<mblk; ++iblk) {
copy_failed_rect(
2 changes: 1 addition & 1 deletion tools/workspace/spral_internal/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def spral_internal_repository(
sha256 = "0795c10c1c4dab1cf8c2de4024296d75d9d83b7525e82c77584c16060e29e4f5", # noqa
build_file = ":package.BUILD.bazel",
patches = [
":patches/upstream/pointer_math_undefined_behavior.patch",
":patches/upstream/pr222.patch",
":patches/drake_vendor.patch",
":patches/no_fortran_profiling.patch",
],
Expand Down