New issue
Advanced search Search tips

Issue 698300 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

Clang ToT Mac failing with "the specified hash functor does not meet the requirements for an enabled hash"

Project Member Reported by h...@chromium.org, Mar 3 2017

Issue description

For example:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac/builds/13325/steps/compile/logs/stdio

FAILED: obj/v8/d8/d8.o 
export DEVELOPER_DIR=/b/c/b/ClangToTMac/src/build/mac_files/Xcode.app;  ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/v8/d8/d8.o.d -DV8_INSPECTOR_ENABLED -DV8_DEPRECATION_WARNINGS -DNO_TCMALLOC -DUSE_EXTERNAL_POPUP_MENU=1 -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DENABLE_MEDIA_ROUTER=1 -DFIELDTRIAL_TESTING_ENABLED -DCR_CLANG_REVISION=\"296874\" -DCR_XCODE_VERSION=0511 -DCOMPONENT_BUILD -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DV8_I18N_SUPPORT -DENABLE_HANDLE_ZAPPING -DV8_USE_EXTERNAL_STARTUP_DATA -DV8_TARGET_ARCH_X64 -DUSING_V8_SHARED -DUSING_V8_BASE_SHARED -DUSING_V8_PLATFORM_SHARED -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen -I../../v8 -I../../v8/include -Igen/v8/include -I../../v8/include -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -fno-strict-aliasing -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -fcolor-diagnostics -arch x86_64 -g1 -isysroot /b/c/b/ClangToTMac/src/build/mac_files/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -mmacosx-version-min=10.9 -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Werror -Wall -Wno-unused-variable -Wpartial-availability -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-deprecated-register -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-shift-negative-value -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-block-capture-autoreleasing -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wsign-compare -Winconsistent-missing-override -O3 -fvisibility-inlines-hidden -std=c++11 -stdlib=libc++ -fno-rtti -fno-exceptions -c ../../v8/src/d8.cc -o obj/v8/d8/d8.o
In file included from ../../v8/src/d8.cc:12:
In file included from /b/c/b/ClangToTMac/src/third_party/llvm-build/Release+Asserts/include/c++/v1/unordered_map:369:
/b/c/b/ClangToTMac/src/third_party/llvm-build/Release+Asserts/include/c++/v1/__hash_table:881:5: error: static_assert failed "the specified hash functor does not meet the requirements for an enabled hash"
    static_assert(__has_enabled_hash<_Key, _Hash>::value,
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/b/c/b/ClangToTMac/src/third_party/llvm-build/Release+Asserts/include/c++/v1/__hash_table:964:77: note: in instantiation of member function 'std::__1::__diagnose_hash_table_helper<v8::Global<v8::Module>, v8::(anonymous namespace)::ModuleEmbedderData::ModuleGlobalHash, std::__1::equal_to<v8::Global<v8::Module> >, std::__1::allocator<std::__1::__hash_value_type<v8::Global<v8::Module>, std::__1::basic_string<char> > > >::__trigger_diagnostics' requested here
    static_assert(__diagnose_hash_table_helper<_Tp, _Hash, _Equal, _Alloc>::__trigger_diagnostics(), "");
                                                                            ^
/b/c/b/ClangToTMac/src/third_party/llvm-build/Release+Asserts/include/c++/v1/unordered_map:769:13: note: in instantiation of template class 'std::__1::__hash_table<std::__1::__hash_value_type<v8::Global<v8::Module>, std::__1::basic_string<char> >, std::__1::__unordered_map_hasher<v8::Global<v8::Module>, std::__1::__hash_value_type<v8::Global<v8::Module>, std::__1::basic_string<char> >, v8::(anonymous namespace)::ModuleEmbedderData::ModuleGlobalHash, false>, std::__1::__unordered_map_equal<v8::Global<v8::Module>, std::__1::__hash_value_type<v8::Global<v8::Module>, std::__1::basic_string<char> >, std::__1::equal_to<v8::Global<v8::Module> >, true>, std::__1::allocator<std::__1::__hash_value_type<v8::Global<v8::Module>, std::__1::basic_string<char> > > >' requested here
    __table __table_;
            ^
../../v8/src/d8.cc:635:7: note: in instantiation of template class 'std::__1::unordered_map<v8::Global<v8::Module>, std::__1::basic_string<char>, v8::(anonymous namespace)::ModuleEmbedderData::ModuleGlobalHash, std::__1::equal_to<v8::Global<v8::Module> >, std::__1::allocator<std::__1::pair<const v8::Global<v8::Module>, std::__1::basic_string<char> > > >' requested here
      module_to_directory_map;
      ^
1 error generated.
 
That's kind of a crappy diagnostic, maybe we can ask upstream to make that diagnostic more actionable? (instead of "this is wrong", make it say "this is wrong because of a, b, c")

Comment 2 by h...@chromium.org, Mar 3 2017

It's hard to pinpoint where this started because  Issue 697603  had the build red for a while.

I think this is the first where it's showing in the output: https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.fyi%2FClangToTMac%2F13303%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout

But the previous build had other errors, and they occurred in earlier steps so they could be hiding this one.

There's a related recent commit though:

Author: ericwf
Date: Tue Feb 28 20:02:28 2017
New Revision: 296565

URL: http://llvm.org/viewvc/llvm-project?rev=296565&view=rev
Log:
Improve diagnostics when an invalid hash is used in an unordered container.

This patch adds a static assertion that the specified hash meets
the requirements of an enabled hash, and it ensures that the static
assertion is evaluated before __compressed_pair is instantiated.
That way the static assertion diagnostic is emitted first.

Added:
    libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
Modified:
    libcxx/trunk/include/__hash_table

Modified: libcxx/trunk/include/__hash_table
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=296565&r1=296564&r2=296565&view=diff
==============================================================================
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Tue Feb 28 20:02:28 2017
@@ -871,11 +871,20 @@ public:
 template <class _Key, class _Hash, class _Equal, class _Alloc>
 struct __diagnose_hash_table_helper {
   static constexpr bool __trigger_diagnostics()
-  _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,
-    "the specified hash functor does not provide a const call operator")
-  _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value,
-    "the specified comparator type does not provide a const call operator")
-  { return true; }
+    _LIBCPP_DIAGNOSE_WARNING(__has_enabled_hash<_Key, _Hash>::value
+                         && !__invokable<_Hash const&, _Key const&>::value,
+      "the specified hash functor does not provide a const call operator")
+    _LIBCPP_DIAGNOSE_WARNING(is_copy_constructible<_Equal>::value
+                          && !__invokable<_Equal const&, _Key const&, _Key const&>::value,
+      "the specified comparator type does not provide a const call operator")
+  {
+    static_assert(__has_enabled_hash<_Key, _Hash>::value,
+      "the specified hash functor does not meet the requirements for an "
+      "enabled hash");
+    static_assert(is_copy_constructible<_Equal>::value,
+      "the specified comparator is required to be copy constructible");
+    return true;
+  }
 };

 template <class _Key, class _Value, class _Hash, class _Equal, class _Alloc>
