zeek / spicy

C++ parser generator for dissecting protocols & files.
https://docs.zeek.org/projects/spicy
Other
243 stars 37 forks source link

Required implicit `confirmed` hook incorrectly removed by optimizer #1789

Closed bbannier closed 1 month ago

bbannier commented 1 month ago

In the following sample the default implementation of the on %confirmed hook gets incorrectly removed by the optimizer which causes a compilation error:

module y;

type Y = unit {};
module x;

public type X = unit {
    on %synced {
        confirm;
    }

    # Adding any `%confirm` implementation makes this pass.
    # on %confirmed {}
};
$ spicyc -dj y.spicy x.spicy
In file included from /private/var/folders/ht/vtb0rkbd4ws15vx02xdb84zw0000gn/T/x_2c5bc7ddff461c16-868c357ed31ef036.cc:7:
In file included from /opt/homebrew/Cellar/zeek/HEAD-1c8feda/include/spicy/rt/libspicy.h:21:
/opt/homebrew/Cellar/zeek/HEAD-1c8feda/include/spicy/rt/util.h:47:11: error: no member named '__on_0x25_confirmed' in '__hlt::x::X'
        p.__on_0x25_confirmed();
        ~ ^
/private/var/folders/ht/vtb0rkbd4ws15vx02xdb84zw0000gn/T/x_2c5bc7ddff461c16-868c357ed31ef036.cc:213:18: note: in instantiation of function template specialization 'spicy::rt::confirm<__hlt::x::X>' requested here
    ::spicy::rt::confirm((*__self));
                 ^
1 error generated.
[error] spicyc: JIT compilation failed

If I change the order of source files in the spicyc invocation to spicyc -dj x.spicy y.spicy this passes; also adding a dummy on %confirmed hook makes this pass. This is reduced from an actual parser which contained debug print statements in on %confirmed which I tried to remove.

This is broken since #1462.