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
eval: save_tv_as_string: Correctly handle an empty string #6558
Conversation
6426e40
to
03a0be3
Compare
03a0be3
to
b53b2ef
Compare
@ZyX-I Any idea why the test is sometimes failing in Travis like this:
I've been running |
Hmm, after clearing Travis' cache, everything ran fine except for the flaky timers tests. |
Let's re-run it a few times... |
Ok, it happened again in the coverage build. There was also this stderr output reported at the end of the run:
|
src/nvim/eval.c
Outdated
@@ -17409,7 +17409,8 @@ static char *save_tv_as_string(typval_T *tv, ptrdiff_t *const len, bool endnl) | |||
// print an error. | |||
if (tv->v_type != VAR_LIST) { | |||
const char *ret = tv_get_string_chk(tv); | |||
if (ret && (*len = strlen(ret))) { | |||
if (ret) { | |||
*len = strlen(ret); |
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.
Might be worth temporarily reverting this change to see if the problem still occurs with the new test. To avoid having to look at a bunch of failed builds, change the expect result to what happens on master.
eq("", eval('system("echo test", "")'))
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 lua tracebacks yet with the code reverted...
@@ -255,7 +255,7 @@ describe('system()', function() | |||
eq(2, eval("1+1")) -- Still alive? |
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.
off topic, just noticed the test on lin 250 should be:
feed_command('call system("cat - &", "input")')
Edit: fixed in 15119f9
b53b2ef
to
2a9d96b
Compare
When tv_get_string_chk returns a non-NULL value, we have a valid string. Propagating an error state (*len = -1, NULL return) for an empty string is invalid. Closes neovim#6554
2a9d96b
to
3ff92ba
Compare
I've run the Travis builds a few times now and none of them have failed. Looking better now. |
Hmm, saw this in #7924 :
|
I can repro it locally, will investigate. #7951 |
Test failure: test/functional/eval/system_spec.lua: "works with an empty string" E5677: Error writing input to shell-command: EPIPE ref neovim#6558 (comment)
Test failure: test/functional/eval/system_spec.lua: "works with an empty string" E5677: Error writing input to shell-command: EPIPE ref neovim#6558 (comment) ref neovim#6554
Test failure: test/functional/eval/system_spec.lua: "works with an empty string" E5677: Error writing input to shell-command: EPIPE ref neovim#6558 (comment) ref neovim#6554
When tv_get_string_chk returns a non-NULL value, we have a valid string.
Propagating an error state (*len = -1, NULL return) for an empty string
is invalid.
Closes #6554