From: Paul Floyd Date: Sun, 7 Dec 2025 07:50:32 +0000 (+0100) Subject: Darwin mach_msg_host: move assign_port_name to post X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a779c501550173dbee98a6713402fafb161e59a7;p=thirdparty%2Fvalgrind.git Darwin mach_msg_host: move assign_port_name to post There's a GrP comment saying that assign_port_name should only be called on success. And indeed when it is called in the PRE and it can't find the info for the port then the code will assert. --- diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 13ca4eb72..3bbfb76e6 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -5407,7 +5407,8 @@ PRE(host_request_notification) } // GrP fixme only do this on success - assign_port_name(req->notify_port.name, "host_notify-%p"); + // PJF moved to POST(mach_msg_post) + //assign_port_name(req->notify_port.name, "host_notify-%p"); } @@ -8771,6 +8772,7 @@ PRE(mach_msg) else if (mh->msgh_request_port == vg_host_port) { // message sent to mach_host_self() CALL_PRE(mach_msg_host); + AFTER = POST_FN(mach_msg_host); return; } else if (is_task_port(mh->msgh_request_port)) { @@ -8971,6 +8973,34 @@ POST(mach_msg_unhandled_check) PRINT("mach_msg_unhandled_check tid:%d missed mapping change()", tid); } +POST(mach_msg_host) +{ + mach_msg_header_t *mh = (mach_msg_header_t *)ARG1; + + // FIXME PJF put this in a header rather than have a copy and paste duplicate +#pragma pack(4) + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t notify_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + host_flavor_t notify_type; + } Request; +#pragma pack() + + switch (mh->msgh_id) { + case 217: { + Request *req = (Request *)ARG1; + assign_port_name(req->notify_port.name, "host_notify-%p"); + } + break; + default: + break; + } +} + /* --------------------------------------------------------------------- other Mach traps