| 1 |
// Copyright 2016 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package main |
| 6 |
|
| 7 |
/* |
| 8 |
char *geterror() { |
| 9 |
return "cgo error"; |
| 10 |
} |
| 11 |
*/ |
| 12 |
import "C" |
| 13 |
import ( |
| 14 |
"fmt" |
| 15 |
) |
| 16 |
|
| 17 |
func init() { |
| 18 |
register("CgoPanicDeadlock", CgoPanicDeadlock) |
| 19 |
} |
| 20 |
|
| 21 |
type cgoError struct{} |
| 22 |
|
| 23 |
func (cgoError) Error() string { |
| 24 |
fmt.Print("") // necessary to trigger the deadlock |
| 25 |
return C.GoString(C.geterror()) |
| 26 |
} |
| 27 |
|
| 28 |
func CgoPanicDeadlock() { |
| 29 |
panic(cgoError{}) |
| 30 |
} |