Revert "[core] Downgrade vendored setproctitle to 1.2.3 (#60185)"#60361
Revert "[core] Downgrade vendored setproctitle to 1.2.3 (#60185)"#60361dayshah merged 3 commits intoray-project:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request reverts a previous downgrade of the setproctitle library and introduces macOS-specific logic to address test failures and potential performance regressions. The changes include updating the vendored version to 1.3.6, modifying the BUILD.bazel file to include macOS-specific source and header files, and updating the c.h file to use stdbool.h for boolean types in C. New files darwin_set_process_name.c and darwin_set_process_name.h are added to handle process title setting on macOS using Launch Services. The spt_setup.c and spt_status.c files are updated to integrate these macOS-specific functionalities and include minor debugging improvements and typo fixes. Overall, the changes are well-aligned with the stated goal of fixing macOS-related issues.
| if (spt_setup() < 0) { | ||
| spt_debug("failed to initialize setproctitle"); | ||
| } | ||
|
|
||
| /* Initialize the process title */ | ||
| set_ps_display(title, true); |
There was a problem hiding this comment.
The set_ps_display function is now called unconditionally, even if spt_setup() fails. If spt_setup() returns a negative value, it indicates a failure in initialization, and set_ps_display might operate on uninitialized global variables (ps_buffer, save_argv), which could lead to undefined behavior or crashes. The original logic correctly guarded this call. It's safer to only call set_ps_display if spt_setup() is successful.
if (spt_setup() < 0) {
spt_debug("failed to initialize setproctitle");
return NULL;
}
/* Initialize the process title */
set_ps_display(title, true);| if (spt_setup() < 0) { | ||
| spt_debug("failed to initialize setproctitle"); | ||
| } |
There was a problem hiding this comment.
Similar to spt_setproctitle, get_ps_display is called unconditionally after spt_setup(). While get_ps_display has internal checks to prevent crashes if ps_buffer is NULL, it will return an empty string, which might not be the desired behavior if the setup failed. It would be more robust to handle the spt_setup() failure explicitly, perhaps by returning NULL or raising a Python exception to indicate that the process title could not be retrieved.
if (spt_setup() < 0) {
spt_debug("failed to initialize setproctitle");
return NULL;
}| strncpy(namebuf, name, sizeof(namebuf) - 1); | ||
| namebuf[sizeof(namebuf) - 1] = '\0'; | ||
|
|
||
| return (pthread_setname_np(namebuf) != 0); |
There was a problem hiding this comment.
The function darwin_pthread_setname_np returns true if pthread_setname_np fails (returns non-zero) and false if it succeeds (returns zero). This is counter-intuitive for a boolean function typically indicating success. Consider inverting the return value or renaming the function to clarify its meaning (e.g., darwin_pthread_setname_np_failed).
return (pthread_setname_np(namebuf) == 0);|
Kicked off a release test to see if it affected the ask throughput numbers at all: |
|
Doesn't look like this helped the benchmarks. Also premerge is failing. We might be able to make this work on latest with OBJC_DISABLE_INITIALIZE_FORK_SAFETY=yes baked into the environment. If you have a build of this version on mac and can observe the crash issue, try setting that environment variable and see if we can skirt the hang. EDIT: Doesn't seem to skirt the hang, but we should see if the env variable can deflake the tests. |
| strncpy(namebuf, name, sizeof(namebuf) - 1); | ||
| namebuf[sizeof(namebuf) - 1] = '\0'; | ||
|
|
||
| return (pthread_setname_np(namebuf) != 0); |
There was a problem hiding this comment.
Inverted boolean return value in pthread helper
Low Severity
darwin_pthread_setname_np returns pthread_setname_np(namebuf) != 0, which evaluates to true on failure and false on success. This inverts conventional boolean semantics where true indicates success. While the return value is currently explicitly ignored at line 170 via (void) cast, the confusing semantics could cause bugs if this function is used elsewhere in the future.
…60185)" (ray-project#60361) Signed-off-by: joshlee <joshlee@anyscale.com> Signed-off-by: jinbum-kim <jinbum9958@gmail.com>
…60185)" (ray-project#60361) Signed-off-by: joshlee <joshlee@anyscale.com> Signed-off-by: 400Ping <jiekaichang@apache.org>
…60185)" (ray-project#60361) Signed-off-by: joshlee <joshlee@anyscale.com>
…60185)" (ray-project#60361) Signed-off-by: joshlee <joshlee@anyscale.com> Signed-off-by: peterxcli <peterxcli@gmail.com>
…60185)" (ray-project#60361) Signed-off-by: joshlee <joshlee@anyscale.com> Signed-off-by: peterxcli <peterxcli@gmail.com>
It looks this change caused multiple mac tests to fail or become flaky:
Also potentially (unlikely since this change was mac specific) responsible for a perf regression since it's in the range of commits: f182131...1fd6d11 and nothing else seems obvious.