Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault on spicyz #1743

Closed
stevesmoot opened this issue May 15, 2024 · 1 comment · Fixed by #1746
Closed

segfault on spicyz #1743

stevesmoot opened this issue May 15, 2024 · 1 comment · Fixed by #1746
Assignees
Labels

Comments

@stevesmoot
Copy link
Collaborator

stevesmoot commented May 15, 2024

on 7.0.0-dev.254 I tried compiling a spicy script that worked fine on 6.0.3 and got a seg fault.
another old script compiled fine, have not tried to to biscect somehow to see what triggers.
Have no idea how to usefully use a debugger anymore so here is the info I get:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x58)
    frame #0: 0x000000010164d520 libhilti.dylib`hilti::QualifiedType::_type() const [inlined] hilti::ast::detail::ContextIndex<(char)84>::operator!=(this=0x0000000000000058, other=<unavailable>) const at ast-context.h:75:63 [opt]
   72  	    explicit operator bool() const { return *this != None; }
   73
   74  	    bool operator==(const ContextIndex& other) const { return _value == other._value; }
-> 75  	    bool operator!=(const ContextIndex& other) const { return _value != other._value; }
   76
   77  	    ContextIndex(const ContextIndex& other) = default;
   78  	    ContextIndex(ContextIndex&& other) noexcept = default;
Target 0: (spicyz) stopped.
warning: libhilti.dylib was compiled with optimization - stepping may behave oddly; variables may not be available.
(lldb) thread backtrace
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x58)
  * frame #0: 0x000000010159eb50 libhilti.dylib`hilti::QualifiedType::_type() const [inlined] hilti::ast::detail::ContextIndex<(char)84>::operator!=(this=0x0000000000000058, other=<unavailable>) const at ast-context.h:75:63 [opt]
    frame #1: 0x000000010159eb50 libhilti.dylib`hilti::QualifiedType::_type() const [inlined] hilti::ast::detail::ContextIndex<(char)84>::operator bool(this=0x0000000000000058) const at ast-context.h:72:51 [opt]
    frame #2: 0x000000010159eb50 libhilti.dylib`hilti::QualifiedType::_type(this=0x0000000000000000) const at type.cc:129:10 [opt]
    frame #3: 0x00000001016d7f98 libhilti.dylib`(anonymous namespace)::VisitorPass2::operator()(hilti::operator_::map::In*) [inlined] hilti::QualifiedType::type(this=<unavailable>, follow=true) const at node.h:0:16 [opt]
    frame #4: 0x00000001016d7f94 libhilti.dylib`(anonymous namespace)::VisitorPass2::operator()(hilti::operator_::map::In*) [inlined] hilti::type::Map::keyType(this=<unavailable>) const at map.h:67:61 [opt]
    frame #5: 0x00000001016d7f64 libhilti.dylib`(anonymous namespace)::VisitorPass2::operator()(this=0x000000016fdfda20, n=0x00006000034c2e20) at resolver.cc:1401:88 [opt]
    frame #6: 0x00000001016ca854 libhilti.dylib`hilti::detail::resolver::resolve(hilti::Builder*, hilti::Node*) at visitor.h:334:17 [opt]
    frame #7: 0x00000001016ca810 libhilti.dylib`hilti::detail::resolver::resolve(builder=0x000060000059c0c0, root=0x000060000339c050) at resolver.cc:1627:5 [opt]
    frame #8: 0x00000001013ba770 libhilti.dylib`hilti::rt::Result<hilti::rt::Nothing> _runHook<bool (* hilti::Plugin::*)(hilti::Builder*, hilti::Node*), hilti::Builder*, hilti::node::RetainedPtr<hilti::ASTRoot>>(modified=0x000000016fdfdc37, plugin=0x0000000126e04b40, hook=0x0000000000000088, description="resolving AST", args=0x000000016fdfdcd8, args=0x0000600002c9c030) at ast-context.cc:387:10 [opt]
    frame #9: 0x00000001013b9014 libhilti.dylib`hilti::ASTContext::_resolve(hilti::Builder*, hilti::Plugin const&) [inlined] hilti::ASTContext::_resolveRoot(this=0x0000600002c9c000, modified=0x000000016fdfdc37, builder=0x000060000059c0c0, plugin=0x0000000126e04b40) at ast-context.cc:517:12 [opt]
    frame #10: 0x00000001013b8fd8 libhilti.dylib`hilti::ASTContext::_resolve(this=<unavailable>, builder=<unavailable>, plugin=<unavailable>) at ast-context.cc:542:24 [opt]
    frame #11: 0x00000001013b8694 libhilti.dylib`hilti::ASTContext::processAST(this=0x0000600002c9c000, builder=0x000060000059c0c0, driver=0x000000016fdfe628) at ast-context.cc:414:28 [opt]
    frame #12: 0x000000010168a810 libhilti.dylib`hilti::Driver::compileUnits(this=0x000000016fdfe628) at driver.cc:671:45 [opt]
    frame #13: 0x000000010168b5e4 libhilti.dylib`hilti::Driver::compile(this=0x000000016fdfe628) at driver.cc:746:20 [opt]
    frame #14: 0x0000000100005930 spicyz`zeek::spicy::Driver::compile(this=0x000000016fdfe628) at driver.cc:218:36 [opt]
    frame #15: 0x0000000100061bf0 spicyz`main(argc=<unavailable>, argv=<unavailable>) at main.cc:274:27 [opt]
    frame #16: 0x000000019333e0e0 dyld`start + 2360

EDIT

Reproducer:

module foo;

public type X = unit {
    var a: map<bytes, bytes>;
    : Y(self);
};

type Y = unit(x: X) {
    on %done {
        b"" in x.a;
    }
};
@bbannier
Copy link
Member

Thanks for trying out development versions and reporting back. Unfortunately debugging compiler failures from stack traces is extremely hard, can you share some code which shows this behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants