-
Notifications
You must be signed in to change notification settings - Fork 194
fix(mip): resolve SIGSEGV from OpenMP runtime conflict during MIP teardown (#1219) #1323
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,13 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import ctypes | ||
| import os | ||
|
|
||
| _gomp_path = os.path.join(os.path.dirname(__file__), "_libs", "libgomp-855c301a.so.1.0.0") | ||
| if os.path.exists(_gomp_path): | ||
| ctypes.CDLL(_gomp_path, mode=ctypes.RTLD_GLOBAL) | ||
|
Comment on lines
+7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for libgomp preload failures. If the bundled libgomp exists but fails to load (due to corruption, incompatible architecture, or permission issues), 🛡️ Proposed fix: Add try/except with actionable error message _gomp_path = os.path.join(os.path.dirname(__file__), "_libs", "libgomp-855c301a.so.1.0.0")
if os.path.exists(_gomp_path):
- ctypes.CDLL(_gomp_path, mode=ctypes.RTLD_GLOBAL)
+ try:
+ ctypes.CDLL(_gomp_path, mode=ctypes.RTLD_GLOBAL)
+ except OSError as e:
+ raise ImportError(
+ f"Failed to preload bundled OpenMP runtime library. "
+ f"This may indicate a corrupted installation. "
+ f"Please reinstall cuopt. Details: {e}"
+ ) from e🤖 Prompt for AI Agents |
||
|
|
||
| from cuopt.linear_programming import internals | ||
| from cuopt.linear_programming.data_model import DataModel | ||
| from cuopt.linear_programming.io import ParseMps, Read | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Destructor can throw, risking abrupt termination.
The destructor calls
handle_ptr->sync_stream(), which likely wrapscudaStreamSynchronize()and can throwraft::cuda_erroron failure. If an exception escapes from a destructor during stack unwinding (e.g., when another exception is already active), C++ callsstd::terminate(), causing an abrupt program crash instead of graceful shutdown.Best practice: destructors should not throw. Wrap potentially-throwing calls in try/catch, log the error, and suppress the exception to allow cleanup to continue.
🐛 Proposed fix: Add exception handling in destructor
~iteration_data_t() { - chol.reset(); - handle_ptr->sync_stream(); + try { + chol.reset(); + handle_ptr->sync_stream(); + } catch (const std::exception& e) { + // Log but suppress: destructors must not throw + // settings_ is not accessible here, so we cannot log via settings_.log + // In production, consider using a global error handler or stderr + fprintf(stderr, "Warning: iteration_data_t destructor failed during cleanup: %s\n", e.what()); + } catch (...) { + fprintf(stderr, "Warning: iteration_data_t destructor failed during cleanup (unknown exception)\n"); + } }Note: If
settings_or a logger is accessible in the destructor context, prefer logging through the proper channel instead offprintf(stderr, ...).As per coding guidelines: "cuOpt uses exceptions for error handling" and "Flag missing RAII in exception paths."
🤖 Prompt for AI Agents