Pagghiu / SaneCppLibraries

Sane C++ Libraries
https://pagghiu.github.io/SaneCppLibraries
MIT License
507 stars 11 forks source link

Access violation on windows #15

Closed silent-tech closed 4 months ago

silent-tech commented 4 months ago

Hello, unfortunately I have an issue with SCLib on windows. I got an exception in the Async module.

Details of my environment:

Details of the error: "Exception thrown at 0x00007FF7DDFD1536 in SCTest.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF."

Call Stack: SCTest.exe!SC::detail::AsyncWinOverlapped::getUserDataFromOverlapped(_OVERLAPPED lpOverlapped) Line 32 C++ SCTest.exe!SC::AsyncEventLoop::KernelQueue::getAsyncRequest(unsigned int index) Line 200 C++ SCTest.exe!SC::AsyncEventLoop::Private::runStepExecuteCompletions(SC::AsyncEventLoop::KernelQueue & queue) Line 610 C++ SCTest.exe!SC::AsyncEventLoop::Private::runStep(SC::AsyncEventLoop::Private::SyncMode syncMode) Line 573 C++ SCTest.exe!SC::AsyncEventLoop::runNoWait() Line 269 C++ SCTest.exe!SC::AsyncEventLoop::Internal::createSharedWatchers(SC::AsyncEventLoop & eventLoop) Line 134 C++ SCTest.exe!SC::AsyncEventLoop::create(SC::AsyncEventLoop::Options options) Line 261 C++ SCTest.exe!SC::FileSystemWatcherTest::eventLoopSubdirectory(const SC::StringView appDirectory) Line 117 C++ SCTest.exe!SC::FileSystemWatcherTest::FileSystemWatcherTest(SC::TestReport & report) Line 23 C++ SCTest.exe!SC::runFileSystemWatcherTest(SC::TestReport & report) Line 334 C++ SCTest.exe!main(int argc, const char * argv) Line 157 C++

Locals of the AsyncWinOverlapped::getUserDataFromOverlapped function: offsetOfOverlapped -> 8 offsetOfAsync -> 0

I hope, it will be enough info to find the problem.

Pagghiu commented 4 months ago

Hi, thanks for the report!

I have been trying to reproduce it but without success 😞 Maybe the reason is that I mostly test things on Windows 11 ARM on a VM... I will try to get a Win 10 22H2 with Intel CPU to try this one.

It would be great if you could share some more context around the crash. Can you show me the content of the OVERLAPPED_ENTRY& object?

Also I am curious about value of idx when you get the crash at : https://github.com/Pagghiu/SaneCppLibraries/blob/df488cd871a9277f32b1efbb3b575c1707d56704/Libraries/Async/Async.cpp#L604

If you prefer you can also share details on the Discord, but here is good too, whatever you like 👀

Pagghiu commented 4 months ago

Ok I actually got the issue to reproduce on an Windows 10 22H2 on an Intel machine 🥳 Time to fix it 😈

silent-tech commented 4 months ago

Hello, it was very quick :) I updated my local repo, and tried your fix. Everything works fine now!

I appreciate your hard work. I hope, we can forget the ugly STD soon :)

Pagghiu commented 4 months ago

Thanks @silent-tech !

I am not testing Windows 10 regularly, so to avoid it regressing I have been adding a VS2019 project generator. This allows CI to build and run the tests also on the Windows Server 2019 GitHub runner (based on the Windows 10 kernel) .

I'm also running all tests using matrix strategy (see cdd5e3a) to test both Debug and Release configurations.

Let's catch 🐛 early with automation!