RESOLVED FIXED286004
REGRESSION(288829@main) [CMake] Build failure with clang-18 crashing on Vector::map and complex LengthPercentage templates
https://bugs.webkit.org/show_bug.cgi?id=286004
Summary REGRESSION(288829@main) [CMake] Build failure with clang-18 crashing on Vecto...
Lauro Moura
Reported 2025-01-15 08:56:20 PST
Starting with 288829@main, building WebKit with clang-18 fails with the compiler frontend crashing while compiling either LayoutShape.cpp or StylePolygonFunction.cpp. In the former, it's the following snippet (similar in both cases): ```cpp [&](const Style::PolygonFunction& polygon) -> Ref<LayoutShape> { auto boxSize = FloatSize { boxWidth, boxHeight }; auto vertices = polygon->vertices.value.map([&](const auto& vertex) -> FloatPoint { return physicalPointToLogical(Style::evaluate(vertex, boxSize) + borderBoxOffset, logicalBoxSize.height(), writingMode); }); ... ``` One workaround for clang-18 is replacing the `Vector::map` call with a for loop, like: ```cpp Vector<FloatPoint> vertices(polygon->vertices.value.size()); for (const auto& vertex : polygon->vertices.value) vertices.append(physicalPointToLogical(Style::evaluate(vertex, boxSize) + borderBoxOffset, logicalBoxSize.height(), writingMode)); ``` Not sure about the performance impact of this, though. This issue also does not seem to affect the current clang version, 19, released September 2024. Given clang-18 is quite new (March 2024), it would be good to either work around this issue or add a clang version check, to bail out early and make the compiler requirement explicit. clang stack trace from a failed build with clang 18.1.3, Ubuntu 24.04.1 LTS: Stack dump: 0. Program arguments: /usr/bin/clang -x c++ -Xclang -main-file-name -Xclang /home/lauro/wkdev-shared/dev/WebKit/WebKitBuild/GTK/Release/WebCore/DerivedSources/unified-sources/UnifiedSource-26ec8d00-11.cpp -Xclang -fdebug-compilation-dir -Xclang /home/lauro/wkdev-shared/dev/WebKit/WebKitBuild/GTK/Release -fdiagnostics-color=always -Wextra -Wall -Werror=undefined-internal -Werror=undefined-inline -pipe -Wno-noexcept-type -Wno-psabi -Wno-misleading-indentation -Wno-parentheses-equality -Qunused-arguments -Wundef -Wpointer-arith -Wmissing-format-attribute -Wformat-security -Wcast-align -Wno-tautological-compare -fasynchronous-unwind-tables -fdebug-types-section -fno-strict-aliasing -fno-exceptions -fno-rtti -fcoroutines -ffunction-sections -fdata-sections -O2 -g -std=c++23 -fPIC -fvisibility=hidden -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions -mfpmath=sse -msse -msse2 -pthread -fcolor-diagnostics -fcolor-di agnostics -c -target x86_64-pc-linux-gnu - -o icecc-121552_3317dd71.o -no-canonical-prefixes 1. <eof> parser at end of file 2. /home/lauro/wkdev-shared/dev/WebKit/WebKitBuild/GTK/Release/WTF/Headers/wtf/Vector.h:1816:125: instantiating function definition 'WTF::Vector<WebCore::SpaceSeparatedPoint<WebCore::Style::LengthPercentage<Range{-INF, INF, 0}>>>::map<(lambda at /home/lauro/wkdev-shared/dev/WebKit/Source/WebCore/style/va lues/shapes/StylePolygonFunction.cpp:65:44)>' 3. /home/lauro/wkdev-shared/dev/WebKit/WebKitBuild/GTK/Release/WTF/Headers/wtf/Vector.h:1802:86: instantiating function definition 'WTF::Vector<WebCore::SpaceSeparatedPoint<WebCore::Style::LengthPercentage<Range{-INF, INF, 0}>>>::map<WTF::Vector<WebCore::FloatPoint>, (lambda at /home/lauro/wkdev-shared/d ev/WebKit/Source/WebCore/style/values/shapes/StylePolygonFunction.cpp:65:44)>' 4. /home/lauro/wkdev-shared/dev/WebKit/Source/WebCore/style/values/shapes/StylePolygonFunction.cpp:65:44: instantiating function definition 'WebCore::Style::PathComputation<WebCore::Style::Polygon>::operator()(const Polygon &, const FloatRect &)::(anonymous class)::operator()<WebCore::SpaceSeparatedPoint <WebCore::Style::LengthPercentage<Range{-INF, INF, 0}>>>' Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 libLLVM.so.18.1 0x0000745d2c1a63bf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 63 1 libLLVM.so.18.1 0x0000745d2c1a44f9 llvm::sys::RunSignalHandlers() + 89 2 libLLVM.so.18.1 0x0000745d2c0f0227 3 libc.so.6 0x0000745d2ac45320 4 libclang-cpp.so.18.1 0x0000745d34318f6a clang::Sema::tryCaptureVariable(clang::ValueDecl*, clang::SourceLocation, clang::Sema::TryCaptureKind, clang::SourceLocation, bool, clang::QualType&, clang::QualType&, unsigned int const*) + 698 5 libclang-cpp.so.18.1 0x0000745d342e10a6 clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::NestedNameSpecifierLoc, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) + 134 6 libclang-cpp.so.18.1 0x0000745d342e1005 clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&, clang::CXXScopeSpec const*, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) + 149 7 libclang-cpp.so.18.1 0x0000745d342e533c clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&, clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::NamedDecl*, clang::TemplateArgumentListInfo const*, bool) + 1372 8 libclang-cpp.so.18.1 0x0000745d3476aa34 9 libclang-cpp.so.18.1 0x0000745d34761294 10 libclang-cpp.so.18.1 0x0000745d3476bf65 11 libclang-cpp.so.18.1 0x0000745d34772670 12 libclang-cpp.so.18.1 0x0000745d34765c77 13 libclang-cpp.so.18.1 0x0000745d34760b51 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) + 81 14 libclang-cpp.so.18.1 0x0000745d3412a828 15 libclang-cpp.so.18.1 0x0000745d341295b1 16 libclang-cpp.so.18.1 0x0000745d34124109 17 libclang-cpp.so.18.1 0x0000745d34123d85 clang::Sema::CheckConstraintSatisfaction(clang::NamedDecl const*, llvm::ArrayRef<clang::Expr const*>, llvm::SmallVectorImpl<clang::Expr*>&, clang::MultiLevelTemplateArgumentList const&, clang::SourceRange, clang::ConstraintSatisfaction&) + 805 18 libclang-cpp.so.18.1 0x0000745d34126899 clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef<clang::TemplateArgument>, clang::ConstraintSatisfaction&) + 857 19 libclang-cpp.so.18.1 0x0000745d346fd442 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bo ol, llvm::function_ref<bool ()>) + 3138 20 libclang-cpp.so.18.1 0x0000745d347535c7 21 libclang-cpp.so.18.1 0x0000745d33fecde0 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) + 64 22 libclang-cpp.so.18.1 0x0000745d346fed4b clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref <bool (llvm::ArrayRef<clang::QualType>)>) + 2379 23 libclang-cpp.so.18.1 0x0000745d345cc1eb clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamO rder, bool) + 683 24 libclang-cpp.so.18.1 0x0000745d345c16a3 25 libclang-cpp.so.18.1 0x0000745d345e8eb3 26 libclang-cpp.so.18.1 0x0000745d345bc45a 27 libclang-cpp.so.18.1 0x0000745d345eb259 28 libclang-cpp.so.18.1 0x0000745d345c953f 29 libclang-cpp.so.18.1 0x0000745d345c8556 clang::Sema::AddOverloadCandidate(clang::FunctionDecl*, clang::DeclAccessPair, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, bool, clang::CallExpr::ADLCallKind, llvm::MutableArrayRef<clang::ImplicitConversionSequence>, clang::OverloadC andidateParamOrder, bool) + 3270 30 libclang-cpp.so.18.1 0x0000745d345dc70a 31 libclang-cpp.so.18.1 0x0000745d345dc4de clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) + 318 32 libclang-cpp.so.18.1 0x0000745d345dc86c clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult<clang::Expr*, true>*) + 156 33 libclang-cpp.so.18.1 0x0000745d345dcb6c clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) + 348 34 libclang-cpp.so.18.1 0x0000745d342db62a clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) + 1146 35 libclang-cpp.so.18.1 0x0000745d342f60a1 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) + 81 36 libclang-cpp.so.18.1 0x0000745d3476b65d 37 libclang-cpp.so.18.1 0x0000745d3476b858 38 libclang-cpp.so.18.1 0x0000745d34781218 39 libclang-cpp.so.18.1 0x0000745d34770669 40 libclang-cpp.so.18.1 0x0000745d3475fa03 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) + 83 41 libclang-cpp.so.18.1 0x0000745d347a1f26 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) + 2662 42 libclang-cpp.so.18.1 0x0000745d347a4744 clang::Sema::PerformPendingInstantiations(bool) + 628 43 libclang-cpp.so.18.1 0x0000745d347a2029 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) + 2921 44 libclang-cpp.so.18.1 0x0000745d347a4744 clang::Sema::PerformPendingInstantiations(bool) + 628 45 libclang-cpp.so.18.1 0x0000745d347a2041 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) + 2945 46 libclang-cpp.so.18.1 0x0000745d347a4744 clang::Sema::PerformPendingInstantiations(bool) + 628 47 libclang-cpp.so.18.1 0x0000745d33fee90b clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) + 427 48 libclang-cpp.so.18.1 0x0000745d33feef7b clang::Sema::ActOnEndOfTranslationUnit() + 363 49 libclang-cpp.so.18.1 0x0000745d3385fe2e clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) + 1166 50 libclang-cpp.so.18.1 0x0000745d3379747e clang::ParseAST(clang::Sema&, bool, bool) + 766 51 libclang-cpp.so.18.1 0x0000745d3560662c clang::FrontendAction::Execute() + 52 libclang-cpp.so.18.1 0x0000745d355830b4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 708 53 libclang-cpp.so.18.1 0x0000745d3568263d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 765 54 clang 0x000059de46afd42e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 3694 55 clang 0x000059de46afa894 56 libclang-cpp.so.18.1 0x0000745d35233972 57 libLLVM.so.18.1 0x0000745d2c0eff77 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 151 58 libclang-cpp.so.18.1 0x0000745d35233237 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const + 407 59 libclang-cpp.so.18.1 0x0000745d351fb518 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 888 60 libclang-cpp.so.18.1 0x0000745d351fb77f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const + 159 61 libclang-cpp.so.18.1 0x0000745d35217c20 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) + 352 62 clang 0x000059de46afa1ec clang_main(int, char**, llvm::ToolContext const&) + 11180 63 clang 0x000059de46b07383 main + 131 64 libc.so.6 0x0000745d2ac2a1ca 65 libc.so.6 0x0000745d2ac2a28b __libc_start_main + 139 66 clang 0x000059de46af7255 _start + 37 clang: error: clang frontend command failed with exit code 139 (use -v to see invocation) Ubuntu clang version 18.1.3 (1ubuntu1) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin clang: note: diagnostic msg: Error generating preprocessed source(s) - ignoring input from stdin. clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
Attachments
Lauro Moura
Comment 1 2025-01-16 03:38:16 PST
EWS
Comment 2 2025-01-18 06:18:55 PST
Committed 289103@main (fa7b6d6d7447): <https://commits.webkit.org/289103@main> Reviewed commits have been landed. Closing PR #39127 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.