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: can't use unsafe.Pointer as map key #51238

Closed
erifan opened this issue Feb 17, 2022 · 4 comments
Closed

gollvm: can't use unsafe.Pointer as map key #51238

erifan opened this issue Feb 17, 2022 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@erifan
Copy link

erifan commented Feb 17, 2022

What version of Go are you using (go version)?

$ go version
Gollvm tip version

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
linux/arm64

What did you do?

$ llvm-goc -c foo.go
$ cat foo.go

package foo

import (
        "unsafe"
)

// if the key of the map is not unsafe.Pointer, then the program compiles.
var newCache map[unsafe.Pointer]int

func mapCopy(k unsafe.Pointer, v int) {
        newCache = make(map[unsafe.Pointer]int, 1)
        newCache[k] = v
        return
}

What did you expect to see?

No error

What did you see instead?

Call parameter type does not match function signature!
%.ld.1 = load i8, i8* %tmpv.4.ld.0, align 1, !dbg !57
i8* %call.1 = call i8* @runtime.mapassign__fast64ptr(i8* nest undef, %_type.0* getelementptr inbounds (%MapType.0, %MapType.0* @type..map_6unsafe_0Pointer_7int, i32 0, i32 0), { i64, i8, i8, i16, i32, i8*, i8*, i64, i8* }* %go_0foo.newCache.ld.0, i8 %.ld.1), !dbg !57
Call parameter type does not match function signature!
%.ld.1 = load i8, i8* %tmpv.4.ld.0, align 1, !dbg !57
i8* %call.1 = call i8* @runtime.mapassign__fast64ptr(i8* nest undef, %_type.0* getelementptr inbounds (%MapType.0, %MapType.0* @type..map_6unsafe_0Pointer_7int, i32 0, i32 0), { i64, i8, i8, i16, i32, i8*, i8*, i64, i8* }* %go_0foo.newCache.ld.0, i8 %.ld.1), !dbg !57
in function go_0foo.mapCopy
LLVM ERROR: Broken function found, compilation aborted!
#0 0x0000aaaad7616c9c PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x0000aaaad7614dc4 SignalHandler(int) Signals.cpp:0:0
#2 0x0000ffffbb06e66c (linux-vdso.so.1+0x66c)
#3 0x0000ffffbab654f8 gsignal /build/glibc-D9JkfM/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0, Program arguments: llvm-goc -c foo.go
1, Running pass 'Module Verifier' on function '@go_0foo.mapCopy'
Aborted (core dumped)

@beoran
Copy link

beoran commented Feb 17, 2022

I think you should probably use uintptr in stead.

@randall77
Copy link
Contributor

@thanm

@thanm
Copy link
Contributor

thanm commented Feb 17, 2022

Thanks for the report, I'll take a look.

@dmitshur dmitshur added this to the gollvm milestone Feb 17, 2022
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 17, 2022
@thanm
Copy link
Contributor

thanm commented Mar 16, 2022

Looks like this was fixed by https://go-review.googlesource.com/c/gollvm/+/393295 -- thanks.

@thanm thanm closed this as completed Mar 16, 2022
@golang golang locked and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants