Build error: static_assert failed due to requirement 'std::is_standard_layout<v8::internal::ThreadLocalTop>::value'

101 views
Skip to first unread message

Immanuel Haffner

unread,
Dec 19, 2022, 7:43:29 AM12/19/22
to v8-dev
I am currently facing issues building V8 at version 11.0.226 for embedding in my application. Compilation of several source files fails with the following error:

../../../../../../third-party/v8/v8/src/execution/isolate-data.h:279:3: error: static_assert failed due to requirement 'std::is_standard_layout<v8::internal::ThreadLocalTop>::value'
  static_assert(std::is_standard_layout<ThreadLocalTop>::value);
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../../third-party/v8/v8/src/execution/isolate-data.h:281:3: error: static_assert failed due to requirement 'std::is_standard_layout<v8::internal::IsolateData>::value'
  static_assert(std::is_standard_layout<IsolateData>::value);
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 2 errors generated.

I compile V8 with flags

is_clang=true clang_base_path=\"/usr\" use_lld=false use_gold=true v8_enable_pointer_compression=true treat_warnings_as_errors=false v8_use_external_startup_data=false use_sysroot=false use_custom_libcxx=false clang_use_chrome_plugins=false target_cpu=\"x64\""

I have tried both my system Clang and Google's toolchain. The compilation error is the same. My system clang is on 14.0.6.

Git blame tells me @Clemens Backes is the author of the respective lines of code.
I hope you or someone else can help me out.

Ben Noordhuis

unread,
Dec 19, 2022, 8:02:06 AM12/19/22
to v8-...@googlegroups.com
IsolateData embeds ThreadLocalTop embeds Stack embeds std::unique_ptr
and std::vector. Those last two are likely not standard layout types
on your system.
Message has been deleted
Message has been deleted
Message has been deleted

Clemens Backes

unread,
Dec 19, 2022, 11:36:12 AM12/19/22
to v8-dev, niko...@chromium.org, ish...@chromium.org
You probably found my refactoring (https://crrev.com/c/3647353) via git blame. Looks like the addition of ::heap::base::Stack to ThreadLocalTop (https://crrev.com/c/3960991, +nik...@chromium.org) broke the is_standard_layout assertion that was added in 2018 (https://crrev.com/c/1278793+is...@chromium.org).

The standard layout requirement is there to ensure that the offsetof expressions are actually well-defined. Having a std::unique_ptr and a std::vector in a class that is required to have standard layout indeed looks fishy.

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAHQurc_vTA009ypjv8umvpCXj7JZEbOMKmR9rWy8mBvTx_ONhw%40mail.gmail.com.


--

Clemens Backes

Software Engineer

clem...@google.com

Google Germany GmbH

Erika-Mann-Straße 33

80636 München


Geschäftsführer: Paul Manicle, Liana Sebastian   

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg


Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde.


This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.


Nikos Papaspyrou

unread,
Dec 19, 2022, 12:21:06 PM12/19/22
to Clemens Backes, v8-dev, ish...@chromium.org, Michael Lippautz, Thibaud Michaud
For completeness:
  • Originally https://crrev.com/c/3960991 introduced Stack in ThreadLocalTop; at that time, Stack had just two pointer fields and was a standard-layout class. I don't think there was anything fishy then.
  • Later, https://crrev.com/c/4017512 modified the Stack object, adding a std::unique_ptr. This is probably fishy, as in g++ smart pointers are considered to have standard-layout, whereas in clang++ they are not. (cc: mlippautz@ because we had explicitly discussed this)
  • Later, https://crrev.com/c/4081126 modified the Stack object again, adding a std::vector of standard layout structures. This could also be fishy, but it seems to be ok both in g++ and clang++. (cc:thibaud@ for that CL).
I suppose we need a C++ language lawyer. :-)
If the verdict is negative, we could convert the std::unique_ptr to a raw pointer and the vector to a linked list data structure.

Nikolaos Papaspyrou

Software Engineer

niko...@google.com


Google Germany GmbH

Erika-Mann-Straße 33

80636 München


Geschäftsführer: Paul Manicle, Liana Sebastian

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg


Diese E-Mail ist vertraulich. Falls Sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde. 

Message has been deleted
Message has been deleted

Clemens Backes

unread,
Jan 3, 2023, 10:02:46 AM1/3/23
to Nikos Papaspyrou, Clemens Backes, v8-dev, ish...@chromium.org, Michael Lippautz, Thibaud Michaud
FYI: There was another report of this problem, in our bug tracker: https://crbug.com/v8/13630
Reply all
Reply to author
Forward
0 new messages