You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not store LazyNeverDestroyed objects as member variables
https://bugs.webkit.org/show_bug.cgi?id=298814
Reviewed by Darin Adler.
Stop using LazyNeverDestroyed for member variables in StaticCSSValuePool.
This triggers undefined behavior in ASSERT_ENABLED builds, since the
'm_isConstructed' member of LazyNeverDestroyed<T> is not initialized
in that case. GCC 14 correctly warned about this, breaking the build
on e.g. Ubuntu 25.04, where GCC 14 is default.
The straightforward solution was to directly use AlignedStorage<T>
as type for the pool member variables instead of LazyNeverDestroyed<T>,
preserving the current performance characteristics (no dynamic
allocations, etc.). The "canonical" solution of using e.g.
Vector<RefPtr<CSSPrimitiveValue>> would re-introduce the memory
problems which were previously migitiated by introducing
std::array<LazyNeverDestroyed<...>, capacity> -- thus it is not
applicable here.
Covered by existing tests.
* Source/WebCore/css/CSSPrimitiveValue.cpp:
(WebCore::valueFromPool):
* Source/WebCore/css/CSSValuePool.cpp:
(WebCore::StaticCSSValuePool::StaticCSSValuePool):
(WebCore::CSSValuePool::createColorValue):
* Source/WebCore/css/CSSValuePool.h:
(WebCore::CSSPrimitiveValue::implicitInitialValue):
(WebCore::CSSPrimitiveValue::create):
Canonical link: https://commits.webkit.org/299936@main
0 commit comments