Repository navigation
Report parcelport failures at startup instead of terminating #8194
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
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 |
|---|---|---|
|
|
@@ -962,35 +962,60 @@ namespace hpx { | |
|
|
||
| // Command line handling should have updated this by now. | ||
| HPX_ASSERT(cmdline.rtcfg_.mode_ != runtime_mode::default_); | ||
| if (cmdline.rtcfg_.mode_ == runtime_mode::local) | ||
| { | ||
| LPROGRESS_ << "creating local runtime"; | ||
| rt.reset(new hpx::runtime(cmdline.rtcfg_, true)); | ||
| } | ||
| else | ||
|
|
||
| // The runtime's constructor creates and starts the | ||
| // parcelports and bootstraps the localities: errors there | ||
| // (invalid settings, a parcelport that can't start) are | ||
| // reported like the other errors during startup, instead of | ||
| // leaving hpx::init. Its thread pools haven't started yet. | ||
| try | ||
| { | ||
| #if defined(HPX_HAVE_DISTRIBUTED_RUNTIME) | ||
| for (auto const& registry : component_registries) | ||
| if (cmdline.rtcfg_.mode_ == runtime_mode::local) | ||
| { | ||
| hpx::register_startup_function([registry]() { | ||
| registry->register_component_type(); | ||
| }); | ||
| LPROGRESS_ << "creating local runtime"; | ||
| rt.reset(new hpx::runtime(cmdline.rtcfg_, true)); | ||
| } | ||
| else | ||
| { | ||
| #if defined(HPX_HAVE_DISTRIBUTED_RUNTIME) | ||
| for (auto const& registry : component_registries) | ||
| { | ||
| hpx::register_startup_function([registry]() { | ||
| registry->register_component_type(); | ||
| }); | ||
| } | ||
|
|
||
| LPROGRESS_ << "creating distributed runtime"; | ||
| rt.reset(new hpx::runtime_distributed(cmdline.rtcfg_, | ||
| &hpx::detail::pre_main, &hpx::detail::post_main)); | ||
| LPROGRESS_ << "creating distributed runtime"; | ||
| rt.reset(new hpx::runtime_distributed(cmdline.rtcfg_, | ||
| &hpx::detail::pre_main, &hpx::detail::post_main)); | ||
| #else | ||
| HPX_THROW_EXCEPTION(hpx::error::invalid_status, | ||
| "run_or_start", | ||
| "Attempted to start the runtime in the mode \"{1}\", " | ||
| "but HPX was compiled with " | ||
| "HPX_WITH_DISTRIBUTED_RUNTIME=OFF, and \"{1}\" " | ||
| "requires HPX_WITH_DISTRIBUTED_RUNTIME=ON. " | ||
| "Recompile HPX with HPX_WITH_DISTRIBUTED_RUNTIME=ON or " | ||
| "change the runtime mode.", | ||
| get_runtime_mode_name(cmdline.rtcfg_.mode_)); | ||
| HPX_THROW_EXCEPTION(hpx::error::invalid_status, | ||
| "run_or_start", | ||
| "Attempted to start the runtime in the mode " | ||
| "\"{1}\", but HPX was compiled with " | ||
| "HPX_WITH_DISTRIBUTED_RUNTIME=OFF, and \"{1}\" " | ||
| "requires HPX_WITH_DISTRIBUTED_RUNTIME=ON. " | ||
| "Recompile HPX with " | ||
| "HPX_WITH_DISTRIBUTED_RUNTIME=ON " | ||
| "or change the runtime mode.", | ||
| get_runtime_mode_name(cmdline.rtcfg_.mode_)); | ||
| #endif | ||
| } | ||
| } | ||
| catch (hpx::exception const& e) | ||
| { | ||
| resource::detail::delete_partitioner(); | ||
| std::cerr << "hpx::init: hpx::exception caught: " | ||
| << hpx::get_error_what(e) << "\n"; | ||
| return -1; | ||
|
Contributor
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. Clear the global runtime pointer when runtime construction fails.
A later On construction failure, clear the published runtime pointer before control returns from the handler. The runtime objects are already destroyed on this path, and no thread pools have started, so nothing needs to stop first. Use the same clearing that normal shutdown uses, If
|
||
| } | ||
| catch (std::exception const& e) | ||
| { | ||
| resource::detail::delete_partitioner(); | ||
| std::cerr | ||
| << "hpx::init: std::exception caught: " << e.what() | ||
| << "\n"; | ||
| return -1; | ||
| } | ||
|
|
||
| // Store application defined command line options | ||
|
|
||
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.
Guard
thread_manager_in~runtimewhen startup fails before the manager exists.thread_manager_is assigned only at the end ofset_notification_policies, after the main, I/O, and timer pools are initialized. If one of those calls throws, the member stays null. When a derived runtime constructor then fails after the baseruntimeis constructed,~runtimeruns and callsthread_manager_->status()on the null pointer. The existingstop()call dereferences it the same way. This crash can prevent the new startup error reporting from running on this path.Check
thread_manager_before using it in the destructor.wait()already runs only whenthreads_ranis true.Suggested fix