@@ -951,6 +960,10 @@ private:
     typedef allocator_traits<__pointer_allocator>          __pointer_alloc_traits;
     typedef typename __bucket_list_deleter::pointer       __node_pointer_pointer;

+#ifndef _LIBCPP_CXX03_LANG
+    static_assert(__diagnose_hash_table_helper<_Tp, _Hash, _Equal, _Alloc>::__trigger_diagnostics(), "");
+#endif
+
     // --- Member data begin ---
     __bucket_list                                         __bucket_list_;
     __compressed_pair<__first_node, __node_allocator>     __p1_;
@@ -1482,13 +1495,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 template <class _Tp, class _Hash, class _Equal, class _Alloc>
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
 {
+#if defined(_LIBCPP_CXX03_LANG)
     static_assert((is_copy_constructible<key_equal>::value),
                  "Predicate must be copy-constructible.");
     static_assert((is_copy_constructible<hasher>::value),
                  "Hasher must be copy-constructible.");
-#ifndef _LIBCPP_CXX03_LANG
-    static_assert(__diagnose_hash_table_helper<_Tp, _Hash, _Equal, _Alloc>::__trigger_diagnostics(), "");
 #endif
+
     __deallocate_node(__p1_.first().__next_);
 #if _LIBCPP_DEBUG_LEVEL >= 2
     __get_db()->__erase_c(this);
Maybe just ask ericwf on IRC if this bug here rings any bells?

Comment 4 by h...@chromium.org, Mar 3 2017

__has_enabled_hash<_Key, _Hash>::value

Seems to be defined here https://llvm.org/svn/llvm-project/libcxx/trunk/include/utility
like

template <class _Key, class _Hash = std::hash<_Key> >
using __has_enabled_hash = integral_constant<bool,
    is_default_constructible<_Hash>::value &&
    is_copy_constructible<_Hash>::value &&
    is_move_constructible<_Hash>::value &&
    __invokable_r<size_t, _Hash, _Key const&>::value
>;


In V8's case module_to_directory_map is a std::unordered_map<Global<Module>, std::string, ModuleGlobalHash>, so _Hash should be ModuleGlobalHash, which is this one: https://cs.chromium.org/chromium/src/v8/src/d8.cc?rcl=c9b4087f4a00632b7133c491addac7272d45cbef&l=616

  class ModuleGlobalHash {
   public:
    explicit ModuleGlobalHash(Isolate* isolate) : isolate_(isolate) {}
    size_t operator()(const Global<Module>& module) const {
      return module.Get(isolate_)->GetIdentityHash();
    }

   private:
    Isolate* isolate_;
  };

Which does not meet those criteria..

Comment 5 by h...@chromium.org, Mar 3 2017

Owner: h...@chromium.org
Status: Fixed (was: Available)
Eric says it should be fixed in r296919.

Tentatively closing this.

Sign in to add a comment