<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>286004</bug_id>
          
          <creation_ts>2025-01-15 08:56:20 -0800</creation_ts>
          <short_desc>REGRESSION(288829@main) [CMake] Build failure with clang-18 crashing on Vector::map and complex LengthPercentage templates</short_desc>
          <delta_ts>2025-01-18 06:18:56 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CMake</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=285453</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Lauro Moura">lmoura</reporter>
          <assigned_to name="Lauro Moura">lmoura</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2087468</commentid>
    <comment_count>0</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2025-01-15 08:56:20 -0800</bug_when>
    <thetext>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&apos;s the following snippet (similar in both cases):

```cpp
[&amp;](const Style::PolygonFunction&amp; polygon) -&gt; Ref&lt;LayoutShape&gt; {
    auto boxSize = FloatSize { boxWidth, boxHeight };
    auto vertices = polygon-&gt;vertices.value.map([&amp;](const auto&amp; vertex) -&gt; 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&lt;FloatPoint&gt; vertices(polygon-&gt;vertices.value.size());
for (const auto&amp; vertex : polygon-&gt;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.      &lt;eof&gt; 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 &apos;WTF::Vector&lt;WebCore::SpaceSeparatedPoint&lt;WebCore::Style::LengthPercentage&lt;Range{-INF, INF, 0}&gt;&gt;&gt;::map&lt;(lambda at /home/lauro/wkdev-shared/dev/WebKit/Source/WebCore/style/va
lues/shapes/StylePolygonFunction.cpp:65:44)&gt;&apos;
3.      /home/lauro/wkdev-shared/dev/WebKit/WebKitBuild/GTK/Release/WTF/Headers/wtf/Vector.h:1802:86: instantiating function definition &apos;WTF::Vector&lt;WebCore::SpaceSeparatedPoint&lt;WebCore::Style::LengthPercentage&lt;Range{-INF, INF, 0}&gt;&gt;&gt;::map&lt;WTF::Vector&lt;WebCore::FloatPoint&gt;, (lambda at /home/lauro/wkdev-shared/d
ev/WebKit/Source/WebCore/style/values/shapes/StylePolygonFunction.cpp:65:44)&gt;&apos;
4.      /home/lauro/wkdev-shared/dev/WebKit/Source/WebCore/style/values/shapes/StylePolygonFunction.cpp:65:44: instantiating function definition &apos;WebCore::Style::PathComputation&lt;WebCore::Style::Polygon&gt;::operator()(const Polygon &amp;, const FloatRect &amp;)::(anonymous class)::operator()&lt;WebCore::SpaceSeparatedPoint
&lt;WebCore::Style::LengthPercentage&lt;Range{-INF, INF, 0}&gt;&gt;&gt;&apos;
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&amp;, 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&amp;, clang::QualType&amp;, unsigned int const*) + 698
5  libclang-cpp.so.18.1 0x0000745d342e10a6 clang::Sema::BuildDeclRefExpr(clang::ValueDecl*, clang::QualType, clang::ExprValueKind, clang::DeclarationNameInfo const&amp;, 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&amp;, clang::CXXScopeSpec const*, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) + 149
7  libclang-cpp.so.18.1 0x0000745d342e533c clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&amp;, clang::DeclarationNameInfo const&amp;, 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&amp;) + 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&lt;clang::Expr const*&gt;, llvm::SmallVectorImpl&lt;clang::Expr*&gt;&amp;, clang::MultiLevelTemplateArgumentList const&amp;, clang::SourceRange, clang::ConstraintSatisfaction&amp;) + 805
18 libclang-cpp.so.18.1 0x0000745d34126899 clang::Sema::CheckInstantiatedFunctionTemplateConstraints(clang::SourceLocation, clang::FunctionDecl*, llvm::ArrayRef&lt;clang::TemplateArgument&gt;, clang::ConstraintSatisfaction&amp;) + 857
19 libclang-cpp.so.18.1 0x0000745d346fd442 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl&lt;clang::DeducedTemplateArgument&gt;&amp;, unsigned int, clang::FunctionDecl*&amp;, clang::sema::TemplateDeductionInfo&amp;, llvm::SmallVectorImpl&lt;clang::Sema::OriginalCallArg&gt; const*, bo
ol, llvm::function_ref&lt;bool ()&gt;) + 3138
20 libclang-cpp.so.18.1 0x0000745d347535c7
21 libclang-cpp.so.18.1 0x0000745d33fecde0 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref&lt;void ()&gt;) + 64
22 libclang-cpp.so.18.1 0x0000745d346fed4b clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::FunctionDecl*&amp;, clang::sema::TemplateDeductionInfo&amp;, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref
&lt;bool (llvm::ArrayRef&lt;clang::QualType&gt;)&gt;) + 2379
23 libclang-cpp.so.18.1 0x0000745d345cc1eb clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::OverloadCandidateSet&amp;, 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&lt;clang::Expr*&gt;, clang::OverloadCandidateSet&amp;, bool, bool, bool, bool, clang::CallExpr::ADLCallKind, llvm::MutableArrayRef&lt;clang::ImplicitConversionSequence&gt;, 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&lt;clang::Expr*&gt;, clang::OverloadCandidateSet&amp;, bool) + 318
32 libclang-cpp.so.18.1 0x0000745d345dc86c clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, llvm::MutableArrayRef&lt;clang::Expr*&gt;, clang::SourceLocation, clang::OverloadCandidateSet*, clang::ActionResult&lt;clang::Expr*, true&gt;*) + 156
33 libclang-cpp.so.18.1 0x0000745d345dcb6c clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef&lt;clang::Expr*&gt;, 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&lt;clang::Expr*&gt;, 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&lt;clang::Expr*&gt;, 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&amp;) + 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&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) + 1166
50 libclang-cpp.so.18.1 0x0000745d3379747e clang::ParseAST(clang::Sema&amp;, 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&amp;) + 708
53 libclang-cpp.so.18.1 0x0000745d3568263d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 765
54 clang                0x000059de46afd42e cc1_main(llvm::ArrayRef&lt;char const*&gt;, 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&lt;void ()&gt;) + 151
58 libclang-cpp.so.18.1 0x0000745d35233237 clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const + 407
59 libclang-cpp.so.18.1 0x0000745d351fb518 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const + 888
60 libclang-cpp.so.18.1 0x0000745d351fb77f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const + 159
61 libclang-cpp.so.18.1 0x0000745d35217c20 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) + 352
62 clang                0x000059de46afa1ec clang_main(int, char**, llvm::ToolContext const&amp;) + 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2087719</commentid>
    <comment_count>1</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2025-01-16 03:38:16 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/39127</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2088275</commentid>
    <comment_count>2</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-01-18 06:18:55 -0800</bug_when>
    <thetext>Committed 289103@main (fa7b6d6d7447): &lt;https://commits.webkit.org/289103@main&gt;

Reviewed commits have been landed. Closing PR #39127 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>