Investigate segfault when trying to use kRange in sampling CE bm

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • ALL
    • Hide

      To repro, change the following line of code for `queryConfig1` to be `kRange`.

      Then run the `BM_RunCardinalityEstimationOnSample` Benchmark and there will be segfault with the stacktrace attached to the bottom of this ticket. I added log lines inside the `createQueryMatchExpressionOnMultipleFields()` function and noted that it failed during the first iteration of the inner loop here.

      {"t":{"$date":"2025-07-17T14:25:12.770+00:00"},"s":"I",  "c":"CONTROL",  "id":31380,   "ctx":"main","msg":"BACKTRACE","attr":{"bt":{"backtrace":[{"a":"C214BDE9B080","b":"C214A6D80000","o":"1711B080","s":"_ZN5mongo18stack_trace_detail12_GLOBAL__N_117getStackTraceImplERKNS1_7OptionsE","C":"mongo::stack_trace_detail::(anonymous namespace)::getStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const&)","s+":"5C"},{"a":"C214BDE9B310","b":"C214A6D80000","o":"1711B310","s":"_ZN5mongo15printStackTraceEv","C":"mongo::printStackTrace()","s+":"44"},{"a":"C214BDE69F70","b":"C214A6D80000","o":"170E9F70","s":"_ZN5mongo12_GLOBAL__N_126printStackTraceNoRecursionEv","C":"mongo::(anonymous namespace)::printStackTraceNoRecursion()","s+":"38"},{"a":"C214BDE69574","b":"C214A6D80000","o":"170E9574","s":"_ZN5mongo12_GLOBAL__N_115printErrorBlockEv","C":"mongo::(anonymous namespace)::printErrorBlock()","s+":"C"},{"a":"C214BDE698C4","b":"C214A6D80000","o":"170E98C4","s":"abruptQuitWithAddrSignal","s+":"118"},{"a":"F0A7941159D0","b":"F0A794115000","o":"9D0","s":"__kernel_rt_sigreturn","s+":"0"},{"a":"C214B9449F94","b":"C214A6D80000","o":"126C9F94","s":"_ZN5mongo5stats8SBEValueC2ERKS1_","C":"mongo::stats::SBEValue::SBEValue(mongo::stats::SBEValue const&)","s+":"30"},{"a":"C214B554E368","b":"C214A6D80000","o":"E7CE368","s":"_ZNSt4pairIN5mongo5stats8SBEValueES2_EC2ERKS3_","C":"std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>::pair(std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const&)","s+":"24"},{"a":"C214B7E58D80","b":"C214A6D80000","o":"110D8D80","s":"_ZSt12construct_atISt4pairIN5mongo5stats8SBEValueES3_EJRKS4_EEDTgsnwcvPvLi0E_T_pispclsr3stdE7declvalIT0_EEEEPS8_DpOS9_","C":"decltype (::new ((void*)(0)) std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>((std::declval<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const&>)())) std::construct_at<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>, std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const&>(std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>*, std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const&)","s+":"24"},{"a":"C214B7E58C14","b":"C214A6D80000","o":"110D8C14","s":"_ZNSt6vectorISt4pairIN5mongo5stats8SBEValueES3_ESaIS4_EE17_M_realloc_appendIJRKS4_EEEvDpOT_","C":"void std::vector<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>, std::allocator<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> > >::_M_realloc_append<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const&>(std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const&)","s+":"108"},{"a":"C214B7E5740C","b":"C214A6D80000","o":"110D740C","s":"_ZNSt6vectorISt4pairIN5mongo5stats8SBEValueES3_ESaIS4_EE9push_backERKS4_","C":"std::vector<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>, std::allocator<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> > >::push_back(std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const&)","s+":"74"},{"a":"C214B7E548B8","b":"C214A6D80000","o":"110D48B8","s":"_ZN5mongo2ce42createQueryMatchExpressionOnMultipleFieldsENS0_21WorkloadConfigurationESt6vectorIS2_ISt4pairINS_5stats8SBEValueES5_ESaIS6_EESaIS8_EE","C":"mongo::ce::createQueryMatchExpressionOnMultipleFields(mongo::ce::WorkloadConfiguration, std::vector<std::vector<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>, std::allocator<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> > >, std::allocator<std::vector<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>, std::allocator<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> > > > >)","s+":"128"},{"a":"C214B551F86C","b":"C214A6D80000","o":"E79F86C","s":"_ZN5mongo2ce35BM_RunCardinalityEstimationOnSampleERN9benchmark5StateE","C":"mongo::ce::BM_RunCardinalityEstimationOnSample(benchmark::State&)","s+":"5AC"},{"a":"C214BE1A2A4C","b":"C214A6D80000","o":"17422A4C","s":"_ZN9benchmark8internal17FunctionBenchmark3RunERNS_5StateE","C":"benchmark::internal::FunctionBenchmark::Run(benchmark::State&)","s+":"24"},{"a":"C214BE19EB40","b":"C214A6D80000","o":"1741EB40","s":"_ZNK9benchmark8internal17BenchmarkInstance3RunEmiPNS0_11ThreadTimerEPNS0_13ThreadManagerE","C":"benchmark::internal::BenchmarkInstance::Run(unsigned long, int, benchmark::internal::ThreadTimer*, benchmark::internal::ThreadManager*) const","s+":"80"},{"a":"C214BE1AA870","b":"C214A6D80000","o":"1742A870","s":"_ZN9benchmark8internal12_GLOBAL__N_111RunInThreadEPKNS0_17BenchmarkInstanceEmiPNS0_13ThreadManagerE","C":"benchmark::internal::(anonymous namespace)::RunInThread(benchmark::internal::BenchmarkInstance const*, unsigned long, int, benchmark::internal::ThreadManager*)","s+":"78"},{"a":"C214BE1AA184","b":"C214A6D80000","o":"1742A184","s":"_ZN9benchmark8internal12_GLOBAL__N_115BenchmarkRunner13DoNIterationsEv","C":"benchmark::internal::(anonymous namespace)::BenchmarkRunner::DoNIterations()","s+":"280"},{"a":"C214BE1A9BAC","b":"C214A6D80000","o":"17429BAC","s":"_ZN9benchmark8internal12_GLOBAL__N_115BenchmarkRunner15DoOneRepetitionEl","C":"benchmark::internal::(anonymous namespace)::BenchmarkRunner::DoOneRepetition(long)","s+":"58"},{"a":"C214BE1A9990","b":"C214A6D80000","o":"17429990","s":"_ZN9benchmark8internal12_GLOBAL__N_115BenchmarkRunnerC2ERKNS0_17BenchmarkInstanceEPSt6vectorINS_17BenchmarkReporter3RunESaIS8_EE","C":"benchmark::internal::(anonymous namespace)::BenchmarkRunner::BenchmarkRunner(benchmark::internal::BenchmarkInstance const&, std::vector<benchmark::BenchmarkReporter::Run, std::allocator<benchmark::BenchmarkReporter::Run> >*)","s+":"260"},{"a":"C214BE1A96C0","b":"C214A6D80000","o":"174296C0","s":"_ZN9benchmark8internal12RunBenchmarkERKNS0_17BenchmarkInstanceEPSt6vectorINS_17BenchmarkReporter3RunESaIS6_EE","C":"benchmark::internal::RunBenchmark(benchmark::internal::BenchmarkInstance const&, std::vector<benchmark::BenchmarkReporter::Run, std::allocator<benchmark::BenchmarkReporter::Run> >*)","s+":"40"},{"a":"C214BE19B810","b":"C214A6D80000","o":"1741B810","s":"_ZN9benchmark8internal12_GLOBAL__N_113RunBenchmarksERKSt6vectorINS0_17BenchmarkInstanceESaIS3_EEPNS_17BenchmarkReporterES9_","C":"benchmark::internal::(anonymous namespace)::RunBenchmarks(std::vector<benchmark::internal::BenchmarkInstance, std::allocator<benchmark::internal::BenchmarkInstance> > const&, benchmark::BenchmarkReporter*, benchmark::BenchmarkReporter*)","s+":"334"},{"a":"C214BE19B27C","b":"C214A6D80000","o":"1741B27C","s":"_ZN9benchmark22RunSpecifiedBenchmarksEPNS_17BenchmarkReporterES1_","C":"benchmark::RunSpecifiedBenchmarks(benchmark::BenchmarkReporter*, benchmark::BenchmarkReporter*)","s+":"444"},{"a":"C214BE19AE30","b":"C214A6D80000","o":"1741AE30","s":"_ZN9benchmark22RunSpecifiedBenchmarksEv","C":"benchmark::RunSpecifiedBenchmarks()","s+":"14"},{"a":"C214BDC1E5A4","b":"C214A6D80000","o":"16E9E5A4","s":"main","s+":"4CC"},{"a":"F0A7939A73FC","b":"F0A793980000","o":"273FC","s":"__libc_start_call_main","s+":"6C"},{"a":"F0A7939A74CC","b":"F0A793980000","o":"274CC","s":"__libc_start_main_alias_2","s+":"98"}],"processInfo":{"mongodbVersion":"unknown","gitVersion":"none","compiledModules":["unknown"],"uname":{"sysname":"Linux","release":"6.5.0-1016-aws","version":"#16~22.04.1-Ubuntu SMP Wed Mar 13 20:57:51 UTC 2024","machine":"aarch64"},"somap":[{"b":"C214A6D80000","path":"/home/ubuntu/.cache/bazel/_bazel_ubuntu/8c0f9643d9076e854e292e295bf57b7d/execroot/_main/bazel-out/aarch64-fastbuild/bin/src/mongo/db/query/ce/sampling/sampling_bm_with_debug","buildId":"5F9C289ABA2131155DA6FADC05B694E862B4012D","elfType":3},{"b":"F0A794115000","path":"linux-vdso.so.1","elfType":3,"buildId":"1B987A679F990C11FECEBCF728ABEFBC94559461"},{"b":"F0A793980000","path":"/lib/aarch64-linux-gnu/libc.so.6","elfType":3,"buildId":"3BA44E06B9DC66AEEB2651DB4DD015FFAF6E0849"}]}}},"tags":[]}
      
      
      Show
      To repro, change the following line of code for `queryConfig1` to be `kRange`. Then run the `BM_RunCardinalityEstimationOnSample` Benchmark and there will be segfault with the stacktrace attached to the bottom of this ticket. I added log lines inside the `createQueryMatchExpressionOnMultipleFields()` function and noted that it failed during the first iteration of the inner loop here . { "t" :{ "$date" : "2025-07-17T14:25:12.770+00:00" }, "s" : "I" , "c" : "CONTROL" , "id" :31380, "ctx" : "main" , "msg" : "BACKTRACE" , "attr" :{ "bt" :{ "backtrace" :[{ "a" : "C214BDE9B080" , "b" : "C214A6D80000" , "o" : "1711B080" , "s" : "_ZN5mongo18stack_trace_detail12_GLOBAL__N_117getStackTraceImplERKNS1_7OptionsE" , "C" : "mongo::stack_trace_detail::(anonymous namespace)::getStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const &)" , "s+" : "5C" },{ "a" : "C214BDE9B310" , "b" : "C214A6D80000" , "o" : "1711B310" , "s" : "_ZN5mongo15printStackTraceEv" , "C" : "mongo::printStackTrace()" , "s+" : "44" },{ "a" : "C214BDE69F70" , "b" : "C214A6D80000" , "o" : "170E9F70" , "s" : "_ZN5mongo12_GLOBAL__N_126printStackTraceNoRecursionEv" , "C" : "mongo::(anonymous namespace)::printStackTraceNoRecursion()" , "s+" : "38" },{ "a" : "C214BDE69574" , "b" : "C214A6D80000" , "o" : "170E9574" , "s" : "_ZN5mongo12_GLOBAL__N_115printErrorBlockEv" , "C" : "mongo::(anonymous namespace)::printErrorBlock()" , "s+" : "C" },{ "a" : "C214BDE698C4" , "b" : "C214A6D80000" , "o" : "170E98C4" , "s" : "abruptQuitWithAddrSignal" , "s+" : "118" },{ "a" : "F0A7941159D0" , "b" : "F0A794115000" , "o" : "9D0" , "s" : "__kernel_rt_sigreturn" , "s+" : "0" },{ "a" : "C214B9449F94" , "b" : "C214A6D80000" , "o" : "126C9F94" , "s" : "_ZN5mongo5stats8SBEValueC2ERKS1_" , "C" : "mongo::stats::SBEValue::SBEValue(mongo::stats::SBEValue const &)" , "s+" : "30" },{ "a" : "C214B554E368" , "b" : "C214A6D80000" , "o" : "E7CE368" , "s" : "_ZNSt4pairIN5mongo5stats8SBEValueES2_EC2ERKS3_" , "C" : "std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>::pair(std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const &)" , "s+" : "24" },{ "a" : "C214B7E58D80" , "b" : "C214A6D80000" , "o" : "110D8D80" , "s" : "_ZSt12construct_atISt4pairIN5mongo5stats8SBEValueES3_EJRKS4_EEDTgsnwcvPvLi0E_T_pispclsr3stdE7declvalIT0_EEEEPS8_DpOS9_" , "C" : "decltype (:: new ((void*)(0)) std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>((std::declval<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const &>)())) std::construct_at<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>, std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const &>(std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>*, std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const &)" , "s+" : "24" },{ "a" : "C214B7E58C14" , "b" : "C214A6D80000" , "o" : "110D8C14" , "s" : "_ZNSt6vectorISt4pairIN5mongo5stats8SBEValueES3_ESaIS4_EE17_M_realloc_appendIJRKS4_EEEvDpOT_" , "C" : "void std::vector<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>, std::allocator<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> > >::_M_realloc_append<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const &>(std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const &)" , "s+" : "108" },{ "a" : "C214B7E5740C" , "b" : "C214A6D80000" , "o" : "110D740C" , "s" : "_ZNSt6vectorISt4pairIN5mongo5stats8SBEValueES3_ESaIS4_EE9push_backERKS4_" , "C" : "std::vector<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>, std::allocator<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> > >::push_back(std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> const &)" , "s+" : "74" },{ "a" : "C214B7E548B8" , "b" : "C214A6D80000" , "o" : "110D48B8" , "s" : "_ZN5mongo2ce42createQueryMatchExpressionOnMultipleFieldsENS0_21WorkloadConfigurationESt6vectorIS2_ISt4pairINS_5stats8SBEValueES5_ESaIS6_EESaIS8_EE" , "C" : "mongo::ce::createQueryMatchExpressionOnMultipleFields(mongo::ce::WorkloadConfiguration, std::vector<std::vector<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>, std::allocator<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> > >, std::allocator<std::vector<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue>, std::allocator<std::pair<mongo::stats::SBEValue, mongo::stats::SBEValue> > > > >)" , "s+" : "128" },{ "a" : "C214B551F86C" , "b" : "C214A6D80000" , "o" : "E79F86C" , "s" : "_ZN5mongo2ce35BM_RunCardinalityEstimationOnSampleERN9benchmark5StateE" , "C" : "mongo::ce::BM_RunCardinalityEstimationOnSample(benchmark::State&)" , "s+" : "5AC" },{ "a" : "C214BE1A2A4C" , "b" : "C214A6D80000" , "o" : "17422A4C" , "s" : "_ZN9benchmark8internal17FunctionBenchmark3RunERNS_5StateE" , "C" : "benchmark::internal::FunctionBenchmark::Run(benchmark::State&)" , "s+" : "24" },{ "a" : "C214BE19EB40" , "b" : "C214A6D80000" , "o" : "1741EB40" , "s" : "_ZNK9benchmark8internal17BenchmarkInstance3RunEmiPNS0_11ThreadTimerEPNS0_13ThreadManagerE" , "C" : "benchmark::internal::BenchmarkInstance::Run(unsigned long , int , benchmark::internal::ThreadTimer*, benchmark::internal::ThreadManager*) const " , "s+" : "80" },{ "a" : "C214BE1AA870" , "b" : "C214A6D80000" , "o" : "1742A870" , "s" : "_ZN9benchmark8internal12_GLOBAL__N_111RunInThreadEPKNS0_17BenchmarkInstanceEmiPNS0_13ThreadManagerE" , "C" : "benchmark::internal::(anonymous namespace)::RunInThread(benchmark::internal::BenchmarkInstance const *, unsigned long , int , benchmark::internal::ThreadManager*)" , "s+" : "78" },{ "a" : "C214BE1AA184" , "b" : "C214A6D80000" , "o" : "1742A184" , "s" : "_ZN9benchmark8internal12_GLOBAL__N_115BenchmarkRunner13DoNIterationsEv" , "C" : "benchmark::internal::(anonymous namespace)::BenchmarkRunner::DoNIterations()" , "s+" : "280" },{ "a" : "C214BE1A9BAC" , "b" : "C214A6D80000" , "o" : "17429BAC" , "s" : "_ZN9benchmark8internal12_GLOBAL__N_115BenchmarkRunner15DoOneRepetitionEl" , "C" : "benchmark::internal::(anonymous namespace)::BenchmarkRunner::DoOneRepetition( long )" , "s+" : "58" },{ "a" : "C214BE1A9990" , "b" : "C214A6D80000" , "o" : "17429990" , "s" : "_ZN9benchmark8internal12_GLOBAL__N_115BenchmarkRunnerC2ERKNS0_17BenchmarkInstanceEPSt6vectorINS_17BenchmarkReporter3RunESaIS8_EE" , "C" : "benchmark::internal::(anonymous namespace)::BenchmarkRunner::BenchmarkRunner(benchmark::internal::BenchmarkInstance const &, std::vector<benchmark::BenchmarkReporter::Run, std::allocator<benchmark::BenchmarkReporter::Run> >*)" , "s+" : "260" },{ "a" : "C214BE1A96C0" , "b" : "C214A6D80000" , "o" : "174296C0" , "s" : "_ZN9benchmark8internal12RunBenchmarkERKNS0_17BenchmarkInstanceEPSt6vectorINS_17BenchmarkReporter3RunESaIS6_EE" , "C" : "benchmark::internal::RunBenchmark(benchmark::internal::BenchmarkInstance const &, std::vector<benchmark::BenchmarkReporter::Run, std::allocator<benchmark::BenchmarkReporter::Run> >*)" , "s+" : "40" },{ "a" : "C214BE19B810" , "b" : "C214A6D80000" , "o" : "1741B810" , "s" : "_ZN9benchmark8internal12_GLOBAL__N_113RunBenchmarksERKSt6vectorINS0_17BenchmarkInstanceESaIS3_EEPNS_17BenchmarkReporterES9_" , "C" : "benchmark::internal::(anonymous namespace)::RunBenchmarks(std::vector<benchmark::internal::BenchmarkInstance, std::allocator<benchmark::internal::BenchmarkInstance> > const &, benchmark::BenchmarkReporter*, benchmark::BenchmarkReporter*)" , "s+" : "334" },{ "a" : "C214BE19B27C" , "b" : "C214A6D80000" , "o" : "1741B27C" , "s" : "_ZN9benchmark22RunSpecifiedBenchmarksEPNS_17BenchmarkReporterES1_" , "C" : "benchmark::RunSpecifiedBenchmarks(benchmark::BenchmarkReporter*, benchmark::BenchmarkReporter*)" , "s+" : "444" },{ "a" : "C214BE19AE30" , "b" : "C214A6D80000" , "o" : "1741AE30" , "s" : "_ZN9benchmark22RunSpecifiedBenchmarksEv" , "C" : "benchmark::RunSpecifiedBenchmarks()" , "s+" : "14" },{ "a" : "C214BDC1E5A4" , "b" : "C214A6D80000" , "o" : "16E9E5A4" , "s" : "main" , "s+" : "4CC" },{ "a" : "F0A7939A73FC" , "b" : "F0A793980000" , "o" : "273FC" , "s" : "__libc_start_call_main" , "s+" : "6C" },{ "a" : "F0A7939A74CC" , "b" : "F0A793980000" , "o" : "274CC" , "s" : "__libc_start_main_alias_2" , "s+" : "98" }], "processInfo" :{ "mongodbVersion" : "unknown" , "gitVersion" : "none" , "compiledModules" :[ "unknown" ], "uname" :{ "sysname" : "Linux" , "release" : "6.5.0-1016-aws" , "version" : "#16~22.04.1-Ubuntu SMP Wed Mar 13 20:57:51 UTC 2024" , "machine" : "aarch64" }, "somap" :[{ "b" : "C214A6D80000" , "path" : "/home/ubuntu/.cache/bazel/_bazel_ubuntu/8c0f9643d9076e854e292e295bf57b7d/execroot/_main/bazel-out/aarch64-fastbuild/bin/src/mongo/db/query/ce/sampling/sampling_bm_with_debug" , "buildId" : "5F9C289ABA2131155DA6FADC05B694E862B4012D" , "elfType" :3},{ "b" : "F0A794115000" , "path" : "linux-vdso.so.1" , "elfType" :3, "buildId" : "1B987A679F990C11FECEBCF728ABEFBC94559461" },{ "b" : "F0A793980000" , "path" : "/lib/aarch64-linux-gnu/libc.so.6" , "elfType" :3, "buildId" : "3BA44E06B9DC66AEEB2651DB4DD015FFAF6E0849" }]}}}, "tags" :[]}
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When running sampling ce benchmarks with the `kRange` type specified for a query, we run into a segfault.

            Assignee:
            Matt Olma
            Reporter:
            Naafiyan Ahmed
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: