-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Weird _invalid_parameter failures in _STL_ASSERT #2335
Comments
Could you give a some example which gives the compilation error? |
Unfortunately it is a closed source large project that I can not share. Linked gitlab issue seems to be reproducible since it is in some open source msft github project. Author there explained his steps: note: that issue is on W11, I am on W10, so I guess that is to show OS version is not the issue(probably) |
I modified About Install Windows SDK and look into the file: |
Did you make some modifications with
I can't reproduce the bug without witchcraft with the _DEBUG macro... |
I am a bit confused(sorry not a professional level lib developer). Shouldn't STL be self-contained, so should I not be able to at least see the forward declaration of Or STL depends on the Windows SDK being installed also? As for _DEBUG macro(your next comment) I will try to investigate, but my projects are not trivial, so I cant promise results. |
STL depends on UCRT and some other Windows libs. You can try forward declare the function, maybe it will work as workaround: #ifdef _DEBUG
_ACRTIMP void __cdecl _invalid_parameter(
_In_opt_z_ wchar_t const*,
_In_opt_z_ wchar_t const*,
_In_opt_z_ wchar_t const*,
_In_ unsigned int,
_In_ uintptr_t
);
#endif |
Yes, it will. and before I hope it will fix the issue... |
OK, also just confirmed that your fix probably works(I tested only 1 project). I did not know where to get
Anyways I am not STL expert STL so I have no idea if what pybind does is legal, that is for you and the team to discuss, I am happy we narrowed it down, so you can close this bug as a not caused by STL or whatever you decide... Thanks for the help. |
Yes, you are correct.
You're welcome. |
For future visitors: forward declaration fixes the issue of compile, but I still get linker issues. It is possible I got the wrong signature, but even when I tried to match the signature in windows headers I still got link failures. |
It is possible that my project does not link it, or is it linked implicitly whenever I use MSFT STL? I tried your suggestion, I get:
my code is:
When I remove _ACRTIMP from function signature I get inconsistent dll linkage error/warning, so it seems that compiler has already seen this function before... weird. |
Try add the macro :
and probably you can delete everything that we added before... |
It worked. Again thank you very much. Out of curiosity: is this a workaround for pybind undefined behavior or is it a fix for STL? |
You linked to release UCRT, this is why the function is not found. With We started passing parameters to the debug message box in a different way because with ranges and namespaces function name might be very big. Read the discussion: #2054 |
I was trying to build Debug build, I presume pybind messed stuff up then... |
To be clear: redefinition of If pybind is touching I'm going to close this as invalid - I see no STL bug here - but feel free to the continue discussion and attempts to find an even-more-egregious hack to workaround the problems this egregious hack is causing if you like. |
Thank you Casey, I guessed so since it starts with _ but was not sure since it is a macro. Will open pybind bug. I wish C++ compilers knew about special macros and disallowed/warned on redefinition, but then again I wish C++ had so many thing... |
@libbooze , clang warns about it: https://gcc.godbolt.org/z/cnE3jeaKf |
Very nice, if somebody from MSFT is reading: if your compiler dev friends are bored ;) this would be a nice warning to add. |
I don't think the issue is reading by anyone besides me, Casey and you :) But I found the same requested feature at DevCom by https://github.com/tiagomacarios: https://developercommunity.visualstudio.com/t/Add-a-checker-to-flag-functions-in-the-r/1524874 You can upvote it. I upvoted. (I am "Игорь Жуков" there) Maybe it will get enough upvotes for the developers to start implementing it. :) |
We have to undefine If we don't, then |
This is very confusing, I did not mess with installation, looks like just internal header inclusion is missing, but then it makes no sense that everything is not broken.
Also it seems this is broken for somebody else too:
microsoft/onnxruntime#9735
For helping people search: error is this:
'_invalid_parameter': is not a member of '`global namespace'
The text was updated successfully, but these errors were encountered: