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

passing generics to functions that has optional & kwargs causes a crash #25

Closed
DarkDimius opened this issue Jan 16, 2019 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@DarkDimius
Copy link
Collaborator

This likely should be a user-facing error.

Given


[1] pry(main)> class S
[1] pry(main)*   def self.has_kwarg(value, foo = 1, baz: 2)
[1] pry(main)*     puts "value: #{value}, path: #{path}"
[1] pry(main)*   end
[1] pry(main)* end
=> :has_kwarg
[2] pry(main)> class S
[2] pry(main)*   def self.has_kwarg(value, foo = 1, baz: 2)
[2] pry(main)*     puts "value: #{value}, foo: #{foo}, baz: #{baz}"
[2] pry(main)*   end
[2] pry(main)* end
=> :has_kwarg
[4] pry(main)> S.has_kwarg(1, {baz:3})
value: 1, foo: 1, baz: 3
=> nil
[5] pry(main)> S.has_kwarg(1, {bar:3})
ArgumentError: unknown keyword: bar
from (pry):7:in `has_kwarg'
[6] pry(main)> S.has_kwarg(1, 's')
value: 1, foo: s, baz: 2
=> nil

what should


class C
  extend T::Generic
  A = type_member
  sig {params(value:A).void}
  def dd(value)
    S.has_kwarg(1, value)
  end
end

do?

Originally reported by @dmitry-stripe at https://jira.corp.stripe.com/browse/RUBYPLAT-1543

@DarkDimius DarkDimius added bug Something isn't working and removed bug Something isn't working labels Jan 16, 2019
jez added a commit that referenced this issue Jan 23, 2021
Fails with this backtrace:

    Exception::raise(): core/Loc.cc:270 enforced condition exists() has failed: Can't take source of Loc that doesn't exist

    Backtrace:
      #3 0x1725725 sorbet::core::Loc::source()
      #4 0x120e0e1 sorbet::infer::Environment::processBinding()
      #5 0x11fae5b sorbet::infer::Inference::run()
      #6 0xed1a88 sorbet::realmain::pipeline::CFGCollectorAndTyper::preTransformMethodDef()
      #7 0xed185b sorbet::ast::CALL_MEMBER_impl_preTransformMethodDef<>::call<>()
      #8 0xecf90c sorbet::ast::TreeMapper<>::mapMethodDef()
      #9 0xece3ff sorbet::ast::TreeMapper<>::mapIt()
      #10 0xecf81f sorbet::ast::TreeMapper<>::mapClassDef()
      #11 0xece37a sorbet::ast::TreeMapper<>::mapIt()
      #12 0xed1409 sorbet::ast::TreeMapper<>::mapInsSeq()
      #13 0xecef9f sorbet::ast::TreeMapper<>::mapIt()
      #14 0xebc5d9 sorbet::ast::TreeMap::apply<>()
      #15 0xea2971 sorbet::realmain::pipeline::typecheckOne()
      #16 0xeb3dc6 sorbet::realmain::pipeline::typecheck()::$_4::operator()()
      #17 0xeb3acd std::__1::__invoke<>()
      #18 0xeb3a7d std::__1::__invoke_void_return_wrapper<>::__call<>()
      #19 0xeb3a4d std::__1::__function::__alloc_func<>::operator()()
      #20 0xeb2bee std::__1::__function::__func<>::operator()()
      #21 0x177e015 std::__1::__function::__value_func<>::operator()()
      #22 0x177ddb5 std::__1::function<>::operator()()
      #23 0x17fc90e sorbet::WorkerPoolImpl::multiplexJob()
      #24 0xea5633 sorbet::realmain::pipeline::typecheck()
      #25 0xafb232 sorbet::realmain::realmain()
      #26 0xaf70f2 main
      #27 0x7fba7de990b3 __libc_start_main
      #28 0xaf702e _start
jez added a commit that referenced this issue Jan 26, 2021
* Add ENFORCE that would have made error more obvious

* Add failing test

Fails with this backtrace:

    Exception::raise(): core/Loc.cc:270 enforced condition exists() has failed: Can't take source of Loc that doesn't exist

    Backtrace:
      #3 0x1725725 sorbet::core::Loc::source()
      #4 0x120e0e1 sorbet::infer::Environment::processBinding()
      #5 0x11fae5b sorbet::infer::Inference::run()
      #6 0xed1a88 sorbet::realmain::pipeline::CFGCollectorAndTyper::preTransformMethodDef()
      #7 0xed185b sorbet::ast::CALL_MEMBER_impl_preTransformMethodDef<>::call<>()
      #8 0xecf90c sorbet::ast::TreeMapper<>::mapMethodDef()
      #9 0xece3ff sorbet::ast::TreeMapper<>::mapIt()
      #10 0xecf81f sorbet::ast::TreeMapper<>::mapClassDef()
      #11 0xece37a sorbet::ast::TreeMapper<>::mapIt()
      #12 0xed1409 sorbet::ast::TreeMapper<>::mapInsSeq()
      #13 0xecef9f sorbet::ast::TreeMapper<>::mapIt()
      #14 0xebc5d9 sorbet::ast::TreeMap::apply<>()
      #15 0xea2971 sorbet::realmain::pipeline::typecheckOne()
      #16 0xeb3dc6 sorbet::realmain::pipeline::typecheck()::$_4::operator()()
      #17 0xeb3acd std::__1::__invoke<>()
      #18 0xeb3a7d std::__1::__invoke_void_return_wrapper<>::__call<>()
      #19 0xeb3a4d std::__1::__function::__alloc_func<>::operator()()
      #20 0xeb2bee std::__1::__function::__func<>::operator()()
      #21 0x177e015 std::__1::__function::__value_func<>::operator()()
      #22 0x177ddb5 std::__1::function<>::operator()()
      #23 0x17fc90e sorbet::WorkerPoolImpl::multiplexJob()
      #24 0xea5633 sorbet::realmain::pipeline::typecheck()
      #25 0xafb232 sorbet::realmain::realmain()
      #26 0xaf70f2 main
      #27 0x7fba7de990b3 __libc_start_main
      #28 0xaf702e _start

* Fix failing test
jez added a commit that referenced this issue Aug 1, 2022
    + exec test/lsp_test_runner --single_test=test/testdata/lsp/go_to_type_definition.rb
    Pausing
    Resuming
    [doctest] doctest version is "2.4.1"
    [doctest] run with "--help" for options
    [2022-08-01 22:09:09.445] [fatalFallback] [error] Exception::raise(): ./core/TypePtr.h:223 enforced condition store != 0 has failed: (no message provided)

    [2022-08-01 22:09:09.490] [fatalFallback] [error] Backtrace:
      #3 0xc859b2
      #4 0xdbc197 sorbet::core::TypePtr::tag()
      #5 0xef9fe7 sorbet::realmain::lsp::(anonymous namespace)::locsForType()::$_13::operator()()
      #6 0xef95d3 sorbet::typecaseHelper<>()
      #7 0xef8f85 sorbet::typecase<>()
      #8 0xef8b0a sorbet::realmain::lsp::(anonymous namespace)::locsForType()
      #9 0xef859f sorbet::realmain::lsp::TypeDefinitionTask::runRequest()
      #10 0xda699c sorbet::realmain::lsp::LSPRequestTask::run()
      #11 0xf160f4 sorbet::realmain::lsp::(anonymous namespace)::TypecheckerTask::run()
      #12 0xf1454e sorbet::realmain::lsp::LSPTypecheckerCoordinator::asyncRunInternal()
      #13 0xf14620 sorbet::realmain::lsp::LSPTypecheckerCoordinator::syncRun()
      #14 0xf12d44 sorbet::realmain::lsp::LSPLoop::runTask()
      #15 0xf12698 sorbet::realmain::lsp::LSPLoop::processRequests()
      #16 0xf0410d sorbet::realmain::lsp::SingleThreadedLSPWrapper::getLSPResponsesFor()
      #17 0xcbf398 sorbet::test::getLSPResponsesFor()
      #18 0xcbcece sorbet::test::getLSPResponsesFor()
      #19 0xcf1709 sorbet::test::TypeDefAssertion::check()
      #20 0xbbff18 sorbet::test::_DOCTEST_ANON_FUNC_71()
      #21 0x1d060a9 doctest::Context::run()
      #22 0xbc2380 main
      #23 0x7f162d27c083 __libc_start_main
      #24 0xbb34ae _start

    [2022-08-01 22:09:09.496] [fatalFallback] [error] Backtrace:
      #3 0x1d8f6e8 std::terminate()
      #4 0xbcb94b
      #5 0xdbc1c9
      #6 0xef9fe7 sorbet::realmain::lsp::(anonymous namespace)::locsForType()::$_13::operator()()
      #7 0xef95d3 sorbet::typecaseHelper<>()
      #8 0xef8f85 sorbet::typecase<>()
      #9 0xef8b0a sorbet::realmain::lsp::(anonymous namespace)::locsForType()
      #10 0xef859f sorbet::realmain::lsp::TypeDefinitionTask::runRequest()
      #11 0xda699c sorbet::realmain::lsp::LSPRequestTask::run()
      #12 0xf160f4 sorbet::realmain::lsp::(anonymous namespace)::TypecheckerTask::run()
      #13 0xf1454e sorbet::realmain::lsp::LSPTypecheckerCoordinator::asyncRunInternal()
      #14 0xf14620 sorbet::realmain::lsp::LSPTypecheckerCoordinator::syncRun()
      #15 0xf12d44 sorbet::realmain::lsp::LSPLoop::runTask()
      #16 0xf12698 sorbet::realmain::lsp::LSPLoop::processRequests()
      #17 0xf0410d sorbet::realmain::lsp::SingleThreadedLSPWrapper::getLSPResponsesFor()
      #18 0xcbf398 sorbet::test::getLSPResponsesFor()
      #19 0xcbcece sorbet::test::getLSPResponsesFor()
      #20 0xcf1709 sorbet::test::TypeDefAssertion::check()
      #21 0xbbff18 sorbet::test::_DOCTEST_ANON_FUNC_71()
      #22 0x1d060a9 doctest::Context::run()
      #23 0xbc2380 main
      #24 0x7f162d27c083 __libc_start_main
      #25 0xbb34ae _start

    libc++abi: terminate_handler unexpectedly returned
    ===============================================================================
    test/lsp_test_runner.cc:497:
    TEST CASE:  LSPTest

    test/lsp_test_runner.cc:497: FATAL ERROR: test case CRASHED: SIGABRT - Abort (abnormal termination) signal
jez added a commit that referenced this issue Aug 1, 2022
* Add a failing test

    + exec test/lsp_test_runner --single_test=test/testdata/lsp/go_to_type_definition.rb
    Pausing
    Resuming
    [doctest] doctest version is "2.4.1"
    [doctest] run with "--help" for options
    [2022-08-01 22:09:09.445] [fatalFallback] [error] Exception::raise(): ./core/TypePtr.h:223 enforced condition store != 0 has failed: (no message provided)

    [2022-08-01 22:09:09.490] [fatalFallback] [error] Backtrace:
      #3 0xc859b2
      #4 0xdbc197 sorbet::core::TypePtr::tag()
      #5 0xef9fe7 sorbet::realmain::lsp::(anonymous namespace)::locsForType()::$_13::operator()()
      #6 0xef95d3 sorbet::typecaseHelper<>()
      #7 0xef8f85 sorbet::typecase<>()
      #8 0xef8b0a sorbet::realmain::lsp::(anonymous namespace)::locsForType()
      #9 0xef859f sorbet::realmain::lsp::TypeDefinitionTask::runRequest()
      #10 0xda699c sorbet::realmain::lsp::LSPRequestTask::run()
      #11 0xf160f4 sorbet::realmain::lsp::(anonymous namespace)::TypecheckerTask::run()
      #12 0xf1454e sorbet::realmain::lsp::LSPTypecheckerCoordinator::asyncRunInternal()
      #13 0xf14620 sorbet::realmain::lsp::LSPTypecheckerCoordinator::syncRun()
      #14 0xf12d44 sorbet::realmain::lsp::LSPLoop::runTask()
      #15 0xf12698 sorbet::realmain::lsp::LSPLoop::processRequests()
      #16 0xf0410d sorbet::realmain::lsp::SingleThreadedLSPWrapper::getLSPResponsesFor()
      #17 0xcbf398 sorbet::test::getLSPResponsesFor()
      #18 0xcbcece sorbet::test::getLSPResponsesFor()
      #19 0xcf1709 sorbet::test::TypeDefAssertion::check()
      #20 0xbbff18 sorbet::test::_DOCTEST_ANON_FUNC_71()
      #21 0x1d060a9 doctest::Context::run()
      #22 0xbc2380 main
      #23 0x7f162d27c083 __libc_start_main
      #24 0xbb34ae _start

    [2022-08-01 22:09:09.496] [fatalFallback] [error] Backtrace:
      #3 0x1d8f6e8 std::terminate()
      #4 0xbcb94b
      #5 0xdbc1c9
      #6 0xef9fe7 sorbet::realmain::lsp::(anonymous namespace)::locsForType()::$_13::operator()()
      #7 0xef95d3 sorbet::typecaseHelper<>()
      #8 0xef8f85 sorbet::typecase<>()
      #9 0xef8b0a sorbet::realmain::lsp::(anonymous namespace)::locsForType()
      #10 0xef859f sorbet::realmain::lsp::TypeDefinitionTask::runRequest()
      #11 0xda699c sorbet::realmain::lsp::LSPRequestTask::run()
      #12 0xf160f4 sorbet::realmain::lsp::(anonymous namespace)::TypecheckerTask::run()
      #13 0xf1454e sorbet::realmain::lsp::LSPTypecheckerCoordinator::asyncRunInternal()
      #14 0xf14620 sorbet::realmain::lsp::LSPTypecheckerCoordinator::syncRun()
      #15 0xf12d44 sorbet::realmain::lsp::LSPLoop::runTask()
      #16 0xf12698 sorbet::realmain::lsp::LSPLoop::processRequests()
      #17 0xf0410d sorbet::realmain::lsp::SingleThreadedLSPWrapper::getLSPResponsesFor()
      #18 0xcbf398 sorbet::test::getLSPResponsesFor()
      #19 0xcbcece sorbet::test::getLSPResponsesFor()
      #20 0xcf1709 sorbet::test::TypeDefAssertion::check()
      #21 0xbbff18 sorbet::test::_DOCTEST_ANON_FUNC_71()
      #22 0x1d060a9 doctest::Context::run()
      #23 0xbc2380 main
      #24 0x7f162d27c083 __libc_start_main
      #25 0xbb34ae _start

    libc++abi: terminate_handler unexpectedly returned
    ===============================================================================
    test/lsp_test_runner.cc:497:
    TEST CASE:  LSPTest

    test/lsp_test_runner.cc:497: FATAL ERROR: test case CRASHED: SIGABRT - Abort (abnormal termination) signal

* Set type to untyped if null
@jez
Copy link
Collaborator

jez commented Aug 6, 2022

I think this is a simple problem of has_kwarg not having a sig. Without a signature, Sorbet simply binds value to foo, which is allowed since foo is T.untyped in the absence of a sig.

Adding a sig makes the expected error appear:

→ View on sorbet.run

# typed: true

class S
  extend T::Sig
  sig {params(value: Integer, foo: Integer, baz: Integer).void}
  def self.has_kwarg(value, foo = 1, baz: 2)
  end
end

class C
  extend T::Sig
  extend T::Generic
  A = type_member
  sig {params(value: A).void}
  def dd(value)
    S.has_kwarg(1, value)
  end
end

Observed output

editor.rb:16: Expected Integer but found C::A for argument foo https://srb.help/7002
    16 |    S.has_kwarg(1, value)
                           ^^^^^
  Expected Integer for argument foo of method S.has_kwarg:
    editor.rb:5:
     5 |  sig {params(value: Integer, foo: Integer, baz: Integer).void}
                                      ^^^
  Got C::A originating from:
    editor.rb:15:
    15 |  def dd(value)
                 ^^^^^
Errors: 1

@jez jez closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2022
jez added a commit that referenced this issue Oct 26, 2023
    * thread #1, name = 'lsp_test_runner', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
      * frame #0: 0x0000000000e3d2c5 lsp_test_runner`absl::inlined_vector_internal::Storage<sorbet::core::SymbolRef, 1ul, std::__1::allocator<sorbet::core::SymbolRef>>::GetIsAllocated(this=0x0000000000000000) const at inlined_vector.h:353:40
        frame #1: 0x0000000000eabec9 lsp_test_runner`absl::InlinedVector<sorbet::core::SymbolRef, 1ul, std::__1::allocator<sorbet::core::SymbolRef>>::data(this=0x0000000000000000) const at inlined_vector.h:305:21
        frame #2: 0x0000000000eabb3a lsp_test_runner`absl::InlinedVector<sorbet::core::SymbolRef, 1ul, std::__1::allocator<sorbet::core::SymbolRef>>::operator=(this=0x00007fffffff6fe8, other=0x0000000000000000) at inlined_vector.h:465:40
        frame #3: 0x0000000000ea879f lsp_test_runner`sorbet::realmain::lsp::(anonymous namespace)::matchesQuery(ctx=Context @ 0x00007fffffff7100, lit=0x00000000035c0cc0, lspQuery=0x0000000002d0bfd0, symbolBeforeDealias=(_id = 24890)) at DefLocSaver.cc:121:24
        frame #4: 0x0000000000ea8357 lsp_test_runner`sorbet::realmain::lsp::DefLocSaver::postTransformConstantLit(this=0x00007fffffff86b8, ctx=Context @ 0x00007fffffff7148, tree=0x0000000002be4140) at DefLocSaver.cc:144:5
        frame #5: 0x0000000000e682da lsp_test_runner`decltype(self=0x00007fffffff86b8, args=0x00007fffffff7380, args=0x0000000002be4140) sorbet::ast::MapFunctions<(sorbet::ast::TreeMapKind)1>::CALL_MEMBER_impl_postTransformConstantLit<sorbet::realmain::lsp::DefLocSaver, true>::call<sorbet::core::Context&, sorbet::ast::ExpressionPtr&>(sorbet::realmain::lsp::DefLocSaver&, sorbet::core::Context&, sorbet::ast::ExpressionPtr&) at treemap.h:168:5
        frame #6: 0x0000000000e65ce8 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapConstantLit(this=0x00007fffffff8648, v=0x0000000002be4140, ctx=Context @ 0x00007fffffff7380) at treemap.h:417:9
        frame #7: 0x0000000000e64515 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x0000000002be4140, ctx=Context @ 0x00007fffffff7780) at treemap.h:569:28
        frame #8: 0x0000000000e649a0 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapSend(this=0x00007fffffff8648, v=0x0000000002c9d308, ctx=Context @ 0x00007fffffff7bd0) at treemap.h:372:13
        frame #9: 0x0000000000e63c11 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x0000000002c9d308, ctx=Context @ 0x00007fffffff7c50) at treemap.h:491:28
        frame #10: 0x0000000000e64dd4 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapClassDef(this=0x00007fffffff8648, v=0x0000000002bc0fa0, ctx=Context @ 0x00007fffffff8070) at treemap.h:249:13
        frame #11: 0x0000000000e63c75 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x0000000002bc0fa0, ctx=Context @ 0x00007fffffff80f0) at treemap.h:494:28
        frame #12: 0x0000000000e65e78 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapInsSeq(this=0x00007fffffff8648, v=0x000000000246d3e0, ctx=Context @ 0x00007fffffff82f0) at treemap.h:438:13
        frame #13: 0x0000000000e645c6 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x000000000246d3e0, ctx=Context @ 0x00007fffffff8638) at treemap.h:582:28
        frame #14: 0x0000000000e6397a lsp_test_runner`void sorbet::ast::TreeWalk::apply<sorbet::core::Context, sorbet::realmain::lsp::DefLocSaver>(ctx=Context @ 0x00007fffffff8680, func=0x00007fffffff86b8, to=0x000000000246d3e0) at treemap.h:622:20
        frame #15: 0x0000000000e52acc lsp_test_runner`sorbet::realmain::lsp::(anonymous namespace)::tryApplyDefLocSaver(gs=0x0000000002d0bf90, indexedCopies=size=1) at LSPTypechecker.cc:621:9
        frame #16: 0x0000000000e5235d lsp_test_runner`sorbet::realmain::lsp::LSPTypechecker::query(this=0x0000000002472050, q=0x00007fffffff8ca8, filesForQuery=size=1, workers=0x000000000246e9c0) const at LSPTypechecker.cc:643:5
        frame #17: 0x0000000000e53e1b lsp_test_runner`sorbet::realmain::lsp::LSPTypecheckerDelegate::query(this=0x0000000002bc27c0, q=0x00007fffffff8ca8, filesForQuery=size=1) const at LSPTypechecker.cc:770:24
        frame #18: 0x0000000000e42128 lsp_test_runner`sorbet::realmain::lsp::LSPQuery::byLoc(config=0x000000000246bcd8, typechecker=0x0000000002bc27c0, uri="file:///Users/jez/stripe/sorbet/test/testdata/lsp/hover_static_field_alias_to_nothing.rb", pos=0x0000000002bc0500, forMethod=TextDocumentHover, errorIfFileIsUntyped=true) at LSPQuery.cc:89:24
        frame #19: 0x0000000000f74ee0 lsp_test_runner`sorbet::realmain::lsp::HoverTask::runRequest(this=0x0000000002d373d0, typechecker=0x0000000002bc27c0) at hover.cc:44:19
        frame #20: 0x0000000000e3226c lsp_test_runner`sorbet::realmain::lsp::LSPRequestTask::run(this=0x0000000002d373d0, typechecker=0x0000000002bc27c0) at LSPTask.cc:222:21
        frame #21: 0x0000000000fbf3e4 lsp_test_runner`sorbet::realmain::lsp::(anonymous namespace)::TypecheckerTask::run(this=0x0000000002bc0028) at LSPTypecheckerCoordinator.cc:58:19
        frame #22: 0x0000000000fbda0e lsp_test_runner`sorbet::realmain::lsp::LSPTypecheckerCoordinator::asyncRunInternal(this=0x0000000002471db0, task=std::__1::shared_ptr<sorbet::core::lsp::Task>::element_type @ 0x0000000002bc0028 strong=2 weak=1) at LSPTypecheckerCoordinator.cc:129:15
        frame #23: 0x0000000000fbdae0 lsp_test_runner`sorbet::realmain::lsp::LSPTypecheckerCoordinator::syncRun(this=0x0000000002471db0, task=nullptr) at LSPTypecheckerCoordinator.cc:137:5
        frame #24: 0x0000000000fb34f8 lsp_test_runner`sorbet::realmain::lsp::LSPLoop::runTask(this=0x0000000002471d28, task=nullptr) at LSPLoop.cc:263:26
        frame #25: 0x0000000000fb2e38 lsp_test_runner`sorbet::realmain::lsp::LSPLoop::processRequests(this=0x0000000002471d28, messages=<unavailable>) at LSPLoop.cc:218:13
        frame #26: 0x0000000000fa3d6d lsp_test_runner`sorbet::realmain::lsp::SingleThreadedLSPWrapper::getLSPResponsesFor(this=0x000000000246ea10, messages=size=0) at wrapper.cc:68:14
        frame #27: 0x0000000000d2afd7 lsp_test_runner`sorbet::test::getLSPResponsesFor(wrapper=0x000000000246ea10, messages=size=0) at lsp.cc:490:27
        frame #28: 0x0000000000d2894e lsp_test_runner`sorbet::test::getLSPResponsesFor(wrapper=0x000000000246ea10, message=nullptr) at lsp.cc:530:12
        frame #29: 0x0000000000d664a3 lsp_test_runner`sorbet::test::HoverAssertion::check(this=0x0000000001eada28, sourceFileContents=0x00007fffffffc018, wrapper=0x000000000246ea10, nextId=0x00007fffffffbf24, errorPrefix="") at position_assertions.cc:1318:22
        frame #30: 0x0000000000d66224 lsp_test_runner`sorbet::test::HoverAssertion::checkAll(assertions=size=2, sourceFileContents=0x00007fffffffc018, wrapper=0x000000000246ea10, nextId=0x00007fffffffbf24, errorPrefix="") at position_assertions.cc:1280:30
        frame #31: 0x0000000000c29f46 lsp_test_runner`sorbet::test::DOCTEST_ANON_FUNC_58() at lsp_test_runner.cc:842:5
        frame #32: 0x0000000001de1180 lsp_test_runner`doctest::Context::run(this=0x00007fffffffcd58) at doctest.h:6930:21
        frame #33: 0x0000000000c2bcd0 lsp_test_runner`main(argc=2, argv=0x00007fffffffd258) at lsp_test_runner.cc:976:20
        frame #34: 0x00007ffff7c29d90 libc.so.6`__libc_start_call_main(main=(lsp_test_runner`main at lsp_test_runner.cc:959), argc=2, argv=0x00007fffffffd258) at libc_start_call_main.h:58:16
        frame #35: 0x00007ffff7c29e40 libc.so.6`__libc_start_main_impl(main=(lsp_test_runner`main at lsp_test_runner.cc:959), argc=2, argv=0x00007fffffffd258, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffd248) at libc-start.c:392:3
        frame #36: 0x0000000000c1ac85 lsp_test_runner`_start + 37
