Bug 222480

Summary: [GTK] Fails to build in i386: static assertion failed: divisor must be a power of two
Product: WebKit Reporter: Alberto Garcia <berto>
Component: WebKitGTKAssignee: Kimmo Kinnunen <kkinnunen>
Status: RESOLVED FIXED    
Severity: Normal CC: berto, bugs-noreply, cgarcia, kkinnunen, peng.liu6
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch cgarcia: review+

Description Alberto Garcia 2021-02-26 09:44:03 PST
I can reproduce this with WebKitGTK 2.31.90:

In file included from DerivedSources/ForwardingHeaders/wtf/FastMalloc.h:26,
                 from ../Source/WebKit/config.h:42,
                 from DerivedSources/WebKit/WebPageProxyMessageReceiver.cpp:25:
DerivedSources/ForwardingHeaders/wtf/StdLibExtras.h: In instantiation of ‘constexpr size_t WTF::roundUpToMultipleOf(size_t) [with unsigned int divisor = 48; size_t = unsigned int]’:
../Source/WebKit/Platform/IPC/StreamConnectionBuffer.h:117:96:   required from here
DerivedSources/ForwardingHeaders/wtf/StdLibExtras.h:187:27: error: static assertion failed: divisor must be a power of two!
  187 |     static_assert(divisor && !(divisor & (divisor - 1)), "divisor must be a power of two!");
      |                   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

As you can see 'divisor' is 48, I suspect that the problem is in sizeof(Header) due to the differences in size_t between 32-bit and 64-bit platforms:

https://trac.webkit.org/browser/webkit/trunk/Source/WebKit/Platform/IPC/StreamConnectionBuffer.h?rev=273204#L117
Comment 1 Alberto Garcia 2021-02-26 09:45:05 PST
This was added in r273204.
Comment 2 Kimmo Kinnunen 2021-02-26 10:12:21 PST
Thanks! It's a typo:
- roundUpToMultipleOf<sizeof(std::max_align_t)>
+ roundUpToMultipleOf<alignof(std::max_align_t)>
Comment 3 Kimmo Kinnunen 2021-02-26 10:13:27 PST
I can fix it on coming Monday the latest, if nobody gets around fixing it before.
Comment 4 Alberto Garcia 2021-02-26 12:44:11 PST
Created attachment 421699 [details]
Patch

Here is the patch, thanks!
Comment 5 Kimmo Kinnunen 2021-03-01 00:59:51 PST
Comment on attachment 421699 [details]
Patch

Thanks, looks good.
Comment 6 Alberto Garcia 2021-03-01 01:44:08 PST
Committed r273643: <https://commits.webkit.org/r273643>