Skip to content

cmd/compile: infinite loop in the inliner #73425

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

Open
randall77 opened this issue Apr 17, 2025 · 10 comments
Open

cmd/compile: infinite loop in the inliner #73425

randall77 opened this issue Apr 17, 2025 · 10 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. compiler/runtime Issues related to the Go compiler and/or runtime. Critical A critical problem that affects the availability or correctness of production systems built using Go NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@randall77
Copy link
Contributor

git clone https://gitlab.com/cznic/libsamplerate
cd libsamplerate
GOARCH=amd64 ~/go1.24.2/bin/go build

A sample of the infinite loop it appears to be in:

  * frame #0: 0x00000001006e7a34 compile`cmd/compile/internal/ir.(*CallExpr).doChildren + 52
    frame #1: 0x0000000100703d78 compile`cmd/compile/internal/ir.Any.func1 + 104
    frame #2: 0x00000001006f6934 compile`cmd/compile/internal/ir.(*ParenExpr).doChildren + 180
    frame #3: 0x0000000100703d78 compile`cmd/compile/internal/ir.Any.func1 + 104
    frame #4: 0x00000001007005b4 compile`cmd/compile/internal/ir.(*UnaryExpr).doChildren + 180
    frame #5: 0x0000000100703d78 compile`cmd/compile/internal/ir.Any.func1 + 104
    frame #6: 0x00000001006eb8e4 compile`cmd/compile/internal/ir.(*ConvExpr).doChildren + 180
    frame #7: 0x0000000100703d78 compile`cmd/compile/internal/ir.Any.func1 + 104
    frame #8: 0x00000001006f3b10 compile`cmd/compile/internal/ir.(*KeyExpr).doChildren + 224
    frame #9: 0x0000000100703d78 compile`cmd/compile/internal/ir.Any.func1 + 104
    frame #10: 0x00000001006eae10 compile`cmd/compile/internal/ir.(*CompLitExpr).doChildren + 224
    frame #11: 0x0000000100703d78 compile`cmd/compile/internal/ir.Any.func1 + 104
    frame #12: 0x00000001006fdb94 compile`cmd/compile/internal/ir.(*StructKeyExpr).doChildren + 180
    frame #13: 0x0000000100703d78 compile`cmd/compile/internal/ir.Any.func1 + 104
    frame #14: 0x00000001006eae10 compile`cmd/compile/internal/ir.(*CompLitExpr).doChildren + 224
    frame #15: 0x0000000100703d78 compile`cmd/compile/internal/ir.Any.func1 + 104
    frame #16: 0x00000001006e5270 compile`cmd/compile/internal/ir.(*AssignStmt).doChildren + 224
    frame #17: 0x0000000100703d78 compile`cmd/compile/internal/ir.Any.func1 + 104
    frame #18: 0x00000001006dd834 compile`cmd/compile/internal/ir.(*Func).doChildren + 100
    frame #19: 0x0000000100703d78 compile`cmd/compile/internal/ir.Any.func1 + 104
    frame #20: 0x0000000100703cd0 compile`cmd/compile/internal/ir.Any + 176
    frame #21: 0x0000000100b83348 compile`cmd/compile/internal/inline.canInlineCallExpr + 2648
    frame #22: 0x0000000100b83ea4 compile`cmd/compile/internal/inline.mkinlcall + 52
    frame #23: 0x0000000100b81e98 compile`cmd/compile/internal/inline.TryInlineCall + 296
    frame #24: 0x0000000100c6acf0 compile`cmd/compile/internal/inline/interleaved.(*inlClosureState).edit + 144
    frame #25: 0x0000000100d72b58 compile`cmd/compile/internal/gc.Main.DevirtualizeAndInlinePackage.func2.1 + 152
    frame #26: 0x00000001006de3a4 compile`cmd/compile/internal/ir.WithFunc + 148
    frame #27: 0x0000000100d72a58 compile`cmd/compile/internal/gc.Main.DevirtualizeAndInlinePackage.func2 + 392
    frame #28: 0x0000000100701e80 compile`cmd/compile/internal/ir.(*bottomUpVisitor).visit + 880
    frame #29: 0x0000000100701ad4 compile`cmd/compile/internal/ir.VisitFuncsBottomUp + 196
    frame #30: 0x0000000100d711c4 compile`cmd/compile/internal/gc.Main + 4484
    frame #31: 0x0000000100d98650 compile`main.main + 272
    frame #32: 0x0000000100533844 compile`runtime.main + 644
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Apr 17, 2025
@randall77 randall77 added this to the Go1.24.3 milestone Apr 17, 2025
@randall77
Copy link
Contributor Author

@golang/compiler
@dr2chase Want to take a look?

@dmitshur
Copy link
Contributor

We'll need to create a backport candidate issue for the Go1.24.3 milestone; moving this to Go1.25.

@dmitshur dmitshur modified the milestones: Go1.24.3, Go1.25 Apr 17, 2025
@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Apr 17, 2025
@dr2chase
Copy link
Contributor

Tip looked fine (this was GOARCH=amd64 on Darwin).

But I checked it at the current tip of go1.24 (which is a hair past 1.24.2) and am currently 5 cpu minutes in on one compile in the build but at a stable 540MB of memory consumption. Dumping stacks from with the Apple profiler indeed suggests something in the inliner.

So perhaps we fixed it, but where/how?

@dr2chase
Copy link
Contributor

Well that was obvious (in highsight) cmd/compile: remove no-longer-necessary recursive inlining checks. The plan was to split the change into two parts so as to make it easier to backport. Mice, men, etc, oops.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/666555 mentions this issue: [release-branch.go1.24] cmd/compile: remove no-longer-necessary recursive inlining checks

@prattmic
Copy link
Member

Just to clarify, are you saying this was a regression in https://go.dev/cl/655155 (also backported in https://go.dev/cl/657075) which is fixed in https://go.dev/cl/655157?

@prattmic prattmic added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 18, 2025
@dr2chase
Copy link
Contributor

I didn't test it before https://go.dev/cl/655155 so I'm not sure it is a regression in that CL. It is a regression in one of the 1.24 inliner CLs, for sure.

@dr2chase
Copy link
Contributor

@gopherbot, please open a backport issue for 1.24. This is a serious compiler bug and a regression in 1.24.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #73440 (for 1.24).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@JunyangShao JunyangShao added the Critical A critical problem that affects the availability or correctness of production systems built using Go label Apr 23, 2025
@mknyszek mknyszek moved this to All-But-Submitted in Go Compiler / Runtime Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. compiler/runtime Issues related to the Go compiler and/or runtime. Critical A critical problem that affects the availability or correctness of production systems built using Go NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: All-But-Submitted
Development

No branches or pull requests

7 participants