I have created an input library and I link with xinput.lib. The program that uses my input library crashes on start up before any user code is executed so it makes it pretty hard to debug. The program crashes during xinput dll loading which appears to happen in the generated dllmain function of my library. The error I get with the crash is “xinput: an invalid parameter was passed to a function that considers an invalid parameter an error”. If I add an empty dllmain function in my input library, everything works correctly and no crash. What could be causing the crash when no dllmain function exists. Seems like it’s a corruption of some sort and nothing to do specifically with xinput. However no user code has been executed before the crash so I’m lost at what it could be. Any thoughts? I’m on windows 11 and I’m using visual studio 2022 with clang-cl tool chain. I’d also like to point out that this was never an issue when I was using VS 2019 and windows 10. Could it be an issue with the new tool chain or os? Thank you.
EDIT 1:
Here is what the stack trace looks like when there is no dllmain in my library:
When i un-comment that empty DllMain in my library, there is no crash and everything works perfectly. Makes no sense since that DllMain does absolutely nothing.
EDIT 2:
I can confirm that this exact same behavior works on a complete empty project that links to Xinput.lib. Bare-bones console application with simple main() function that calls a function from a blank library that references Xinput.lib
CodePudding user response:
I can confirm that this must be a bug in the latest clang-cl tool-chain (it worked about 2 years ago when i was heavily working on this project). After using the msvc tool-chain, everything works as expected. I will file a bug report with Microsoft Visual Studio.