New issue
Advanced search Search tips

Issue 790853 link

Starred by 2 users

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Fuchsia
Pri: 3
Type: Bug



Sign in to add a comment

getpid() (such as used in base/logging.cc) is meaningless on Fuchsia

Project Member Reported by mark@chromium.org, Dec 1 2017

Issue description

You reminded me about HANDLE_EINTR/IGNORE_EINTR in mini_chromium, but here’s the other thing that occurred to me.

https://fuchsia.googlesource.com/zircon/+/f3e2126c8a8b2ff64ca6cb7818f0606ceb5f889a/third_party/ulib/musl/stubs/idstubs.c:

 8  #define ZX_PID ((pid_t)3)
[…]
57  static pid_t stub_getpid(void) {
58      return ZX_PID;
59  }
60  weak_alias(stub_getpid, getpid);

3: that’s not very useful.

getpid() is used to obtain the process ID for logging purposes (https://chromium.googlesource.com/chromium/src/+/4c6f8e1d631dd75d5444b284b84c8fc4b577856d/base/logging.cc#161, https://chromium.googlesource.com/chromium/src/+/4c6f8e1d631dd75d5444b284b84c8fc4b577856d/base/logging.cc#849).

At least in mini_chromium’s version, the Fuchsia thread ID comes from the thread’s koid. https://chromium.googlesource.com/chromium/mini_chromium/+/7de4d23ce54fbe4469704075f3857ea31ce576f5/base/logging.cc#322. (It appears that non-mini Chromium’s logging doesn’t do this, and uses zx_thread_self() instead. Is that less system-unique than the koid?)

Would the koid be a better process identifier too to use for mini_chromium logging, Chromium logging, or both?

My main use for a unique process identifier (that is, not “3”) is to make clear that different messages are produced by different processes in a multi-process scenario.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Dec 5 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/mini_chromium/+/fbf410cd4d4030b3f6bd81c061471de054ced681

commit fbf410cd4d4030b3f6bd81c061471de054ced681
Author: Scott Graham <scottmg@chromium.org>
Date: Tue Dec 05 00:02:06 2017

fuchsia: Use koid instead of getpid() for process field in logging

getpid() always returns 3 on Fuchsia. Instead, use the associated kernel
object's koid. Docs xref:

https://fuchsia.googlesource.com/zircon/+/master/docs/concepts.md#handles-and-rights

for both handles, and koids directly below that.

Bug: chromium:790853
Change-Id: I2ab7ae3eb9bf0889ab87f797f142f1cdbc56d02e
Reviewed-on: https://chromium-review.googlesource.com/806803
Reviewed-by: Mark Mentovai <mark@chromium.org>

[modify] https://crrev.com/fbf410cd4d4030b3f6bd81c061471de054ced681/base/logging.cc

Sign in to add a comment