Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Issue 279293002: [Mac] Release the mach_host_self() Mach port when done with it (Closed)

Created:
6 years, 7 months ago by Mark Mentovai
Modified:
6 years, 7 months ago
Reviewers:
wtc
CC:
chromium-reviews
Visibility:
Public.

Description

[Mac] Release the mach_host_self() Mach port when done with it. mach_host_self() and mach_thread_self() return send rights to their respective Mach ports, which are finite system-wide resources. The port returned by these calls must be released when the caller finishes using the port. Failure to do so can exhaust the supply of ports system-wide. For an example of the type of problem that this can cause, see http://crbug.com/105513. I don't believe that PR_GetPhysicalMemorySize is used by Chrome anywhere, but Chrome does build this code on Mac, and this mach_host_self() call came up in an audit of un-deallocated ports. This patch should also be sent upstream. Note that while you must mach_port_deallocate() the ports you get from mach_host_self() and mach_thread_self(), you must not normally deallocate the one from mach_task_self(), because mach_task_self() is actually just a macro that references a global variable. It doesn’t add any port rights at all. See <mach/mach_init.h>. If you bypass the macro and call the real mach_task_self() system call, you do need to call mach_port_deallocate(), but this situation is incredibly rare. R=wtc

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+5 lines, -1 line) Patch
M nspr/pr/src/misc/prsystem.c View 2 chunks +5 lines, -1 line 0 comments Download

Messages

Total messages: 5 (0 generated)
Mark Mentovai
6 years, 7 months ago (2014-05-12 20:19:43 UTC) #1
wtc
Patch set 1 LGTM. Please don't commit this CL yet. We need to add a ...
6 years, 7 months ago (2014-05-12 21:02:48 UTC) #2
Mark Mentovai
It’s not urgent. We can prepare a patch to the upstream and import it normally.
6 years, 7 months ago (2014-05-12 21:13:44 UTC) #3
wtc
Mark: I checked in your patch to the NSPR upstream: https://hg.mozilla.org/projects/nspr/rev/f4f1851bb7a6 You can close this ...
6 years, 7 months ago (2014-05-12 23:30:34 UTC) #4
Mark Mentovai
6 years, 7 months ago (2014-05-13 14:14:52 UTC) #5

Powered by Google App Engine
This is Rietveld 408576698