Source file test/fixedbugs/issue5963.go
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 10 package main 11 12 import ( 13 "os" 14 "runtime" 15 ) 16 17 func 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 28 func main() { 29 } 30 31 /* Before fix: 32 33 invalid m->locked = 2 34 fatal error: internal lockOSThread error 35 36 goroutine 2 [runnable]: 37 runtime.MHeap_Scavenger() 38 /Users/rsc/g/go/src/pkg/runtime/mheap.c:438 39 runtime.goexit() 40 /Users/rsc/g/go/src/pkg/runtime/proc.c:1313 41 created by runtime.main 42 /Users/rsc/g/go/src/pkg/runtime/proc.c:165 43 44 goroutine 3 [runnable]: 45 main.funcĀ·002() 46 /Users/rsc/g/go/test/fixedbugs/issue5963.go:22 47 created by main.initĀ·1 48 /Users/rsc/g/go/test/fixedbugs/issue5963.go:24 +0xb9 49 exit status 2 50 */ 51