Can't build V8 with iterator checks in libcxx

32 views
Skip to first unread message

Chris Palmer

unread,
Oct 13, 2020, 4:42:36 PM10/13/20
to v8-dev
Hi all,

I'm doing an experiment: turning on increased checks in Chromium's copy of libcxx (LLVM's C++ library). I use this diff:

diff --git a/build/config/c++/BUILD.gn b/build/config/c++/BUILD.gn
index f1c18b9f35fd..3718fc40773d 100644
--- a/build/config/c++/BUILD.gn
+++ b/build/config/c++/BUILD.gn
@@ -68,11 +68,12 @@ config("runtime_library") {
     # libc++ has two levels of debug mode. Setting _LIBCPP_DEBUG to zero
     # enables most assertions. Setting it to one additionally enables iterator
     # debugging. See https://libcxx.llvm.org/docs/DesignDocs/DebugMode.html
-    if (enable_iterator_debugging) {
-      defines += [ "_LIBCPP_DEBUG=1" ]
-    } else if (is_debug || dcheck_always_on) {
-      defines += [ "_LIBCPP_DEBUG=0" ]
-    }
+    #if (enable_iterator_debugging) {
+    #  defines += [ "_LIBCPP_DEBUG=1" ]
+    #} else if (is_debug || dcheck_always_on) {
+    #  defines += [ "_LIBCPP_DEBUG=0" ]
+    #}
+    defines += [ "_LIBCPP_DEBUG=1" ]
   }


_LIBCPP_DEBUG=1 turns on debugging checks in many std:: classes, and also checks in iterators. (_LIBCPP_DEBUG=0 turns on debugging checks but not in iterators.)

When building, I get this explosion:

ninja: Entering directory `out/Release'
[1/1] Regenerating ninja files
[39041/39294] ACTION //v8:run_mksnapshot_default(//build/toolchain/linux:clang_x64)
FAILED: gen/v8/embedded.S snapshot_blob.bin
python ../../v8/tools/run.py ./mksnapshot --turbo_instruction_scheduling --target_os=linux --target_arch=x64 --embedded_src gen/v8/embedded.S --embedded_variant Default --random-seed 314159265 --startup_blob snapshot_blob.bin --no-native-code-counters
../../buildtools/third_party/libc++/trunk/include/__hash_table:337: _LIBCPP_ASSERT '__get_const_db()->__dereferenceable(this)' failed. Attempted to dereference a non-dereferenceable unordered container iterator
Return code is -6
ninja: build stopped: subcommand failed.


Unfortunately, I don't know how to get you a better error message. Any clues on that? Assuming the check itself is correct, it looks like there's a bug somewhere in V8.

seth.b...@microsoft.com

unread,
Oct 13, 2020, 5:25:24 PM10/13/20
to v8-dev
Hi Chris,

This build step is just running a program: run.py executes whatever is on the command line after it. To get a better error details, you can re-run ./mksnapshot in a debugger with all of the provided arguments. When doing so, I see a failure at the following call stack:

00 mksnapshot!abort
01 mksnapshot!std::__1::__libcpp_abort_debug_function
02 mksnapshot!std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<int,v8::internal::compiler::Node *>,void *> *>::operator->
03 mksnapshot!std::__1::unordered_map<int,v8::internal::compiler::Node *,v8::base::hash<int>,std::__1::equal_to<int>,v8::internal::ZoneAllocator<std::__1::pair<const int,v8::internal::compiler::Node *> > >::operator[]
04 mksnapshot!v8::internal::compiler::NodeCache<int,v8::base::hash<int>,std::__1::equal_to<int> >::Find
05 mksnapshot!v8::internal::compiler::CommonNodeCache::FindInt32Constant
06 mksnapshot!v8::internal::compiler::MachineGraph::Int32Constant
07 mksnapshot!v8::internal::compiler::CodeAssembler::Int32Constant
08 mksnapshot!v8::internal::FromConstexpr_IterationKind_constexpr_IterationKind_0
09 mksnapshot!v8::internal::DownCastForTorqueClass_JSFunction_0
0a mksnapshot!v8::internal::Cast_JSFunction_0
0b mksnapshot!v8::internal::CollectCallFeedback_0
0c mksnapshot!v8::internal::CollectCallFeedback_1
0d mksnapshot!v8::internal::CallWithSpread_WithFeedbackAssembler::GenerateCallWithSpread_WithFeedbackImpl
0e mksnapshot!v8::internal::Builtins::Generate_CallWithSpread_WithFeedback
0f mksnapshot!v8::internal::`anonymous namespace'::BuildWithCodeStubAssemblerCS
10 mksnapshot!v8::internal::SetupIsolateDelegate::SetupBuiltinsInternal
11 mksnapshot!v8::internal::Isolate::Init
12 mksnapshot!v8::internal::Isolate::InitWithoutSnapshot
13 mksnapshot!v8::SnapshotCreator::SnapshotCreator
14 mksnapshot!v8::internal::CreateSnapshotDataBlobInternal
15 mksnapshot!`anonymous namespace'::CreateSnapshotDataBlob
16 mksnapshot!main
17 mksnapshot!invoke_main
18 mksnapshot!__scrt_common_main_seh
19 KERNEL32!BaseThreadInitThunk
1a ntdll!RtlUserThreadStart

By the way, you can just set "enable_iterator_debugging = true" in out/Release/args.gn rather than editing BUILD.gn if you like 😊.

-Seth

Jakob Gruber

unread,
Oct 14, 2020, 12:54:32 AM10/14/20
to v8-...@googlegroups.com

--
--
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/ddc51578-12eb-4692-9124-35eb3b2eafddn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages