1// run 2 3// Copyright 2013 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7// Used to die in runtime due to init goroutine exiting while 8// locked to main thread. 9 10package main 11 12import ( 13 "os" 14 "runtime" 15) 16 17func init() { 18 c := make(chan int, 1) 19 defer func() { 20 c <- 0 21 }() 22 go func() { 23 os.Exit(<-c) 24 }() 25 runtime.Goexit() 26} 27 28func main() { 29} 30 31/* Before fix: 32 33invalid m->locked = 2 34fatal error: internal lockOSThread error 35 36goroutine 2 [runnable]: 37runtime.MHeap_Scavenger() 38 /Users/rsc/g/go/src/pkg/runtime/mheap.c:438 39runtime.goexit() 40 /Users/rsc/g/go/src/pkg/runtime/proc.c:1313 41created by runtime.main 42 /Users/rsc/g/go/src/pkg/runtime/proc.c:165 43 44goroutine 3 [runnable]: 45main.func·002() 46 /Users/rsc/g/go/test/fixedbugs/issue5963.go:22 47created by main.init·1 48 /Users/rsc/g/go/test/fixedbugs/issue5963.go:24 +0xb9 49exit status 2 50*/ 51