Closed
Description
Gogo::write_specific_type_functions
traverses all types to write hash_function
for the key type of each map type.
The trouble is that Type::needs_specific_type_functions
returns false if the key type is an aliased type. Here we need to delegate the check to the real type (or indeed base type) to see whether we need a hash function for the base type.
package main
type RealKey struct {
Type int64
Key string
}
type AliasKey = RealKey
func makeMap() map[AliasKey]interface{} {
m := make(map[AliasKey]interface{})
k := AliasKey{1, ""}
m[k] = k
return m
}
func main() {
if len(makeMap()) != 1 {
panic("Oops")
}
}
# command-line-arguments
llvm-goc: llvm-project/llvm/tools/gollvm/gofrontend/go/types.cc:1977: void Type::write_hash_function(Gogo*, int64_t, const Backend_name*, Function_type*): assertion 'saw_errors()' failed.
Named_object_func: .main.makeMap
#0 0x000055b6708c69cf PrintStackTraceSignalHandler(void*) (bin/llvm-goc+0x1f629cf)
#1 0x000055b6708c4b8c SignalHandler(int) (bin/llvm-goc+0x1f60b8c)
#2 0x00007f52b259a0e0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110e0)
#3 0x00007f52b112ffff raise /build/glibc-77giwP/glibc-2.24/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#4 0x00007f52b113142a abort /build/glibc-77giwP/glibc-2.24/stdlib/abort.c:91:0
#5 0x000055b66f06a0d6 (bin/llvm-goc+0x7060d6)
#6 0x000055b66f059377 Type::write_hash_function(Gogo*, long, Backend_name const*, Function_type*) (.localalias.182) (bin/llvm-goc+0x6f5377)
#7 0x000055b66f0595f3 Type::build_hash_function(Gogo*, long, Function_type*) (.localalias.183) (bin/llvm-goc+0x6f55f3)
#8 0x000055b66f058535 Type::hash_function(Gogo*, Function_type*) (.localalias.184) (bin/llvm-goc+0x6f4535)
#9 0x000055b66f060c6d Map_type::do_type_descriptor(Gogo*, Named_type*) (.localalias.286) (bin/llvm-goc+0x6fcc6d)
#10 0x000055b66f053f5e Type::make_type_descriptor_var(Gogo*) (.localalias.193) (bin/llvm-goc+0x6eff5e)
#11 0x000055b66f054620 Type::type_descriptor_pointer(Gogo*, Location) (bin/llvm-goc+0x6f0620)
#12 0x000055b66f0a3113 Type_descriptor_expression::do_get_backend(Translate_context*) (bin/llvm-goc+0x73f113)
#13 0x000055b66f0d7397 Call_expression::do_get_backend(Translate_context*) (.localalias.377) (bin/llvm-goc+0x773397)
#14 0x000055b66f02776b Temporary_statement::do_get_backend(Translate_context*) (.localalias.129) (bin/llvm-goc+0x6c376b)
#15 0x000055b66efe2a2b Block::get_backend(Translate_context*) (.localalias.82) (bin/llvm-goc+0x67ea2b)
#16 0x000055b66f02421d Block_statement::do_get_backend(Translate_context*) (.localalias.166) (bin/llvm-goc+0x6c021d)
#17 0x000055b66efe2a2b Block::get_backend(Translate_context*) (.localalias.82) (bin/llvm-goc+0x67ea2b)
#18 0x000055b66efe3784 Function::build(Gogo*, Named_object*) (.localalias.95) (bin/llvm-goc+0x67f784)
#19 0x000055b66efe5991 Named_object::get_backend(Gogo*, std::vector<Bexpression*, std::allocator<Bexpression*> >&, std::vector<Btype*, std::allocator<Btype*> >&, std::vector<Bfunction*, std::allocator<Bfunction*> >&) (.localalias.30) (bin/llvm-goc+0x681991)
#20 0x000055b66eff0c2d Gogo::write_globals() (bin/llvm-goc+0x68cc2d)
#21 0x000055b66efb5388 gollvm::driver::CompileGoImpl::invokeFrontEnd() (.localalias.4) (bin/llvm-goc+0x651388)
#22 0x000055b66efbd448 gollvm::driver::CompileGo::performAction(gollvm::driver::Compilation&, gollvm::driver::Action const&, llvm::SmallVector<gollvm::driver::Artifact*, 3u> const&, gollvm::driver::Artifact const&) (.localalias.13) (bin/llvm-goc+0x659448)
#23 0x000055b66efae875 gollvm::driver::Driver::processAction(gollvm::driver::Action*, gollvm::driver::Compilation&, bool) (.localalias.0) (bin/llvm-goc+0x64a875)
#24 0x000055b66efae97f gollvm::driver::Driver::processActions(gollvm::driver::Compilation&) (bin/llvm-goc+0x64a97f)
#25 0x000055b66eedced1 main (bin/llvm-goc+0x578ed1)
#26 0x00007f52b111d2e1 __libc_start_main /build/glibc-77giwP/glibc-2.24/csu/../csu/libc-start.c:325:0
#27 0x000055b66efa5f1a _start (bin/llvm-goc+0x641f1a)