Skip to content
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

fix folly::stringPrintf when ref empty str #4933

Merged
merged 7 commits into from
Nov 28, 2022

Conversation

pengweisong
Copy link
Contributor

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

#4926

Description:

when the sym_ in PropertyExpression is empty, return reference of string and pass it to folly::stringFormat will crash.

(gdb) bt
#0  0x00007f26e967f079 in vfprintf () from /lib64/libc.so.6
#1  0x00007f26e96aa179 in vsnprintf () from /lib64/libc.so.6
#2  0x0000000002c2a2b3 in ?? ()
#3  0x0000000002c2b737 in folly::stringVPrintf[abi:cxx11](char const*, __va_list_tag*) ()
#4  0x0000000002c2b8df in folly::stringPrintf[abi:cxx11](char const*, ...) ()
#5  0x00000000014ce1ca in nebula::storage::UpdateResNode<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::doExecute(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#6  0x00000000014bd030 in nebula::storage::RelNode<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::execute(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#7  0x00000000014bcd86 in nebula::storage::RelNode<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::doExecute(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#8  0x00000000014bd030 in nebula::storage::RelNode<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::execute(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#9  0x00000000014bbfb0 in nebula::storage::UpdateVertexProcessor::doProcess(nebula::storage::cpp2::UpdateVertexRequest const&) ()
#10 0x00000000028b3a27 in virtual thunk to apache::thrift::concurrency::FunctionRunner::run() ()
#11 0x0000000002a0ea38 in apache::thrift::concurrency::ThreadManager::Impl::Worker::run() ()
#12 0x0000000002a10b3e in apache::thrift::concurrency::PthreadThread::threadMain(void*) ()
#13 0x00007f26e9a07ea5 in start_thread () from /lib64/libpthread.so.0
#14 0x00007f26e9730b0d in clone () from /lib64/libc.so.6

How do you solve it?

just use exp->toString(), in which will test empty, and then copy.

Special notes for your reviewer, ex. impact of this fix, design document, etc:

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • N/A

Affects:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

ex. Fixed the bug .....

jievince
jievince previously approved these changes Nov 24, 2022
@pengweisong pengweisong marked this pull request as draft November 24, 2022 09:37
@critical27
Copy link
Contributor

critical27 commented Nov 24, 2022

@jievince, does graphd add something like constant folding?

UPDATE  VERTEX ON `aa` 'a:1005' SET `name` = 'test' YIELD 'a:1005' AS `aId`, `name`;

The root cause is that in YIELD 'a:1005' AS aId, previously it is a PropertyExpression or at least storaged assume it is. But it is a now a ConstantExpression, see the debug info below

two expression in returnPropsExp_ is 'a:1005' AS aId and name

image

@jievince
Copy link
Contributor

'a:1005' is a ConstantExpression generated by the parser.
The graph validator doesn't check the non-property related expr in the yield clause of update statement.
Do we allow such usage?

@critical27
Copy link
Contributor

Ok, I see. You could just remove the static_cast, and use exp->toString here. That could solve it. @pengweisong

@pengweisong
Copy link
Contributor Author

Ok, I see. You could just remove the static_cast, and use exp->toString here. That could solve it. @pengweisong

OK, fixed, and takes some time to compile and verify the sentences in the issue.

@pengweisong pengweisong added the ready-for-testing PR: ready for the CI test label Nov 25, 2022
@pengweisong pengweisong marked this pull request as ready for review November 25, 2022 03:11
@HarrisChu
Copy link
Contributor

could we add some tck cases?

@pengweisong
Copy link
Contributor Author

pengweisong commented Nov 25, 2022

could we add some tck cases?

OK, I'll try.

@Sophie-Xie Sophie-Xie merged commit 611c670 into vesoft-inc:master Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants