-
Notifications
You must be signed in to change notification settings - Fork 335
Exit when json::parse_string failed, avoid double valid string check #1791
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -336,6 +336,12 @@ namespace vcpkg::Json | |
| val.underlying_ = std::make_unique<ValueImpl>(ValueKindConstant<VK::String>(), std::move(s)); | ||
| return val; | ||
| } | ||
| Value Value::string_valid(std::string&& s) noexcept | ||
| { | ||
| Value val; | ||
| val.underlying_ = std::make_unique<ValueImpl>(ValueKindConstant<VK::String>(), std::move(s)); | ||
| return val; | ||
| } | ||
| Value Value::array(Array&& arr) noexcept | ||
| { | ||
| Value val; | ||
|
|
@@ -699,6 +705,7 @@ namespace vcpkg::Json | |
| } | ||
|
|
||
| add_error(msg::format(msgUnexpectedEOFMidString)); | ||
| vcpkg::Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgInvalidString); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is quite clearly trying to return the error message rather than terminate, I don't think elevating an error into termination is appropriate, particularly when this can happen from whatever user supplied input rather than a bug in the tool.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently there are only two functions call
I agree with this, but seems |
||
| return res; | ||
| } | ||
|
|
||
|
|
@@ -1036,7 +1043,7 @@ namespace vcpkg::Json | |
| { | ||
| case '{': return parse_object(); | ||
| case '[': return parse_array(); | ||
| case '"': return Value::string(parse_string()); | ||
| case '"': return Value::string_valid(parse_string()); | ||
| case 'n': | ||
| case 't': | ||
| case 'f': return parse_keyword(); | ||
|
|
||
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.
Unless there is a fairly extreme perf cost from the check on 330 I'm not really seeing a good reason to add this API. If there is an extreme perf reason, perhaps we should consider altering how that assertion works rather than adding a new API footgun like this.
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.
Yeah, it's not much necessary. I am investigating why sometimes
vcpkg searchis slow and then find thisjson::parse_valuefunctionWhen I pref
vcpkg search a, thejson::parse_valuefunction only costs about 5%-10%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.
I'm guessing you're using manifest mode? In that case the reason search is awfully slow is that we end up launching a git process per port to extract the tree sha. I had some work in progress to use
git mktreeto replace N git invocations with 2 git invocations but I haven't had time to get back to that.Also unfortunately child process launch time etc. won't be detected by a sampling based profiler like this since it only cares about CPU time in the process in question.
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.
I'm using the classic mode, and most of the time
vcpkg searchtakes only < 500ms, but occasionally it's slow, up to 5 seconds I guessThere 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.
Did you take your profile during one of the times where it was slow?
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.
No, currently I can't reproduce when build vcpkg from source
"slow" only occured when using offical vcpkg in classic mode, and not occured on all of my PCs
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.
I can reproduce when the first time I compile after I reboot, the search method costs about 5s