mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-20 08:14:24 +00:00
Add goroutine dump and hang trigger to libbox
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package libbox
|
package libbox
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
@@ -10,3 +11,18 @@ func TriggerGoPanic() {
|
|||||||
*(*int)(unsafe.Pointer(uintptr(0))) = 0
|
*(*int)(unsafe.Pointer(uintptr(0))) = 0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TriggerGoHang(seconds int32) {
|
||||||
|
time.Sleep(time.Duration(seconds) * time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GoroutineDump() string {
|
||||||
|
buffer := make([]byte, 64*1024)
|
||||||
|
for {
|
||||||
|
n := runtime.Stack(buffer, true)
|
||||||
|
if n < len(buffer) {
|
||||||
|
return string(buffer[:n])
|
||||||
|
}
|
||||||
|
buffer = make([]byte, 2*len(buffer))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user