Valgrind macOs and error Syscall param msg->desc.port.name points to uninitialised byte(s)

前端 未结 2 1535
傲寒
傲寒 2021-02-20 00:09

I tried to run valgrind 3.13 and 3.14 (on macOs 10.12.6) in very simple project but I got strange error who I never got in my linux before.

  1. Very simple C progra

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-20 00:56

    Valgrind has a system for suppressing errors. Suppression rules are specified in special files, for instance $PREFIX/lib/valgrind/default.supp. Users can create their own rules using the --gen-suppressions=full aid, which will print a suppression rule for each error encountered. The user can then customize it to their own needs.

    I did this for the error in question, and it works great! No need to install unstable versions. This is also a good tool in the belt if you run into other reported errors you'd like to ignore.

    I saved this file as ~/.valgrind.supp.

    # false positive for any executable (it seems)
    # macOS 10.12.6
    # valgrind 3.13.0
    {
        libtrace initialization false positive
        Memcheck:Param
        msg->desc.port.name
        fun:mach_msg_trap
        fun:mach_msg
        fun:task_set_special_port
        fun:_os_trace_create_debug_control_port
        fun:_libtrace_init
    }
    

    # starts a comment and {} denote a rule. The first line is the name of the rule. The second one says which tool and error type to suppress. Param means invalid syscall param, and the next line gives the parameter to suppress errors for. The following lines starting with fun: means this suppression rule only applies in mach_msg_trap when called by mach_msg called by task_set_special_port and so on. This way we only suppress the error in this very specific case where Valgrind mistakes libtrace initialization for an error.

    Valgrind will use this rule if you supply the argument --suppressions=$HOME/.valgrind.supp on the command line, or put it in $VALGRIND_OPTS or ~/.valgrindrc.

    • Suppressing errors [Valgrind]
    • Setting default options [Valgrind]
    • Writing suppression files [Memcheck]
    • Valgrind Suppression File Howto [wkWiki]

提交回复
热议问题