Skip to content

weak: weak.Pointer[T] can be misused with type conversions #71583

Closed
@mateusz834

Description

@mateusz834

This is the second time something like this happens in the std, see #56603.

func main() {
        val := (weak.Pointer[[1024 * 1024]int])(weak.Make(new(int))).Value()
        val[len(val)-1] = 999
        fmt.Println(val[len(val)-1])
}
$ go run .
unexpected fault address 0xc000810108
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x2 addr=0xc000810108 pc=0x49203d]

goroutine 1 gp=0xc000002380 m=0 mp=0x560480 [running]:
runtime.throw({0x4b4e20?, 0x7f54c773b108?})
        /home/mateusz/code/go/src/runtime/panic.go:1096 +0x48 fp=0xc000084ea8 sp=0xc000084e78 pc=0x463328
runtime.sigpanic()
        /home/mateusz/code/go/src/runtime/signal_unix.go:939 +0x26c fp=0xc000084f08 sp=0xc000084ea8 pc=0x4646cc
main.main()
        /tmp/testing/main.go:10 +0x3d fp=0xc000084f50 sp=0xc000084f08 pc=0x49203d
runtime.main()
        /home/mateusz/code/go/src/runtime/proc.go:283 +0x28b fp=0xc000084fe0 sp=0xc000084f50 pc=0x43434b
runtime.goexit({})
        /home/mateusz/code/go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000084fe8 sp=0xc

(........)

Previously reported at: #67552 (comment)

CC @mknyszek

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.NeedsFixThe path to resolution is known, but the work has not been done.release-blocker

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions