Skip to content

Conversation

oni-link
Copy link
Contributor

This patch fixes a crash in channel_job_start() when using rpc and spawning fails by
preventing channel_destroy_early() from freeing uninitialized rpc stuff.

Without this patch the following commands would crash:
:call rpcstart('unknown_command')

:set sh=unknown_command
:call jobstart('ls',{'rpc':1})

@marvim marvim added the RFC label Jul 14, 2018
@@ -347,6 +348,7 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout,
rstream_init(&proc->out, 0);
}

chan->is_rpc = rpc;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can even remove this and change next if to rpc, rpc_start will set it to true.

@@ -288,7 +288,8 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout,
chan->on_stdout = on_stdout;
chan->on_stderr = on_stderr;
chan->on_exit = on_exit;
chan->is_rpc = rpc;
// Prevent channel_destroy_early() from freeing uninitialized rpc stuff
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channel_alloc should return a channel in init state, this is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make it clear why chan->is_rpc should not be set yet. Should I add a comment further down when using channel_destroy_early() that the rpc part needs to be in its init state?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I add a comment further down when using channel_destroy_early() that the rpc part needs to be in its init state?

This is not true, channel_destroy_early() doesn't need any special condition, it works the same as the ordinary channel freeing function. I don't think the lack of special treatment of rpc channels needs a comment.

… rpc stuff

Without this patch the following commands would crash:
    :call rpcstart('unknown_command')

    :set sh=unknown_command
    :call jobstart('ls',{'rpc':1})
@oni-link
Copy link
Contributor Author

@bfredl, applied your review comments.

@oni-link oni-link changed the title [RFC] Fix crash in channel_job_start() in combination with rpc and unknown command [RDY] Fix crash in channel_job_start() in combination with rpc and unknown command Jul 15, 2018
@marvim marvim added RDY and removed RFC labels Jul 15, 2018
@bfredl bfredl merged commit c230ef2 into neovim:master Jul 15, 2018
@justinmk justinmk removed the RDY label Jul 15, 2018
justinmk added a commit that referenced this pull request Jul 18, 2018
FEATURES:
07499a8 #8709 man.vim: C highlighting for EXAMPLES section
07f82ad #8699 TUI: urxvt: also send xterm focus-reporting seqs
40911e4 #8616 API: emit nvim_buf_lines_event from :terminal
c46997a #8546 fillchars: Add "eob" flag

FIXES:
74d19f6 #8576 startup: avoid blank stdin buffer if other files were opened
4874214 #8737 Only waitpid() for processes that we care about
cd6e7e8 #8743 Check all child processes for exit in SIGCHLD handler
c230ef2 #8746 channel.c: Prevent channel_destroy_early() from freeing uninitialized rpc stuff
0ed8b12 #8681 transstr_buf: fix length comparison
d241f27 #8708 TUI: Fix standout mode
9afed40 #8698 man.vim: fix for mandoc
e889640 #8682 provider/node: npm --loglevel silent
1cbc830 #8613 API: nvim_win_set_cursor: set curswant
bf6048e #8628 checkhealth: Python: fix VIRTUAL_ENV check
3cc3506 #8528 checkhealth: node.js: also search yarn

CHANGES:
b751449 #8619 defaults: shortmess+=F
1248178 #8578 highlight: high-priority CursorLine if fg is set.
01570f1 #8726 terminal: handle &confirm and :confirm on unloading
56065bb #8721 screen: truncate showmode messages
bf2460e #7551 buffer: fix copying :setlocal options
c1c14fa #8520 Ex mode: always "improved" (gQ)
050f397 #7992 options: remove 'maxcombine` option (always 6)

INTERNAL:
463da84 #7992 screen: use UTF-8 representation
coditva pushed a commit to coditva/neovim that referenced this pull request Jul 28, 2018
FEATURES:
07499a8 neovim#8709 man.vim: C highlighting for EXAMPLES section
07f82ad neovim#8699 TUI: urxvt: also send xterm focus-reporting seqs
40911e4 neovim#8616 API: emit nvim_buf_lines_event from :terminal
c46997a neovim#8546 fillchars: Add "eob" flag

FIXES:
74d19f6 neovim#8576 startup: avoid blank stdin buffer if other files were opened
4874214 neovim#8737 Only waitpid() for processes that we care about
cd6e7e8 neovim#8743 Check all child processes for exit in SIGCHLD handler
c230ef2 neovim#8746 channel.c: Prevent channel_destroy_early() from freeing uninitialized rpc stuff
0ed8b12 neovim#8681 transstr_buf: fix length comparison
d241f27 neovim#8708 TUI: Fix standout mode
9afed40 neovim#8698 man.vim: fix for mandoc
e889640 neovim#8682 provider/node: npm --loglevel silent
1cbc830 neovim#8613 API: nvim_win_set_cursor: set curswant
bf6048e neovim#8628 checkhealth: Python: fix VIRTUAL_ENV check
3cc3506 neovim#8528 checkhealth: node.js: also search yarn

CHANGES:
b751449 neovim#8619 defaults: shortmess+=F
1248178 neovim#8578 highlight: high-priority CursorLine if fg is set.
01570f1 neovim#8726 terminal: handle &confirm and :confirm on unloading
56065bb neovim#8721 screen: truncate showmode messages
bf2460e neovim#7551 buffer: fix copying :setlocal options
c1c14fa neovim#8520 Ex mode: always "improved" (gQ)
050f397 neovim#7992 options: remove 'maxcombine` option (always 6)

INTERNAL:
463da84 neovim#7992 screen: use UTF-8 representation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants