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

Enumerator is defined as generic but can't be built #7

Closed
gmalette opened this issue Dec 14, 2018 · 3 comments
Closed

Enumerator is defined as generic but can't be built #7

gmalette opened this issue Dec 14, 2018 · 3 comments
Labels
runtime Related to the sorbet-runtime gem

Comments

@gmalette
Copy link
Contributor

::Enumerator is defined as a T::Generic, so it requires parameterization; one cannot do

sig { returns(Enumerator) }

However, the ::Enumerator does not have a self.[](type) method, and it does not have a T::Enumerator sibling.

Most other generics from the stdlib have a T::* sibling to allow defining their type. Enumerator probably would need one too (it feels kind of alone right now).

@elliottt
Copy link
Contributor

This works for me:

# typed: true
extend T::Sig
sig {params(x: Enumerator[T.untyped]).void}
def foo(x)
end

@DarkDimius
Copy link
Collaborator

@elliottt this code will fail in runtime.

@DarkDimius DarkDimius reopened this May 22, 2019
@Morriar Morriar added the runtime Related to the sorbet-runtime gem label Aug 19, 2020
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
Copy link
Collaborator

jez commented Feb 4, 2022

This was fixed in #915

@jez jez closed this as completed Feb 4, 2022
jez added a commit that referenced this issue May 27, 2022
The crash looked like this:

    Exception::raise(): Should never happen

    Backtrace:
      #3 0xccda75 sorbet::core::ClassOrModule::isClass()
      #4 0x13de160 sorbet::resolver::(anonymous namespace)::ResolveConstantsWalk::resolveClassMethodsJob<>()
      #5 0x13d2407 sorbet::resolver::(anonymous namespace)::ResolveConstantsWalk::resolveConstants<>()
      #6 0x13d0a15 sorbet::resolver::Resolver::run()
      #7 0xeaf34b sorbet::realmain::pipeline::resolve()
      #8 0xb1b1ae sorbet::realmain::realmain()
      #9 0xb15a22 main
      #10 0x7ffff7c65083 __libc_start_main
      #11 0xb1592e _start
jez added a commit that referenced this issue May 27, 2022
* Fix crash on mixes_in_class_methods for undeclared

The crash looked like this:

    Exception::raise(): Should never happen

    Backtrace:
      #3 0xccda75 sorbet::core::ClassOrModule::isClass()
      #4 0x13de160 sorbet::resolver::(anonymous namespace)::ResolveConstantsWalk::resolveClassMethodsJob<>()
      #5 0x13d2407 sorbet::resolver::(anonymous namespace)::ResolveConstantsWalk::resolveConstants<>()
      #6 0x13d0a15 sorbet::resolver::Resolver::run()
      #7 0xeaf34b sorbet::realmain::pipeline::resolve()
      #8 0xb1b1ae sorbet::realmain::realmain()
      #9 0xb15a22 main
      #10 0x7ffff7c65083 __libc_start_main
      #11 0xb1592e _start

* Fix error message
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 added a commit that referenced this issue Nov 11, 2022
    [2022-11-11 19:03:12.439] [fatalFallback] [error] Exception::raise(): core/Symbols.cc:256 enforced condition this->exists() has failed: (no message provided)

    [2022-11-11 19:03:12.479] [fatalFallback] [error] Backtrace:
      #3 0xcac0b2
      #4 0x1ab9d22 sorbet::core::MethodRef::data()
      #5 0xefd88a sorbet::realmain::lsp::(anonymous namespace)::findMethodImplementations()
      #6 0xefc952 sorbet::realmain::lsp::ImplementationTask::runRequest()
      #7 0xdd262c sorbet::realmain::lsp::LSPRequestTask::run()
      #8 0xf56484 sorbet::realmain::lsp::(anonymous namespace)::TypecheckerTask::run()
      #9 0xf54aae sorbet::realmain::lsp::LSPTypecheckerCoordinator::asyncRunInternal()
      #10 0xf54b80 sorbet::realmain::lsp::LSPTypecheckerCoordinator::syncRun()
      #11 0xf4a4a8 sorbet::realmain::lsp::LSPLoop::runTask()
      #12 0xf49de8 sorbet::realmain::lsp::LSPLoop::processRequests()
      #13 0xf3acad sorbet::realmain::lsp::SingleThreadedLSPWrapper::getLSPResponsesFor()
      #14 0xce5c48 sorbet::test::getLSPResponsesFor()
      #15 0xce377e sorbet::test::getLSPResponsesFor()
      #16 0xd28be7 sorbet::test::FindImplementationAssertion::check()
      #17 0xbe7df2 sorbet::test::_DOCTEST_ANON_FUNC_75()
      #18 0x1d2e9f9 doctest::Context::run()
      #19 0xbe9b30 main
      #20 0x7f0b04912083 __libc_start_main
      #21 0xbd9eae _start
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
jez added a commit that referenced this issue May 15, 2024
In clang 15, the sanitizer was catching a stack-use-after-return error
from this multithreaded codepath. The test which caught this was

    //test/cli:test_folder-input-not-found

(Because it is multithreaded, the bug only manifested about 30% of the
time, depending on the order that threads were scheduled by the OS.)

The bug was that we were attempting to (atomically) write to
`pendingJobs` from children threads after the function that spawned
those threads exited.

A sequence of steps that could happen:

- A worker thread would realize that the input was not a directory. It
  would return a result requesting that the parent thread throw an
  exception, and queue up a bunch of jobs that would have the effect of
  shutting down the other threads.

- The parent thread would get scheduled first. It would see that a child
  asked to throw, and it would throw, in effect returning from the
  function before all children were done.

- The children would wake up and attempt to decrement the `pendingJobs`
  variable in the worker threads' closure by reference. That stack slot
  is not there anymore because the enclosing function raised.

The fix is simply wait for all the threads to finish, and only raise the
requested exception after we're sure that all the children threads have
finished processing and shut down.

For posterity, this is what the test failure looked like

    +=================================================================
    +==1781049==ERROR: AddressSanitizer: stack-use-after-return on address 0x7f435a57c140 at pc 0x55cac4f42fd8 bp 0x7f43420ef940 sp 0x7f43420ef938
    +WRITE of size 8 at 0x7f435a57c140 thread T7 (options.findFil)
    +    #0 0x55cac4f42fd7 in unsigned long std::__1::__cxx_atomic_fetch_add[abi:v15007]<unsigned long>(std::__1::__cxx_atomic_base_impl<unsigned long>*, unsigned long, std::__1::memory_order) realmain.cc
    +    #1 0x55cac6e4d9b8 in std::__1::__atomic_base<unsigned long, true>::operator+=[abi:v15007](unsigned long) common.cc
    +    #2 0x55cac6e3f5a6 in std::__1::__function::__func<appendFilesInDir(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, absl::flat_hash_set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, absl::container_internal::StringHash, absl::container_internal::StringHashEq::Eq, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, sorbet::WorkerPool&, bool, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_0, std::__1::allocator<appendFilesInDir(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, absl::flat_hash_set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, absl::container_internal::StringHash, absl::container_internal::StringHashEq::Eq, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, sorbet::WorkerPool&, bool, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_0>, void ()>::operator()() common.cc
    +    #3 0x55cac629c0e1 in std::__1::__function::__value_func<void ()>::operator()[abi:v15007]() const driver.cc
    +    #4 0x55cac6265778 in std::__1::function<void ()>::operator()() const (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x43e7778) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #5 0x55cac6ed26ac in std::__1::__function::__func<sorbet::WorkerPoolImpl::multiplexJob(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void ()>)::$_2, std::__1::allocator<sorbet::WorkerPoolImpl::multiplexJob(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void ()>)::$_2>, bool ()>::operator()() WorkerPoolImpl.cc
    +    #6 0x55cac6ed12c5 in std::__1::__function::__func<sorbet::WorkerPoolImpl::WorkerPoolImpl(int, spdlog::logger&)::$_0, std::__1::allocator<sorbet::WorkerPoolImpl::WorkerPoolImpl(int, spdlog::logger&)::$_0>, void ()>::operator()() WorkerPoolImpl.cc
    +    #7 0x55cac629c0e1 in std::__1::__function::__value_func<void ()>::operator()[abi:v15007]() const driver.cc
    +    #8 0x55cac6265778 in std::__1::function<void ()>::operator()() const (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x43e7778) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #9 0x55cac6ee3e33 in Joinable::trampoline(void*) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x5065e33) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #10 0x7f435c953608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x8608) (BuildId: c6d0d79d906d62bb768421fc6dada0d5e729f177)
    +    #11 0x7f435c84c352 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11f352) (BuildId: 87b331c034a6458c64ce09c03939e947212e18ce)
    +
    +Address 0x7f435a57c140 is located in stack of thread T0 at offset 320 in frame
    +    #0 0x55cac6e3bb4c in appendFilesInDir(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, absl::flat_hash_set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, absl::container_internal::StringHash, absl::container_internal::StringHashEq::Eq, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, sorbet::WorkerPool&, bool, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x4fbdb4c) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +
    +  This frame has 20 object(s):
    +    [32, 40) '__p.addr.i.i.i.i'
    +    [64, 65) '__af.i.i.i'
    +    [80, 104) '__hold.i.i.i'
    +    [144, 160) 'ref.tmp.i.i.i'
    +    [176, 177) 'ref.tmp.i'
    +    [192, 208) 'basePath'
    +    [224, 225) 'recursive.addr'
    +    [240, 244) 'numWorkers'
    +    [256, 272) 'jobq'
    +    [288, 304) 'resultq'
    +    [320, 328) 'pendingJobs' <== Memory access at offset 320 is inside this variable
    +    [352, 384) 'ref.tmp24'
    +    [416, 464) 'agg.tmp41'
    +    [496, 584) 'agg.tmp42'
    +    [624, 656) 'threadResult'
    +    [688, 704) 'ref.tmp73'
    +    [720, 728) 'ref.tmp89'
    +    [752, 832) '__enforceTimer'
    +    [864, 880) 'agg.tmp199'
    +    [896, 904) 'ref.tmp225'
    +HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
    +      (longjmp and C++ exceptions *are* supported)
    +SUMMARY: AddressSanitizer: stack-use-after-return realmain.cc in unsigned long std::__1::__cxx_atomic_fetch_add[abi:v15007]<unsigned long>(std::__1::__cxx_atomic_base_impl<unsigned long>*, unsigned long, std::__1::memory_order)
    +Shadow bytes around the buggy address:
    +  0x0fe8eb4a77d0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a77e0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a77f0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7800: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7810: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +=>0x0fe8eb4a7820: f5 f5 f5 f5 f5 f5 f5 f5[f5]f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7830: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7840: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7850: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7860: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7870: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +Shadow byte legend (one shadow byte represents 8 application bytes):
    +  Addressable:           00
    +  Partially addressable: 01 02 03 04 05 06 07
    +  Heap left redzone:       fa
    +  Freed heap region:       fd
    +  Stack left redzone:      f1
    +  Stack mid redzone:       f2
    +  Stack right redzone:     f3
    +  Stack after return:      f5
    +  Stack use after scope:   f8
    +  Global redzone:          f9
    +  Global init order:       f6
    +  Poisoned by user:        f7
    +  Container overflow:      fc
    +  Array cookie:            ac
    +  Intra object redzone:    bb
    +  ASan internal:           fe
    +  Left alloca redzone:     ca
    +  Right alloca redzone:    cb
    +Thread T7 (options.findFil) created by T0 here:
    +    #0 0x55cac4eadd9c in pthread_create (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x302fd9c) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #1 0x55cac6ee4267 in runInAThread(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void ()>, std::__1::optional<int>) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x5066267) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #2 0x55cac6ecf33f in sorbet::WorkerPoolImpl::WorkerPoolImpl(int, spdlog::logger&) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x505133f) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #3 0x55cac6ece73c in sorbet::WorkerPool::create(int, spdlog::logger&) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x505073c) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #4 0x55cac6a300a6 in sorbet::realmain::options::readOptions(sorbet::realmain::options::Options&, std::__1::vector<std::__1::unique_ptr<sorbet::pipeline::semantic_extension::SemanticExtension, std::__1::default_delete<sorbet::pipeline::semantic_extension::SemanticExtension>>, std::__1::allocator<std::__1::unique_ptr<sorbet::pipeline::semantic_extension::SemanticExtension, std::__1::default_delete<sorbet::pipeline::semantic_extension::SemanticExtension>>>>&, int, char**, std::__1::vector<sorbet::pipeline::semantic_extension::SemanticExtensionProvider*, std::__1::allocator<sorbet::pipeline::semantic_extension::SemanticExtensionProvider*>> const&, std::__1::shared_ptr<spdlog::logger>) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x4bb20a6) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #5 0x55cac4f0379c in sorbet::realmain::realmain(int, char**) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x308579c) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #6 0x55cac4eff162 in main (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x3081162) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #7 0x7f435c751082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 87b331c034a6458c64ce09c03939e947212e18ce)
    +
    +==1781049==ABORTING
    ================================================================================
jez added a commit that referenced this issue May 16, 2024
* Pull in sorbet/bazel-toolchain#8

Required to make Clang 15 available.

* llvm toolchain: 12.0.0 → 15.0.7

* Silence this warning globally

* Fix "unused but set variable" warnings

* Stop linking against mimalloc on macOS release builds

* Fix path to sanitizer archives

Clang moved these at some point.

Note that we only ever ran the sanitize build on x86_64--it never ran
over arm64 builds.

That might be nice to add some day, but I'm not blocking on it.

* Add doc on how to build and publish LLVM

* tools/scripts/format_cxx.sh

* Silence some warning for abseil for now

* Backport a patch from upstream to fix -Warray-parameter warning

I couldn't get this silenced by adding `--copt=-Wno-array-parameter`
because it looks like abseil builds this with a bunch of specific
warning flags, and those take precedence over ours.

The issue is fixed upstream, and when we upgrade we'll get this change
for free, but as mentioned in the previous commit we can't upgrade
abseil until after we upgrade clang.

* Ignore unknown warnings on emscripten build

* Defer throwing an exception until all threads have exited

In clang 15, the sanitizer was catching a stack-use-after-return error
from this multithreaded codepath. The test which caught this was

    //test/cli:test_folder-input-not-found

(Because it is multithreaded, the bug only manifested about 30% of the
time, depending on the order that threads were scheduled by the OS.)

The bug was that we were attempting to (atomically) write to
`pendingJobs` from children threads after the function that spawned
those threads exited.

A sequence of steps that could happen:

- A worker thread would realize that the input was not a directory. It
  would return a result requesting that the parent thread throw an
  exception, and queue up a bunch of jobs that would have the effect of
  shutting down the other threads.

- The parent thread would get scheduled first. It would see that a child
  asked to throw, and it would throw, in effect returning from the
  function before all children were done.

- The children would wake up and attempt to decrement the `pendingJobs`
  variable in the worker threads' closure by reference. That stack slot
  is not there anymore because the enclosing function raised.

The fix is simply wait for all the threads to finish, and only raise the
requested exception after we're sure that all the children threads have
finished processing and shut down.

For posterity, this is what the test failure looked like

    +=================================================================
    +==1781049==ERROR: AddressSanitizer: stack-use-after-return on address 0x7f435a57c140 at pc 0x55cac4f42fd8 bp 0x7f43420ef940 sp 0x7f43420ef938
    +WRITE of size 8 at 0x7f435a57c140 thread T7 (options.findFil)
    +    #0 0x55cac4f42fd7 in unsigned long std::__1::__cxx_atomic_fetch_add[abi:v15007]<unsigned long>(std::__1::__cxx_atomic_base_impl<unsigned long>*, unsigned long, std::__1::memory_order) realmain.cc
    +    #1 0x55cac6e4d9b8 in std::__1::__atomic_base<unsigned long, true>::operator+=[abi:v15007](unsigned long) common.cc
    +    #2 0x55cac6e3f5a6 in std::__1::__function::__func<appendFilesInDir(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, absl::flat_hash_set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, absl::container_internal::StringHash, absl::container_internal::StringHashEq::Eq, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, sorbet::WorkerPool&, bool, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_0, std::__1::allocator<appendFilesInDir(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, absl::flat_hash_set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, absl::container_internal::StringHash, absl::container_internal::StringHashEq::Eq, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, sorbet::WorkerPool&, bool, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)::$_0>, void ()>::operator()() common.cc
    +    #3 0x55cac629c0e1 in std::__1::__function::__value_func<void ()>::operator()[abi:v15007]() const driver.cc
    +    #4 0x55cac6265778 in std::__1::function<void ()>::operator()() const (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x43e7778) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #5 0x55cac6ed26ac in std::__1::__function::__func<sorbet::WorkerPoolImpl::multiplexJob(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void ()>)::$_2, std::__1::allocator<sorbet::WorkerPoolImpl::multiplexJob(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void ()>)::$_2>, bool ()>::operator()() WorkerPoolImpl.cc
    +    #6 0x55cac6ed12c5 in std::__1::__function::__func<sorbet::WorkerPoolImpl::WorkerPoolImpl(int, spdlog::logger&)::$_0, std::__1::allocator<sorbet::WorkerPoolImpl::WorkerPoolImpl(int, spdlog::logger&)::$_0>, void ()>::operator()() WorkerPoolImpl.cc
    +    #7 0x55cac629c0e1 in std::__1::__function::__value_func<void ()>::operator()[abi:v15007]() const driver.cc
    +    #8 0x55cac6265778 in std::__1::function<void ()>::operator()() const (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x43e7778) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #9 0x55cac6ee3e33 in Joinable::trampoline(void*) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x5065e33) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #10 0x7f435c953608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x8608) (BuildId: c6d0d79d906d62bb768421fc6dada0d5e729f177)
    +    #11 0x7f435c84c352 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11f352) (BuildId: 87b331c034a6458c64ce09c03939e947212e18ce)
    +
    +Address 0x7f435a57c140 is located in stack of thread T0 at offset 320 in frame
    +    #0 0x55cac6e3bb4c in appendFilesInDir(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, absl::flat_hash_set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, absl::container_internal::StringHash, absl::container_internal::StringHashEq::Eq, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, sorbet::WorkerPool&, bool, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x4fbdb4c) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +
    +  This frame has 20 object(s):
    +    [32, 40) '__p.addr.i.i.i.i'
    +    [64, 65) '__af.i.i.i'
    +    [80, 104) '__hold.i.i.i'
    +    [144, 160) 'ref.tmp.i.i.i'
    +    [176, 177) 'ref.tmp.i'
    +    [192, 208) 'basePath'
    +    [224, 225) 'recursive.addr'
    +    [240, 244) 'numWorkers'
    +    [256, 272) 'jobq'
    +    [288, 304) 'resultq'
    +    [320, 328) 'pendingJobs' <== Memory access at offset 320 is inside this variable
    +    [352, 384) 'ref.tmp24'
    +    [416, 464) 'agg.tmp41'
    +    [496, 584) 'agg.tmp42'
    +    [624, 656) 'threadResult'
    +    [688, 704) 'ref.tmp73'
    +    [720, 728) 'ref.tmp89'
    +    [752, 832) '__enforceTimer'
    +    [864, 880) 'agg.tmp199'
    +    [896, 904) 'ref.tmp225'
    +HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
    +      (longjmp and C++ exceptions *are* supported)
    +SUMMARY: AddressSanitizer: stack-use-after-return realmain.cc in unsigned long std::__1::__cxx_atomic_fetch_add[abi:v15007]<unsigned long>(std::__1::__cxx_atomic_base_impl<unsigned long>*, unsigned long, std::__1::memory_order)
    +Shadow bytes around the buggy address:
    +  0x0fe8eb4a77d0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a77e0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a77f0: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7800: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7810: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +=>0x0fe8eb4a7820: f5 f5 f5 f5 f5 f5 f5 f5[f5]f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7830: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7840: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7850: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7860: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +  0x0fe8eb4a7870: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
    +Shadow byte legend (one shadow byte represents 8 application bytes):
    +  Addressable:           00
    +  Partially addressable: 01 02 03 04 05 06 07
    +  Heap left redzone:       fa
    +  Freed heap region:       fd
    +  Stack left redzone:      f1
    +  Stack mid redzone:       f2
    +  Stack right redzone:     f3
    +  Stack after return:      f5
    +  Stack use after scope:   f8
    +  Global redzone:          f9
    +  Global init order:       f6
    +  Poisoned by user:        f7
    +  Container overflow:      fc
    +  Array cookie:            ac
    +  Intra object redzone:    bb
    +  ASan internal:           fe
    +  Left alloca redzone:     ca
    +  Right alloca redzone:    cb
    +Thread T7 (options.findFil) created by T0 here:
    +    #0 0x55cac4eadd9c in pthread_create (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x302fd9c) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #1 0x55cac6ee4267 in runInAThread(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void ()>, std::__1::optional<int>) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x5066267) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #2 0x55cac6ecf33f in sorbet::WorkerPoolImpl::WorkerPoolImpl(int, spdlog::logger&) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x505133f) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #3 0x55cac6ece73c in sorbet::WorkerPool::create(int, spdlog::logger&) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x505073c) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #4 0x55cac6a300a6 in sorbet::realmain::options::readOptions(sorbet::realmain::options::Options&, std::__1::vector<std::__1::unique_ptr<sorbet::pipeline::semantic_extension::SemanticExtension, std::__1::default_delete<sorbet::pipeline::semantic_extension::SemanticExtension>>, std::__1::allocator<std::__1::unique_ptr<sorbet::pipeline::semantic_extension::SemanticExtension, std::__1::default_delete<sorbet::pipeline::semantic_extension::SemanticExtension>>>>&, int, char**, std::__1::vector<sorbet::pipeline::semantic_extension::SemanticExtensionProvider*, std::__1::allocator<sorbet::pipeline::semantic_extension::SemanticExtensionProvider*>> const&, std::__1::shared_ptr<spdlog::logger>) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x4bb20a6) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #5 0x55cac4f0379c in sorbet::realmain::realmain(int, char**) (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x308579c) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #6 0x55cac4eff162 in main (/pay/home/jez/.cache/bazel/_bazel_jez/2cc40ac946cd09178597ebd947795951/execroot/com_stripe_ruby_typer/bazel-out/k8-dbg/bin/main/sorbet+0x3081162) (BuildId: c972efcad340ab8e0e5ea671063eb36b)
    +    #7 0x7f435c751082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 87b331c034a6458c64ce09c03939e947212e18ce)
    +
    +==1781049==ABORTING
    ================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
runtime Related to the sorbet-runtime gem
Projects
None yet
Development

No branches or pull requests

5 participants