-
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
<xloctime>
: time_put::do_put
does not handle EINVAL
from _Wcsftime
#1563
Conversation
You need to set the invalid parameter handler to an actual function, not just |
Thank you for advice , I tried it, but it also makes tests failed |
I added the following handler, and tests/Dev11_0836436_get_time passed. Can you push the exact code you tried? void test_invalid_parameter_handler(const wchar_t* const expression, const wchar_t* const function,
const wchar_t* const file, const unsigned int line, const uintptr_t reserved) {
(void) expression;
(void) reserved;
// Stop test early. Without this,
static int num_called = 0;
if (num_called++ > 10) {
wprintf(L"Test Failed: Invalid parameter handler was called over 10 times by %s in %s:%u\n", function, file,
line); // These arguments are only populated in debug mode.
exit(1);
}
} |
Great! I'll try it later and if everything will be ok, there won't be any need to push my variant |
<xloctime>
: time_put::do_put
does not handle EINVAL
from _Wcsftime`
<xloctime>
: time_put::do_put
does not handle EINVAL
from _Wcsftime`<xloctime>
: time_put::do_put
does not handle EINVAL
from _Wcsftime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this bugfix that we took forever to review @futuarmo. Please let us know if you won't have time available to make the requested changes, and we'll polish up the PR and get it across the finish line.
FYI @amyw-msft @CaseyCarter, I pushed minor changes after you approved. |
@StephanTLavavej, thanks for fixes! I haven't time to do it in this several days |
I had to push an additional change to fix the internal test pass: |
Thanks for fixing this issue! 😸 🎉 🗓️ |
This PR fixes issue #1461
Error comes from
_Strftime
and_Wcsftime
,_Count
becomes 0 and we should stop execution and setios_base::badbit
if_Count == 0
.do_put
is called afteroperator<<
So, we can change
_Ostr
state only here according to standard function definitionI tried to pass
_State
as a parameter toput
method and it works perfectly, but it contrary to standard and, as I understand, it will be ABI break.Also I tried to invalidate iterator in
do_put
method, it works withwstringstream
, but doesn't works withsstringstream
:do_put
method part:I realize that it's wrong decision.
So, in my opinion the only way to fix it is to do something like that (it works too):
operator<<
iniomanip
headerAnd then set state to badbit in case if ucrt returns error (0):
Modified part of
do_put
:But this decision is not so elegant. Please review it and give some another opinion on this
Also, I added test for this case, but
ucrt
returns and error, tests become failed and error message appears. I tried to set_set_invalid_parameter_handler
to NULL and empty function but it doesn't help. Please, help to avoid it.