Skip to content

Commit

Permalink
src: remove fixed-size GetHumanReadableProcessName
Browse files Browse the repository at this point in the history
Remove the version of GetHumanReadableProcessName() that operates on a
fixed-size buffer.

The only remaining caller is Assert() which might get called in contexts
where dynamically allocating memory isn't possible but as Assert() calls
printf(), which also allocates memory when necessary, this commit is
unlikely to make matters much worse.

PR-URL: #31633
Fixes: #31631
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
bnoordhuis authored and codebytere committed Feb 17, 2020
1 parent 8964077 commit 348c787
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/node_errors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,11 @@ void AppendExceptionLine(Environment* env,
}

[[noreturn]] void Assert(const AssertionInfo& info) {
char name[1024];
GetHumanReadableProcessName(&name);
std::string name = GetHumanReadableProcessName();

fprintf(stderr,
"%s: %s:%s%s Assertion `%s' failed.\n",
name,
name.c_str(),
info.file_line,
info.function,
*info.function ? ":" : "",
Expand Down
1 change: 0 additions & 1 deletion src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ void SignalExit(int signal, siginfo_t* info, void* ucontext);

std::string GetProcessTitle(const char* default_title);
std::string GetHumanReadableProcessName();
void GetHumanReadableProcessName(char (*name)[1024]);

void InitializeContextRuntime(v8::Local<v8::Context>);

Expand Down
7 changes: 0 additions & 7 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,6 @@ std::string GetHumanReadableProcessName() {
return SPrintF("%s[%d]", GetProcessTitle("Node.js"), uv_os_getpid());
}

void GetHumanReadableProcessName(char (*name)[1024]) {
// Leave room after title for pid, which can be up to 20 digits for 64 bit.
char title[1000] = "Node.js";
uv_get_process_title(title, sizeof(title));
snprintf(*name, sizeof(*name), "%s[%d]", title, uv_os_getpid());
}

std::vector<std::string> SplitString(const std::string& in, char delim) {
std::vector<std::string> out;
if (in.empty())
Expand Down

0 comments on commit 348c787

Please sign in to comment.