You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
**Be careful reproducing this as this will take all of the memory on your machine very
quickly.
1. cd into src/pkg/contianer/vector
2. run make generate
3. ???
4. All your cpu and memory are gone.
You can ^C out of the make call, but it will overwrite your intvector.go file in that
directory. So, make sure to revert intvector.go.
Simplified reproduction:
// foo.go
package main
type Foo int
func main() {
var a Foo
println(a)
}
$ gofmt -r='Foo -> Bar' foo.go
What is the expected output?
gofmt should change type Foo to type Bar.
What do you see instead?
No output. Memory usage and cpu usage is unbounded. Gofmt gets locked in an infinite
loop.
Which compiler are you using (5g, 6g, 8g, gccgo)?
6g
Which operating system are you using?
Mac OS X 10.5.7
Which revision are you using? (hg identify)
$ hg identify
b002b8e25d25 tip
Please provide any additional information below.
I isolated this problem to a change between weekly.2011-03-15 and weekly.2011-03-28
(sorry this is so wide). It doesn't seem to be related to the cpuprofiler addition to
gofmt because when I compile the 03-15 version with the 03-28 tree, we still see the
problem. I isolated the loop down to the following function in rewrite.go (in the gofmt
cmd dir):
49 // rewriteFile applies the rewrite rule 'pattern -> replace' to an entire file.
50 func rewriteFile(pattern, replace ast.Expr, p *ast.File) *ast.File {
51 m := make(map[string]reflect.Value)
52 pat := reflect.NewValue(pattern)
53 repl := reflect.NewValue(replace)
54 var f func(val reflect.Value) reflect.Value // f is recursive
55 f = func(val reflect.Value) reflect.Value {
56 for k := range m {
57 m[k] = nil, false
58 }
59 val = apply(f, val)
60 if match(m, pat, val) {
61 val = subst(m, repl, reflect.NewValue(val.Interface().(ast.Node).Pos()))
62 }
63 return val
64 }
65 return apply(f, reflect.NewValue(p)).Interface().(*ast.File)
66 }
Please let me know if you need anything else.
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: