Skip to content

go/types, types2: panic with invalid cyclic program involving unsafe.Sizeof #75918

Closed

Description

@griesemer

This program panics when type checking (playground):

type A [unsafe.Sizeof(S{})]byte

type S struct {
	a A
}

The program is invalid but the type checker/compiler should report an error.

Activity

  1. added this to the Backlog milestone on Oct 15, 2025
  2. added theissue type on Oct 15, 2025
  3. added
    BugReportIssues describing a possible bug in the Go implementation.
    on Oct 15, 2025
  4. coxley commented on Oct 23, 2025

    @coxley

    This looks like it could be the same thing, so I don't want to create a duplicate issue. I ran into a similar panic when testing an open source linter. Here's the repro with trace logs enabled:

    cd $(mktemp -d)
    git clone https://github.com/charithe/durationcheck
    cd durationcheck
    
    # I manually set `check.conf._Trace = true` inside
    # /opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/check.go since I
    # couldn't see a convenient way to do it from outside.
    go test
    Trace Output
    
    == initFiles ==
    
    == collectObjects ==
    
    == packageObjects ==
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:22:6  :  -- checking type Slice (white, objPath = )
    
    == initFiles ==
    
    == collectObjects ==
    
    == packageObjects ==
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:10:6  :  -- checking func Itoa (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:10:15 :  .  -- type int
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:10:15 :  .  => int // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:10:20 :  .  -- type string
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:10:20 :  .  => string // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:10:6  :  => func Itoa(val int) string (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:18:6  :  -- checking func Uitoa (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:18:16 :  .  -- type uint
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:18:16 :  .  => uint // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:18:22 :  .  -- type string
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:18:22 :  .  => string // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:18:6  :  => func Uitoa(val uint) string (black)
    
    
    == initFiles ==
    
    == collectObjects ==
    
    == initFiles ==
    
    == collectObjects ==
    
    == packageObjects ==
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:11:6  :  -- checking type Info (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:11:11 :  .  -- type struct{Name string; Package string; Changed int; Old string; Opaque bool; Immutable bool}
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:12:12 :  .  .  -- type string
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:12:12 :  .  .  => string // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:22:12 :  .  -- type struct{Data unsafe.Pointer; Len int; Cap int}
    
    == initFiles ==
    
    == collectObjects ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:23:7  :  .  .  -- type unsafe.Pointer
    
    == packageObjects ==
    
    == packageObjects ==
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:13:7  :  -- checking const Enabled (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:13:17 :  .  -- expr false
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:11:6  :  -- checking type StackRecord (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:23:7  :  .  .  => unsafe.Pointer // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:11:18 :  .  -- type struct{Stack []uintptr}
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:12:8  :  .  .  -- type []uintptr
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:13:17 :  .  => false (untyped bool constant)
    
    == initFiles ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:13:7  :  => const Enabled untyped bool (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:24:7  :  .  .  -- type int
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:24:7  :  .  .  => int // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:25:7  :  .  .  -- type int
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:15:6  :  -- checking func Read (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:25:7  :  .  .  => int // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:15:16 :  .  -- type unsafe.Pointer
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:15:16 :  .  => unsafe.Pointer // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:15:36 :  .  -- type uintptr
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:13:12 :  .  .  -- type string
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:15:36 :  .  => uintptr // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:13:12 :  .  .  => string // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:14:12 :  .  .  -- type int
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:14:12 :  .  .  => int // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:15:12 :  .  .  -- type string
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:15:6  :  => func Read(addr unsafe.Pointer, len uintptr) (black)
    
    == initFiles ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:15:12 :  .  .  => string // *Basic
    
    == collectObjects ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:16:12 :  .  .  -- type bool
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:16:12 :  .  .  => bool // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:17:12 :  .  .  -- type bool
    == collectObjects ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:17:12 :  .  .  => bool // *Basic
    
    == initFiles ==
    
    == collectObjects ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:11:11 :  .  => struct{Name string; Package string; Changed int; Old string; Opaque bool; Immutable bool} // *Struct
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:11:6  :  => type Info struct{Name string; Package string; Changed int; Old string; Opaque bool; Immutable bool} (black)
    
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:28:5  :  -- checking var All (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:17:6  :  -- checking func Write (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:17:17 :  .  -- type unsafe.Pointer
    
    == packageObjects ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:17:17 :  .  => unsafe.Pointer // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:35:7  :  -- checking const hex (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:17:37 :  .  -- type uintptr
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:12:10 :  .  .  .  -- type uintptr
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:17:37 :  .  => uintptr // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:28:11 :  .  -- expr []Info{…}
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/msan/nomsan.go:13:7  :  -- checking const Enabled (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/msan/nomsan.go:13:17 :  .  -- expr false
    
    == packageObjects ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/msan/nomsan.go:13:17 :  .  => false (untyped bool constant)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/msan/nomsan.go:13:7  :  => const Enabled untyped bool (black)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:28:11 :  .  .  -- type []Info
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:35:13 :  .  -- expr "0123456789abcdef"
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:28:13 :  .  .  .  -- type Info
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:35:13 :  .  => "0123456789abcdef" (untyped string constant)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:35:7  :  => const hex untyped string (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:38:6  :  -- checking func Uitox (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:38:16 :  .  -- type uint
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:38:16 :  .  => uint // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:22:12 :  .  => struct{Data unsafe.Pointer; Len int; Cap int} // *Struct
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:12:10 :  .  .  .  => uintptr // *Basic
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:12:8  :  .  .  => []uintptr // *Slice
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:17:6  :  => func Write(addr unsafe.Pointer, len uintptr) (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:11:18 :  .  => struct{Stack []uintptr} // *Struct
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:38:22 :  .  -- type string
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:11:6  :  => type StackRecord struct{Stack []uintptr} (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:15:6  :  -- checking type MemProfileRecord (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:38:22 :  .  => string // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:15:23 :  .  -- type struct{AllocBytes, FreeBytes int64; AllocObjects, FreeObjects int64; Stack []uintptr}
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:16:28 :  .  .  -- type int64
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:16:28 :  .  .  => int64 // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:38:6  :  => func Uitox(val uint) string (black)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/goarch/goarch.go:17:6  :  -- checking type ArchFamilyType (white, objPath = )
    == packageObjects ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/goarch/goarch.go:17:21 :  .  -- type int
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/goarch/goarch.go:17:21 :  .  => int // *Basic
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/goarch/goarch.go:17:6  :  => type ArchFamilyType int (black)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:9:6   :  -- checking func LEUint16 (white, objPath = )
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:9:17  :  .  -- type []byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:9:19  :  .  .  -- type byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:9:19  :  .  .  => byte // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:9:17  :  .  => []byte // *Slice
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:9:25  :  .  -- type uint16
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:9:25  :  .  => uint16 // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:9:6   :  => func LEUint16(b []byte) uint16 (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:14:6  :  -- checking func LEPutUint16 (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:14:20 :  .  -- type []byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:14:22 :  .  .  -- type byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:14:22 :  .  .  => byte // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:14:20 :  .  => []byte // *Slice
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:14:30 :  .  -- type uint16
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:14:30 :  .  => uint16 // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:14:6  :  => func LEPutUint16(b []byte, v uint16) (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:6  :  -- checking func LEAppendUint16 (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:23 :  .  -- type []byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:25 :  .  .  -- type byte
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:17:28 :  .  .  -- type int64
    
    == processDelayed ==
    -   :  -- delayed 0x104aac7e0
    
    -   :  -- delayed 0x104aac7e0
    
    -   :  -- delayed 0x104a72fa0
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:28:13 :  .  .  .  => Info (under = struct{Name string; Package string; Changed int; Old string; Opaque bool; Immutable bool}) // *Named
    == initFiles ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:10:27 :  -- Itoa: func(val int) string
    
    == initFiles ==
    
    == collectObjects ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:17:28 :  .  .  => int64 // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:18:28 :  .  .  -- type []uintptr
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:18:30 :  .  .  .  -- type uintptr
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:18:30 :  .  .  .  => uintptr // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:18:28 :  .  .  => []uintptr // *Slice
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/itoa/itoa.go:11:5  :  -- expr val < 0
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:15:23 :  .  => struct{AllocBytes int64; FreeBytes int64; AllocObjects int64; FreeObjects int64; Stack []uintptr} // *Struct
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:25 :  .  .  => byte // *Basic
    
    == packageObjects ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:23 :  .  => []byte // *Slice
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:33 :  .  -- type uint16
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:22:6  :  => type Slice struct{Data unsafe.Pointer; Len int; Cap int} (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:34:6  :  -- checking type String (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:34:13 :  .  -- type struct{Data unsafe.Pointer; Len int}
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:35:7  :  .  .  -- type unsafe.Pointer
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:35:7  :  .  .  => unsafe.Pointer // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:36:7  :  .  .  -- type int
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:36:7  :  .  .  => int // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:34:13 :  .  => struct{Data unsafe.Pointer; Len int} // *Struct
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:34:6  :  => type String struct{Data unsafe.Pointer; Len int} (black)
    
    == processDelayed ==
    -   :  -- delayed 0x104a71b90
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:28:11 :  .  .  => []Info // *Slice
    == processDelayed ==
    -   :  -- delayed 0x104aac7e0
    
    -   :  -- delayed 0x104aac7e0
    
    -   :  -- delayed 0x104a72fa0
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/goarch/goarch.go:20:2  :  -- checking const AMD64 (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/asan/noasan.go:15:45 :  -- Read: func(addr unsafe.Pointer, len uintptr)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/goarch/goarch.go:20:8  :  .  -- type ArchFamilyType
    
    
    == collectObjects ==
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:29:2  :  .  .  -- expr (ast: <nil>){…}
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/godebugs/table.go:29:9  :  .  .  .  -- expr "allowmultiplevcs"
    
    == packageObjects ==
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:15:6  :  => type MemProfileRecord struct{AllocBytes int64; FreeBytes int64; AllocObjects int64; FreeObjects int64; Stack []uintptr} (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:24:6  :  -- checking type BlockProfileRecord (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:24:25 :  .  -- type struct{Count int64; Cycles int64; Stack []uintptr}
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:25:9  :  .  .  -- type int64
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:25:9  :  .  .  => int64 // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:26:9  :  .  .  -- type int64
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:26:9  :  .  .  => int64 // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:27:9  :  .  .  -- type []uintptr
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:27:11 :  .  .  .  -- type uintptr
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:27:11 :  .  .  .  => uintptr // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:27:9  :  .  .  => []uintptr // *Slice
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:24:25 :  .  => struct{Count int64; Cycles int64; Stack []uintptr} // *Struct
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:24:6  :  => type BlockProfileRecord struct{Count int64; Cycles int64; Stack []uintptr} (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:21:28 :  -- checking func InUseBytes (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:21:9  :  .  -- type *MemProfileRecord
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:21:10 :  .  .  -- type MemProfileRecord
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:21:10 :  .  .  => MemProfileRecord (under = struct{AllocBytes int64; FreeBytes int64; AllocObjects int64; FreeObjects int64; Stack []uintptr}) // *Named
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:21:9  :  .  => *MemProfileRecord // *Pointer
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:21:41 :  .  -- type int64
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:21:41 :  .  => int64 // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:21:28 :  => func (*MemProfileRecord).InUseBytes() int64 (black)
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:22:28 :  -- checking func InUseObjects (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/profilerecord/profilerecord.go:22:9  :  .  -- type *MemProfileRecord
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:33 :  .  => uint16 // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:19:6  :  -- checking type CovMetaBlob (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:41 :  .  -- type []byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:43 :  .  .  -- type byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:19:18 :  .  -- type struct{P *byte; Len uint32; Hash [16]byte; PkgPath string; PkgID int; CounterMode uint8; CounterGranularity uint8}
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:43 :  .  .  => byte // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu.go:17:6  :  -- checking type CacheLinePad (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:41 :  .  => []byte // *Slice
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/goarch/goarch.go:20:8  :  .  => ArchFamilyType (under = int) // *Named
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/goarch/goarch.go:20:25 :  .  -- expr iota
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:20:6  :  => func LEAppendUint16(b []byte, v uint16) []byte (black)
    
    == initFiles ==
    
    == collectObjects ==
    
    == initFiles ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:27:6  :  -- checking func LEUint32 (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:27:17 :  .  -- type []byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/byteorder/byteorder.go:27:19 :  .  .  -- type byte
    -   :  -- delayed 0x104aac7e0
    
    
    == collectObjects ==
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:20:21 :  .  .  -- type *byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:20:22 :  .  .  .  -- type byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu.go:17:19 :  .  -- type struct{_ [CacheLinePadSize]byte}
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu.go:17:29 :  .  .  -- type [CacheLinePadSize]byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:20:22 :  .  .  .  => byte // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu.go:17:30 :  .  .  .  -- expr CacheLinePadSize
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:20:21 :  .  .  => *byte // *Pointer
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:21:21 :  .  .  -- type uint32
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:21:21 :  .  .  => uint32 // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu_arm64.go:10:7  :  .  .  .  .  -- checking const CacheLinePadSize (white, objPath = CacheLinePad)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:22:21 :  .  .  -- type [16]byte
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:22:22 :  .  .  .  -- expr 16
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu_arm64.go:10:26 :  .  .  .  .  .  -- expr 128
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/coverage/rtcov/rtcov.go:22:22 :  .  .  .  => 16 (untyped int constant)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu_arm64.go:10:26 :  .  .  .  .  .  => 128 (untyped int constant)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/msan/nomsan.go:15:6  :  -- checking func Read (white, objPath = )
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu_arm64.go:10:7  :  .  .  .  .  => const CacheLinePadSize untyped int (black)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/msan/nomsan.go:15:16 :  .  -- type unsafe.Pointer
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu.go:17:30 :  .  .  .  => CacheLinePadSize (untyped int constant 128)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/msan/nomsan.go:15:16 :  .  => unsafe.Pointer // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/msan/nomsan.go:15:35 :  .  -- type uintptr
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/msan/nomsan.go:15:35 :  .  => uintptr // *Basic
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu.go:17:29 :  .  .  => <nil> // <nil>
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu.go:17:19 :  .  => <nil> // <nil>
    
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:22:6  :  .  validType(Slice) nest , path 
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/cpu/cpu.go:17:6  :  => type CacheLinePad struct{} (black)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/goarch/goarch.go:20:25 :  .  => iota (untyped int constant 0)
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:22:6  :  .  .  validType(struct{Data unsafe.Pointer; Len int; Cap int}) nest Slice, path Slice
    /opt/homebrew/Cellar/go/1.25.3/libexec/src/internal/unsafeheader/unsafeheader.go:22:6  :  .  .  .  validType(unsafe.Pointer) nest Slice, path Slice
    panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
    [signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104a9ec28]
    
    goroutine 98 [running]:
    go/types.(*Checker).handleBailout(0x1400050a5a0, 0x14000433bc8)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/check.go:469 +0x9c
    panic({0x104bd3ec0?, 0x104e15700?})
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/runtime/panic.go:783 +0x120
    go/types.(*StdSizes).Sizeof(0x0, {0x104c35a30, 0x104e19440})
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/sizes.go:229 +0x2f8
    go/types.(*Config).sizeof(...)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/sizes.go:334
    go/types.representableConst.func1(...)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/const.go:77
    go/types.representableConst({0x104c36d20, 0x104b96ba0}, 0x1400050a5a0, 0x104e19440, 0x0)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/const.go:93 +0x17c
    go/types.(*Checker).arrayLength(0x1400050a5a0, {0x104c35e58, 0x140000a2340?})
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/typexpr.go:534 +0x19c
    go/types.(*Checker).typInternal(0x1400050a5a0, {0x104c35f78, 0x140000a0330}, 0x0)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/typexpr.go:316 +0x8dc
    go/types.(*Checker).definedType(0x1400050a5a0, {0x104c35f78, 0x140000a0330}, 0x1049429f8?)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/typexpr.go:193 +0x28
    go/types.(*Checker).varType(0x1400050a5a0, {0x104c35f78, 0x140000a0330})
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/typexpr.go:158 +0x2c
    go/types.(*Checker).structType(0x1400050a5a0, 0x140004561b0, 0x140004561b0?)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/struct.go:114 +0x104
    go/types.(*Checker).typInternal(0x1400050a5a0, {0x104c36128, 0x140000963d8}, 0x1400036ebe0)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/typexpr.go:331 +0x14c
    go/types.(*Checker).definedType(0x1400050a5a0, {0x104c36128, 0x140000963d8}, 0x3?)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/typexpr.go:193 +0x28
    go/types.(*Checker).typeDecl(0x1400050a5a0, 0x1400036ebe0, 0x140000a4200, 0x0)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/decl.go:646 +0x418
    go/types.(*Checker).objDecl(0x1400050a5a0, {0x104c39af8, 0x1400036ebe0}, 0x0)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/decl.go:201 +0x750
    go/types.(*Checker).packageObjects(0x1400050a5a0)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/resolver.go:676 +0x3d8
    go/types.(*Checker).checkFiles(0x1400050a5a0, {0x140000a2000?, 0x4?, 0x4?})
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/check.go:525 +0x284
    go/types.(*Checker).Files(0x14000210000?, {0x140000a2000?, 0x14000098120?, 0x6?})
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/go/types/check.go:487 +0x80
    golang.org/x/tools/go/packages.(*loader).loadPackage(0x14000210000, 0x140002033b0)
    	/Users/coxley/.go/pkg/mod/golang.org/x/tools@v0.6.0/go/packages/packages.go:1052 +0x7b8
    golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
    	/Users/coxley/.go/pkg/mod/golang.org/x/tools@v0.6.0/go/packages/packages.go:851 +0x15c
    sync.(*Once).doSlow(0x0?, 0x0?)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/sync/once.go:78 +0xe0
    sync.(*Once).Do(...)
    	/opt/homebrew/Cellar/go/1.25.3/libexec/src/sync/once.go:69
    golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
    	/Users/coxley/.go/pkg/mod/golang.org/x/tools@v0.6.0/go/packages/packages.go:839 +0x44
    golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
    	/Users/coxley/.go/pkg/mod/golang.org/x/tools@v0.6.0/go/packages/packages.go:846 +0x2c
    created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1 in goroutine 29
    	/Users/coxley/.go/pkg/mod/golang.org/x/tools@v0.6.0/go/packages/packages.go:845 +0x78
    exit status 2
    FAIL	github.com/charithe/durationcheck	0.326s
    
    

    It panics with the following Go versions:

    • 1.25
    • 1.24
    • 1.23
    • 1.22

    Works with 1.21 and older:

    docker run -it -v=$(pwd):/app --workdir=/app --rm golang:1.21 sh -c 'go mod tidy && go test'
    
    # go: downloading golang.org/x/tools v0.6.0
    # go: downloading golang.org/x/sys v0.5.0
    # go: downloading golang.org/x/mod v0.8.0
    # go: downloading golang.org/x/sync v0.1.0
    # PASS
    # ok      github.com/charithe/durationcheck       0.315s
  5. gopherbot commented on Nov 20, 2025

    @gopherbot
    Contributor

    Change https://go.dev/cl/722161 mentions this issue: go/types, types2: replace setDefType with boundaries

  6. gopherbot commented on Dec 3, 2025

    @gopherbot
    Contributor

    Change https://go.dev/cl/726580 mentions this issue: go/types, types2: add check for finite memory at value observance

  7. added a commit that references this issue on Dec 9, 2025
    1274d58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugReportIssues describing a possible bug in the Go implementation.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions