Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

james/remove wmi unneeded releases #1863

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ee/wmi/wmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ func Query(ctx context.Context, slogger *slog.Logger, className string, properti
}
defer serviceRaw.Clear()

// the memory of result is released by `defer serviceRaw.Clear()` above,
// on windows arm64 machines, calling `service.Clear()` after `serviceRaw.Release()`
// would cause a panic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// the memory of result is released by `defer serviceRaw.Clear()` above,
// on windows arm64 machines, calling `service.Clear()` after `serviceRaw.Release()`
// would cause a panic
// In testing, we find we do not need to `service.Release(). The memory of result is released
// by `defer serviceRaw.Clear()` above, furthermore on windows arm64 machines, calling
// `service.Clear()` after `serviceRaw.Release()` causes a panic

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or something. I think there are probably better phrases. More imperative or something

service := serviceRaw.ToIDispatch()
defer service.Release()

slogger.Log(ctx, slog.LevelDebug,
"running WMI query",
Expand All @@ -168,8 +170,10 @@ func Query(ctx context.Context, slogger *slog.Logger, className string, properti
}
defer resultRaw.Clear()

// the memory of result is released by `defer resultRaw.Clear()` above,
// on windows arm64 machines, calling `resultRaw.Clear()` after `result.Release()`
// would cause a panic
result := resultRaw.ToIDispatch()
defer result.Release()

if err := oleutil.ForEach(result, handler.HandleVariant); err != nil {
return nil, fmt.Errorf("ole foreach: %w", err)
Expand Down
Loading