Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gollvm/gofrontend: missing hash functions for alias types #52846

Closed
tianxiaogu opened this issue May 11, 2022 · 4 comments
Closed

gollvm/gofrontend: missing hash functions for alias types #52846

tianxiaogu opened this issue May 11, 2022 · 4 comments
Assignees
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@tianxiaogu
Copy link

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)
@heschi heschi added the NeedsFix The path to resolution is known, but the work has not been done. label May 11, 2022
@heschi heschi added this to the Unreleased milestone May 11, 2022
@heschi
Copy link
Contributor

heschi commented May 11, 2022

cc @thanm

@thanm thanm self-assigned this May 12, 2022
@thanm
Copy link
Contributor

thanm commented May 12, 2022

Thanks for the report.

@gopherbot
Copy link

Change https://go.dev/cl/413694 mentions this issue: test: add test that causes gofrontend crash

gopherbot pushed a commit that referenced this issue Jun 22, 2022
For #52846

Change-Id: I763f81def97b53277396c123c524f7b8193ea35e
Reviewed-on: https://go-review.googlesource.com/c/go/+/413694
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
@gopherbot
Copy link

Change https://go.dev/cl/413660 mentions this issue: compiler: unalias types for hash/equality functions

realqhc pushed a commit to realqhc/gofrontend that referenced this issue Aug 4, 2022
Test case is https://go.dev/cl/413694.

Fixes golang/go#52846

Change-Id: I9dc883ba18b3ae1697acfc1b8a78560294cf5c30
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413660
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
jproberts pushed a commit to jproberts/go that referenced this issue Aug 10, 2022
For golang#52846

Change-Id: I763f81def97b53277396c123c524f7b8193ea35e
Reviewed-on: https://go-review.googlesource.com/c/go/+/413694
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants