Valgrind prints the following message for the code below taken from http://miknight.blogspot.com/2005/11/resident-set-size-in-mac-os-x.html : UNKNOWN task message [id 3405, to mach_task_self(), reply 0xf03] Looks like the wrapper for mach_msg_task (see m_syswrap/syswrap_darwin.c) doesn't handle neither id 3405 (which is task_info), nor 3406 (task_set_info). ================================================ #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/sysctl.h> #include <mach/task.h> #include <mach/mach_init.h> void getres(task_t task, unsigned int *rss, unsigned int *vs) { struct task_basic_info t_info; mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT; task_info(task, TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count); *rss = t_info.resident_size; *vs = t_info.virtual_size; } void memcheck() { unsigned int rss, vs, psize; task_t task = MACH_PORT_NULL; if (task_for_pid(current_task(), getpid(), &task) != KERN_SUCCESS) abort(); getres(task, &rss, &vs); psize = getpagesize(); fprintf(stderr, "RSS: %u KiB, VS: %u KiB.\n", rss, vs); } int main() { memcheck(); return 0; }
This can be reliably reproduced with the newly added (r15205) regression test case as follows: $ cd none/tests/darwin/ $ make bug254164 $ cd ../../../ $ perl tests/vg_regtest none/tests/darwin/bug254164 bug254164: valgrind -q ./bug254164 *** bug254164 failed (stderr) *** == 1 test, 1 stderr failure, 0 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures == none/tests/darwin/bug254164 (stderr) Also worth noting that current Darwin kernel code indicates that task_set_info() is currently deprecated. Can you advise of a program which uses the task_set_info() interface?
Created attachment 92542 [details] Proposed patch
Resolved in r15209.