jez added a commit that referenced this issue Oct 29, 2023
* Add a failing test

    * thread #1, name = 'lsp_test_runner', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
      * frame #0: 0x0000000000e3d2c5 lsp_test_runner`absl::inlined_vector_internal::Storage<sorbet::core::SymbolRef, 1ul, std::__1::allocator<sorbet::core::SymbolRef>>::GetIsAllocated(this=0x0000000000000000) const at inlined_vector.h:353:40
        frame #1: 0x0000000000eabec9 lsp_test_runner`absl::InlinedVector<sorbet::core::SymbolRef, 1ul, std::__1::allocator<sorbet::core::SymbolRef>>::data(this=0x0000000000000000) const at inlined_vector.h:305:21
        frame #2: 0x0000000000eabb3a lsp_test_runner`absl::InlinedVector<sorbet::core::SymbolRef, 1ul, std::__1::allocator<sorbet::core::SymbolRef>>::operator=(this=0x00007fffffff6fe8, other=0x0000000000000000) at inlined_vector.h:465:40
        frame #3: 0x0000000000ea879f lsp_test_runner`sorbet::realmain::lsp::(anonymous namespace)::matchesQuery(ctx=Context @ 0x00007fffffff7100, lit=0x00000000035c0cc0, lspQuery=0x0000000002d0bfd0, symbolBeforeDealias=(_id = 24890)) at DefLocSaver.cc:121:24
        frame #4: 0x0000000000ea8357 lsp_test_runner`sorbet::realmain::lsp::DefLocSaver::postTransformConstantLit(this=0x00007fffffff86b8, ctx=Context @ 0x00007fffffff7148, tree=0x0000000002be4140) at DefLocSaver.cc:144:5
        frame #5: 0x0000000000e682da lsp_test_runner`decltype(self=0x00007fffffff86b8, args=0x00007fffffff7380, args=0x0000000002be4140) sorbet::ast::MapFunctions<(sorbet::ast::TreeMapKind)1>::CALL_MEMBER_impl_postTransformConstantLit<sorbet::realmain::lsp::DefLocSaver, true>::call<sorbet::core::Context&, sorbet::ast::ExpressionPtr&>(sorbet::realmain::lsp::DefLocSaver&, sorbet::core::Context&, sorbet::ast::ExpressionPtr&) at treemap.h:168:5
        frame #6: 0x0000000000e65ce8 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapConstantLit(this=0x00007fffffff8648, v=0x0000000002be4140, ctx=Context @ 0x00007fffffff7380) at treemap.h:417:9
        frame #7: 0x0000000000e64515 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x0000000002be4140, ctx=Context @ 0x00007fffffff7780) at treemap.h:569:28
        frame #8: 0x0000000000e649a0 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapSend(this=0x00007fffffff8648, v=0x0000000002c9d308, ctx=Context @ 0x00007fffffff7bd0) at treemap.h:372:13
        frame #9: 0x0000000000e63c11 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x0000000002c9d308, ctx=Context @ 0x00007fffffff7c50) at treemap.h:491:28
        frame #10: 0x0000000000e64dd4 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapClassDef(this=0x00007fffffff8648, v=0x0000000002bc0fa0, ctx=Context @ 0x00007fffffff8070) at treemap.h:249:13
        frame #11: 0x0000000000e63c75 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x0000000002bc0fa0, ctx=Context @ 0x00007fffffff80f0) at treemap.h:494:28
        frame #12: 0x0000000000e65e78 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapInsSeq(this=0x00007fffffff8648, v=0x000000000246d3e0, ctx=Context @ 0x00007fffffff82f0) at treemap.h:438:13
        frame #13: 0x0000000000e645c6 lsp_test_runner`sorbet::ast::TreeMapper<sorbet::realmain::lsp::DefLocSaver, sorbet::core::Context, (sorbet::ast::TreeMapKind)1, (sorbet::ast::TreeMapDepthKind)0>::mapIt(this=0x00007fffffff8648, what=0x000000000246d3e0, ctx=Context @ 0x00007fffffff8638) at treemap.h:582:28
        frame #14: 0x0000000000e6397a lsp_test_runner`void sorbet::ast::TreeWalk::apply<sorbet::core::Context, sorbet::realmain::lsp::DefLocSaver>(ctx=Context @ 0x00007fffffff8680, func=0x00007fffffff86b8, to=0x000000000246d3e0) at treemap.h:622:20
        frame #15: 0x0000000000e52acc lsp_test_runner`sorbet::realmain::lsp::(anonymous namespace)::tryApplyDefLocSaver(gs=0x0000000002d0bf90, indexedCopies=size=1) at LSPTypechecker.cc:621:9
        frame #16: 0x0000000000e5235d lsp_test_runner`sorbet::realmain::lsp::LSPTypechecker::query(this=0x0000000002472050, q=0x00007fffffff8ca8, filesForQuery=size=1, workers=0x000000000246e9c0) const at LSPTypechecker.cc:643:5
        frame #17: 0x0000000000e53e1b lsp_test_runner`sorbet::realmain::lsp::LSPTypecheckerDelegate::query(this=0x0000000002bc27c0, q=0x00007fffffff8ca8, filesForQuery=size=1) const at LSPTypechecker.cc:770:24
        frame #18: 0x0000000000e42128 lsp_test_runner`sorbet::realmain::lsp::LSPQuery::byLoc(config=0x000000000246bcd8, typechecker=0x0000000002bc27c0, uri="file:///Users/jez/stripe/sorbet/test/testdata/lsp/hover_static_field_alias_to_nothing.rb", pos=0x0000000002bc0500, forMethod=TextDocumentHover, errorIfFileIsUntyped=true) at LSPQuery.cc:89:24
        frame #19: 0x0000000000f74ee0 lsp_test_runner`sorbet::realmain::lsp::HoverTask::runRequest(this=0x0000000002d373d0, typechecker=0x0000000002bc27c0) at hover.cc:44:19
        frame #20: 0x0000000000e3226c lsp_test_runner`sorbet::realmain::lsp::LSPRequestTask::run(this=0x0000000002d373d0, typechecker=0x0000000002bc27c0) at LSPTask.cc:222:21
        frame #21: 0x0000000000fbf3e4 lsp_test_runner`sorbet::realmain::lsp::(anonymous namespace)::TypecheckerTask::run(this=0x0000000002bc0028) at LSPTypecheckerCoordinator.cc:58:19
        frame #22: 0x0000000000fbda0e lsp_test_runner`sorbet::realmain::lsp::LSPTypecheckerCoordinator::asyncRunInternal(this=0x0000000002471db0, task=std::__1::shared_ptr<sorbet::core::lsp::Task>::element_type @ 0x0000000002bc0028 strong=2 weak=1) at LSPTypecheckerCoordinator.cc:129:15
        frame #23: 0x0000000000fbdae0 lsp_test_runner`sorbet::realmain::lsp::LSPTypecheckerCoordinator::syncRun(this=0x0000000002471db0, task=nullptr) at LSPTypecheckerCoordinator.cc:137:5
        frame #24: 0x0000000000fb34f8 lsp_test_runner`sorbet::realmain::lsp::LSPLoop::runTask(this=0x0000000002471d28, task=nullptr) at LSPLoop.cc:263:26
        frame #25: 0x0000000000fb2e38 lsp_test_runner`sorbet::realmain::lsp::LSPLoop::processRequests(this=0x0000000002471d28, messages=<unavailable>) at LSPLoop.cc:218:13
        frame #26: 0x0000000000fa3d6d lsp_test_runner`sorbet::realmain::lsp::SingleThreadedLSPWrapper::getLSPResponsesFor(this=0x000000000246ea10, messages=size=0) at wrapper.cc:68:14
        frame #27: 0x0000000000d2afd7 lsp_test_runner`sorbet::test::getLSPResponsesFor(wrapper=0x000000000246ea10, messages=size=0) at lsp.cc:490:27
        frame #28: 0x0000000000d2894e lsp_test_runner`sorbet::test::getLSPResponsesFor(wrapper=0x000000000246ea10, message=nullptr) at lsp.cc:530:12
        frame #29: 0x0000000000d664a3 lsp_test_runner`sorbet::test::HoverAssertion::check(this=0x0000000001eada28, sourceFileContents=0x00007fffffffc018, wrapper=0x000000000246ea10, nextId=0x00007fffffffbf24, errorPrefix="") at position_assertions.cc:1318:22
        frame #30: 0x0000000000d66224 lsp_test_runner`sorbet::test::HoverAssertion::checkAll(assertions=size=2, sourceFileContents=0x00007fffffffc018, wrapper=0x000000000246ea10, nextId=0x00007fffffffbf24, errorPrefix="") at position_assertions.cc:1280:30
        frame #31: 0x0000000000c29f46 lsp_test_runner`sorbet::test::DOCTEST_ANON_FUNC_58() at lsp_test_runner.cc:842:5
        frame #32: 0x0000000001de1180 lsp_test_runner`doctest::Context::run(this=0x00007fffffffcd58) at doctest.h:6930:21
        frame #33: 0x0000000000c2bcd0 lsp_test_runner`main(argc=2, argv=0x00007fffffffd258) at lsp_test_runner.cc:976:20
        frame #34: 0x00007ffff7c29d90 libc.so.6`__libc_start_call_main(main=(lsp_test_runner`main at lsp_test_runner.cc:959), argc=2, argv=0x00007fffffffd258) at libc_start_call_main.h:58:16
        frame #35: 0x00007ffff7c29e40 libc.so.6`__libc_start_main_impl(main=(lsp_test_runner`main at lsp_test_runner.cc:959), argc=2, argv=0x00007fffffffd258, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffd248) at libc-start.c:392:3
        frame #36: 0x0000000000c1ac85 lsp_test_runner`_start + 37

