@@ -893,7 +893,10 @@ func sigblock(exiting bool) {
893
893
// Called on the new thread, cannot allocate memory.
894
894
func minit () {
895
895
var thandle uintptr
896
- stdcall7 (_DuplicateHandle , currentProcess , currentThread , currentProcess , uintptr (unsafe .Pointer (& thandle )), 0 , 0 , _DUPLICATE_SAME_ACCESS )
896
+ if stdcall7 (_DuplicateHandle , currentProcess , currentThread , currentProcess , uintptr (unsafe .Pointer (& thandle )), 0 , 0 , _DUPLICATE_SAME_ACCESS ) == 0 {
897
+ print ("runtime.minit: duplicatehandle failed; errno=" , getlasterror (), "\n " )
898
+ throw ("runtime.minit: duplicatehandle failed" )
899
+ }
897
900
898
901
// Configure usleep timer, if possible.
899
902
var timer uintptr
@@ -1134,8 +1137,12 @@ func profileloop1(param uintptr) uint32 {
1134
1137
}
1135
1138
// Acquire our own handle to the thread.
1136
1139
var thread uintptr
1137
- stdcall7 (_DuplicateHandle , currentProcess , mp .thread , currentProcess , uintptr (unsafe .Pointer (& thread )), 0 , 0 , _DUPLICATE_SAME_ACCESS )
1140
+ if stdcall7 (_DuplicateHandle , currentProcess , mp .thread , currentProcess , uintptr (unsafe .Pointer (& thread )), 0 , 0 , _DUPLICATE_SAME_ACCESS ) == 0 {
1141
+ print ("runtime.profileloop1: duplicatehandle failed; errno=" , getlasterror (), "\n " )
1142
+ throw ("runtime.profileloop1: duplicatehandle failed" )
1143
+ }
1138
1144
unlock (& mp .threadLock )
1145
+
1139
1146
// mp may exit between the DuplicateHandle
1140
1147
// above and the SuspendThread. The handle
1141
1148
// will remain valid, but SuspendThread may
@@ -1214,7 +1221,10 @@ func preemptM(mp *m) {
1214
1221
return
1215
1222
}
1216
1223
var thread uintptr
1217
- stdcall7 (_DuplicateHandle , currentProcess , mp .thread , currentProcess , uintptr (unsafe .Pointer (& thread )), 0 , 0 , _DUPLICATE_SAME_ACCESS )
1224
+ if stdcall7 (_DuplicateHandle , currentProcess , mp .thread , currentProcess , uintptr (unsafe .Pointer (& thread )), 0 , 0 , _DUPLICATE_SAME_ACCESS ) == 0 {
1225
+ print ("runtime.preemptM: duplicatehandle failed; errno=" , getlasterror (), "\n " )
1226
+ throw ("runtime.preemptM: duplicatehandle failed" )
1227
+ }
1218
1228
unlock (& mp .threadLock )
1219
1229
1220
1230
// Prepare thread context buffer. This must be aligned to 16 bytes.
0 commit comments