Open ashie opened 2 years ago
It doesn't crash when I use RubyInstaller 2.7.2.
The crash is occurred when a callback tries to access to the second argument of EnumWindowsProc
.
The pointer is valid when calling EnumWIndows
:
https://github.com/cosmo0920/win32-api/blob/9886db6d7f4d917864b9b544055c04993eac694e/ext/win32/api.c#L900-L903
but become invalid on calling the callback function: https://github.com/cosmo0920/win32-api/blob/9886db6d7f4d917864b9b544055c04993eac694e/ext/win32/api.c#L602-L603
It seems that one of the reason is that mismatched signature of callback function.
The signature of EnumWindowProc
is BOOL EnumWindowsProc(HWND, lParam)
but defined signature in win32-api is DWORD func(DWORD, DWORD)
https://github.com/cosmo0920/win32-api/blob/9886db6d7f4d917864b9b544055c04993eac694e/ext/win32/api.c#L688-L689
When I use same signature with EnumWindowsProc
, the test passed.
I confirmed that it occurs from RubyInstaller 2.7.3 (for 2.7 series).
Since win32-api cannot specify signature of callback function, it seems hard to fix. Migrating to Fiddle might be better solution than adding such feature to win32-api.
For Fluentd, probably callback feature isn't used so that it isn't affected immediately.
Currently a test is omitted due to a crash bug on latest RubyInstaller such as v2.7.5:
https://github.com/cosmo0920/win32-api/runs/4948175686?check_suite_focus=true#step:5:63
I'm investigating it.