* Fix failing test
jez added a commit that referenced this issue Nov 2, 2023
    ❯ sorbet test/testdata/definition_validator/superclass_class_loc__1.rb test/testdata/definition_validator/superclass_class_loc__2.rbi
    msg="Bad offset2Pos off" path="test/testdata/definition_validator/superclass_class_loc__1.rb" off="778""
    source="# typed: true\n\nmodule Parent\nend\n\nclass Child < Parent\nend\n"
    Exception::raise(): core/Loc.cc:43 enforced condition false has failed: (no message provided)

    Backtrace:
      #3 0xbb3f32
      #4 0x1a5b870 sorbet::core::Loc::offset2Pos()
      #5 0x1a5bbda sorbet::core::Loc::position()
      #6 0x1a5da17 sorbet::core::Loc::filePosToString()
      #7 0x19df6b8 sorbet::core::Error::toString()
      #8 0x19f292e sorbet::core::ErrorQueue::pushError()
      #9 0x1a3e882 sorbet::core::GlobalState::_error()
      #10 0x19e11c0 sorbet::core::ErrorBuilder::~ErrorBuilder()
      #11 0x1288d5a sorbet::definition_validator::(anonymous namespace)::validateSuperClass()
      #12 0x12861b6 sorbet::definition_validator::(anonymous namespace)::ValidateWalk::preTransformClassDef()
      #13 0x1285f6a sorbet::ast::MapFunctions<>::CALL_MEMBER_impl_preTransformClassDef<>::call<>()
      #14 0x1284c0f sorbet::ast::TreeMapper<>::mapClassDef()
      #15 0x1283d55 sorbet::ast::TreeMapper<>::mapIt()
      #16 0x1285a58 sorbet::ast::TreeMapper<>::mapInsSeq()
      #17 0x12846a6 sorbet::ast::TreeMapper<>::mapIt()
      #18 0x12839fa sorbet::ast::TreeWalk::apply<>()
      #19 0x12838db sorbet::definition_validator::runOne()
      #20 0xf5e8b0 sorbet::realmain::pipeline::(anonymous namespace)::typecheckOne()
      #21 0xf5e50d sorbet::realmain::pipeline::typecheck()::$_5::operator()()
      #22 0xf5e19d std::__1::__invoke<>()
      #23 0xf5e14d std::__1::__invoke_void_return_wrapper<>::__call<>()
      #24 0xf5e11d std::__1::__function::__alloc_func<>::operator()()
      #25 0xf5d2e9 std::__1::__function::__func<>::operator()()
      #26 0x1753d52 std::__1::__function::__value_func<>::operator()()
      #27 0x174a5f5 std::__1::function<>::operator()()
      #28 0x1bf5d7a sorbet::WorkerPoolImpl::multiplexJob()::$_2::operator()()
      #29 0x1bf5d1d std::__1::__invoke<>()
      #30 0x1bf5ccd std::__1::__invoke_void_return_wrapper<>::__call<>()
      #31 0x1bf5c9d std::__1::__function::__alloc_func<>::operator()()
      #32 0x1bf4ea9 std::__1::__function::__func<>::operator()()
      #33 0x1bfa5b2 std::__1::__function::__value_func<>::operator()()
      #34 0x1bf91d5 std::__1::function<>::operator()()
      #35 0x1bf313d sorbet::WorkerPoolImpl::WorkerPoolImpl()::$_0::operator()()
      #36 0x1bf307d std::__1::__invoke<>()
      #37 0x1bf302d std::__1::__invoke_void_return_wrapper<>::__call<>()
      #38 0x1bf2ffd std::__1::__function::__alloc_func<>::operator()()
      #39 0x1bf2219 std::__1::__function::__func<>::operator()()
      #40 0x1753d52 std::__1::__function::__value_func<>::operator()()
      #41 0x174a5f5 std::__1::function<>::operator()()
      #42 0x1bfdd53 Joinable::trampoline()
      #43 0x7f5e1d694b43
      #44 0x7f5e1d726a00
