feat: Tolerate collector failures (#1769)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2024-11-25 21:27:31 +01:00
committed by GitHub
parent fd76be38e0
commit 1a4c6c5ce7
121 changed files with 1726 additions and 1221 deletions

View File

@@ -27,7 +27,10 @@ import (
"golang.org/x/sys/windows"
)
// We have to registry a global callback function, since the amount of callbacks is limited.
// operationUnmarshalCallbacksInstanceResult registers a global callback function.
// The amount of system callbacks is limited to 2000.
//
//nolint:gochecknoglobals
var operationUnmarshalCallbacksInstanceResult = sync.OnceValue[uintptr](func() uintptr {
// Workaround for a deadlock issue in go.
// Ref: https://github.com/golang/go/issues/55015
@@ -135,7 +138,7 @@ func (o *OperationUnmarshalCallbacks) InstanceResult(
element, err := instance.GetElement(miTag)
if err != nil {
o.errCh <- fmt.Errorf("failed to get element: %w", err)
o.errCh <- fmt.Errorf("failed to get element %s: %w", miTag, err)
return 0
}
@@ -149,9 +152,8 @@ func (o *OperationUnmarshalCallbacks) InstanceResult(
field.SetInt(int64(element.value))
case ValueTypeSTRING:
if element.value == 0 {
o.errCh <- fmt.Errorf("%s: invalid pointer: value is nil", miTag)
return 0
// value is null
continue
}
// Convert the UTF-16 string to a Go string