spicy/runtime-support: Switch ParameterMismatch::_fmt to static

UBSAN's vptr sanitize isn't happy with the call to _fmt()
in its member initializer list.

    $ zeek -r Traces/ssh/single-conn.trace .tmp/spicy.event-args-mismatch/test.hlto .tmp/spicy.event-args-mismatch/event-args-mismatch.zeek
    <...>/src/include/zeek/spicy/runtime-support.h:80:29: runtime error: member call on address 0x511000369540 which does not point to an object of type 'zeek::spicy::rt::ParameterMismatch'
    0x511000369540: note: object has invalid vptr
     00 00 00 00  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be
                  ^~~~~~~~~~~~~~~~~~~~~~~
                  invalid vptr
        #0 0x7f9c9977b019 in zeek::spicy::rt::ParameterMismatch::ParameterMismatch(std::basic_string_view<char, std::char_traits<char>>, zeek::IntrusivePtr<zeek::Type> const&, std::basic_string_view<char, std::char_traits<char>>) <...>/src/include/zeek/spicy/runtime-support.h:80:29
         #1 0x7f9c9977a6a2 in zeek::spicy::rt::to_val(hilti::rt::Bytes const&, zeek::IntrusivePtr<zeek::Type> const&) <...>/src/include/zeek/spicy/runtime-support.h:562:15
This commit is contained in:
Arne Welzel 2024-08-06 17:45:58 +02:00
parent 11bc233f45
commit 9f5f8b809a

View file

@ -80,7 +80,7 @@ public:
: ParameterMismatch(_fmt(have, want)) {}
private:
std::string _fmt(const std::string_view& have, const TypePtr& want) {
static std::string _fmt(const std::string_view& have, const TypePtr& want) {
ODesc d;
want->Describe(&d);
return hilti::rt::fmt("cannot convert Spicy value of type '%s' to Zeek value of type '%s'", have,