jez added a commit that referenced this issue Nov 2, 2023
* Add failing test

    ❯ sorbet test/testdata/definition_validator/superclass_class_loc__1.rb test/testdata/definition_validator/superclass_class_loc__2.rbi
    msg="Bad offset2Pos off" path="test/testdata/definition_validator/superclass_class_loc__1.rb" off="778""
    source="# typed: true\n\nmodule Parent\nend\n\nclass Child < Parent\nend\n"
    Exception::raise(): core/Loc.cc:43 enforced condition false has failed: (no message provided)

    Backtrace:
      #3 0xbb3f32
      #4 0x1a5b870 sorbet::core::Loc::offset2Pos()
      #5 0x1a5bbda sorbet::core::Loc::position()
      #6 0x1a5da17 sorbet::core::Loc::filePosToString()
      #7 0x19df6b8 sorbet::core::Error::toString()
      #8 0x19f292e sorbet::core::ErrorQueue::pushError()
      #9 0x1a3e882 sorbet::core::GlobalState::_error()
      #10 0x19e11c0 sorbet::core::ErrorBuilder::~ErrorBuilder()
      #11 0x1288d5a sorbet::definition_validator::(anonymous namespace)::validateSuperClass()
      #12 0x12861b6 sorbet::definition_validator::(anonymous namespace)::ValidateWalk::preTransformClassDef()
      #13 0x1285f6a sorbet::ast::MapFunctions<>::CALL_MEMBER_impl_preTransformClassDef<>::call<>()
      #14 0x1284c0f sorbet::ast::TreeMapper<>::mapClassDef()
      #15 0x1283d55 sorbet::ast::TreeMapper<>::mapIt()
      #16 0x1285a58 sorbet::ast::TreeMapper<>::mapInsSeq()
      #17 0x12846a6 sorbet::ast::TreeMapper<>::mapIt()
      #18 0x12839fa sorbet::ast::TreeWalk::apply<>()
      #19 0x12838db sorbet::definition_validator::runOne()
      #20 0xf5e8b0 sorbet::realmain::pipeline::(anonymous namespace)::typecheckOne()
      #21 0xf5e50d sorbet::realmain::pipeline::typecheck()::$_5::operator()()
      #22 0xf5e19d std::__1::__invoke<>()
      #23 0xf5e14d std::__1::__invoke_void_return_wrapper<>::__call<>()
      #24 0xf5e11d std::__1::__function::__alloc_func<>::operator()()
      #25 0xf5d2e9 std::__1::__function::__func<>::operator()()
      #26 0x1753d52 std::__1::__function::__value_func<>::operator()()
      #27 0x174a5f5 std::__1::function<>::operator()()
      #28 0x1bf5d7a sorbet::WorkerPoolImpl::multiplexJob()::$_2::operator()()
      #29 0x1bf5d1d std::__1::__invoke<>()
      #30 0x1bf5ccd std::__1::__invoke_void_return_wrapper<>::__call<>()
      #31 0x1bf5c9d std::__1::__function::__alloc_func<>::operator()()
      #32 0x1bf4ea9 std::__1::__function::__func<>::operator()()
      #33 0x1bfa5b2 std::__1::__function::__value_func<>::operator()()
      #34 0x1bf91d5 std::__1::function<>::operator()()
      #35 0x1bf313d sorbet::WorkerPoolImpl::WorkerPoolImpl()::$_0::operator()()
      #36 0x1bf307d std::__1::__invoke<>()
      #37 0x1bf302d std::__1::__invoke_void_return_wrapper<>::__call<>()
      #38 0x1bf2ffd std::__1::__function::__alloc_func<>::operator()()
      #39 0x1bf2219 std::__1::__function::__func<>::operator()()
      #40 0x1753d52 std::__1::__function::__value_func<>::operator()()
      #41 0x174a5f5 std::__1::function<>::operator()()
      #42 0x1bfdd53 Joinable::trampoline()
      #43 0x7f5e1d694b43
      #44 0x7f5e1d726a00

* Fix failing test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants