Skip to content

feat: coredump - #6791

Merged
sholderbach merged 1 commit into
nushell:mainfrom
Decodetalkers:coredump
Oct 22, 2022
Merged

sholderbach merged 1 commit into
nushell:mainfrom
Decodetalkers:coredump

Conversation

@Decodetalkers

@Decodetalkers Decodetalkers commented Oct 18, 2022 •

Copy link
Copy Markdown
Contributor

Finally

Description

Coredump , try to fix again, here I just print the message, without use channels, so timers or timeout is not need, and all coredump messages will be print on the screen

#5903

Tests

Make sure you've done the following:

  • Add tests that cover your changes, either in the command examples, the crate/tests folder, or in the /tests folder.
  • Try to think about corner cases and various ways how your changes could break. Cover them with tests.
  • If adding tests is not possible, please document in the PR body a minimal example with steps on how to reproduce so one can verify your change works.

Make sure you've run and fixed any issues with these commands:

  • cargo fmt --all -- --check to check standard code formatting (cargo fmt --all applies these changes)
  • cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace --features=extra to check that all the tests pass

Documentation

@Decodetalkers

Copy link
Copy Markdown
Contributor Author

I should use a signal to send the coredump message..

@Decodetalkers

Copy link
Copy Markdown
Contributor Author

It seems 5d00ece
in this pr, he use a channel to return status, but it seems because of this channel, the message cannot always receive, so I think we should not send andy message, maybe?

@Decodetalkers
Decodetalkers marked this pull request as ready for review October 18, 2022 07:30
@Decodetalkers

Copy link
Copy Markdown
Contributor Author

And if signal hooks is must needed? maybe just show the program name is better?

@Decodetalkers

Copy link
Copy Markdown
Contributor Author

Emm. I think print the name is better, how can I get the name of process?

@nibon7

nibon7 commented Oct 18, 2022 •

Copy link
Copy Markdown
Contributor

@Decodetalkers
Decodetalkers force-pushed the coredump branch 13 times, most recently from ebb6392 to b193d6e Compare October 19, 2022 02:11
@Decodetalkers

Copy link
Copy Markdown
Contributor Author

Should not add more signals, just print message is fine

@WindSoilder

Copy link
Copy Markdown
Contributor

When I first meet println!, I'm nervous about it, but finally I think printing message is fine, user need to know it immediately :-) Look good to me :-)

@Decodetalkers

Decodetalkers commented Oct 19, 2022 •

Copy link
Copy Markdown
Contributor Author

When I first meet println!, I'm nervous about it, but finally I think printing message is fine, user need to know it immediately :-) Look good to me :-)

Emm,I used want to return an Err, but I finally give up to return an error... It will need another channel, and should consider the timeout, then sometimes we cannot receive the coredump message..

@sholderbach

Copy link
Copy Markdown
Member

Thanks for picking that up!
I think there are two/three questions we need to clarify to land this:

  1. Can we be sure we do not cause a pipeline stall or deadlock (whatever forced us to revert Return error when external command core dumped #5908 in Revert "Return error when external command core dumped (#5908)" #5987)
  2. Should a core dumped error be a variant of ShellError so you can programmatically handle that situation, and make sure following commands act accordingly? Following entries of a pipeline will never deal with something we output with println!
  3. Make sure the signal hooking doesn't interfere with other things we are doing to Unix signals and process groups. (e.g. main process setting up process groups (Foreground process group management, again #6584) and setting the Ctrl-C handler)

@Decodetalkers

Decodetalkers commented Oct 20, 2022 •

Copy link
Copy Markdown
Contributor Author

Thanks for picking that up! I think there are two/three questions we need to clarify to land this:

1. Can we be sure we do not cause a pipeline stall or deadlock (whatever forced us to revert [Return error when external command core dumped #5908](https://github.com/nushell/nushell/pull/5908) in [Revert "Return error when external command core dumped (#5908)" #5987](https://github.com/nushell/nushell/pull/5987))

2. Should a core dumped error be a variant of `ShellError` so you can programmatically handle that situation, and make sure following commands act accordingly? Following entries of a pipeline will never deal with something we output with `println!`

3. Make sure the signal hooking doesn't interfere with other things we are doing to Unix signals and process groups. (e.g. main process setting up process groups ([Foreground process group management, again #6584](https://github.com/nushell/nushell/pull/6584)) and setting the Ctrl-C handler)

1: I do not use channel, so .. And I think coredumped will not stop the procress..
2: I want to , but It will include a channel, then it will block the process. So I think show the information to user is enough
3: I do not know if signal hooks will influence other thing, if it will , I can remove the dependence of signal hooks, I just think show the information of signal is good, but if it will influence other progress, then it should be remove..

@Decodetalkers

Decodetalkers commented Oct 20, 2022 •

Copy link
Copy Markdown
Contributor Author

Thanks for picking that up! I think there are two/three questions we need to clarify to land this:

1. Can we be sure we do not cause a pipeline stall or deadlock (whatever forced us to revert [Return error when external command core dumped #5908](https://github.com/nushell/nushell/pull/5908) in [Revert "Return error when external command core dumped (#5908)" #5987](https://github.com/nushell/nushell/pull/5987))

2. Should a core dumped error be a variant of `ShellError` so you can programmatically handle that situation, and make sure following commands act accordingly? Following entries of a pipeline will never deal with something we output with `println!`

3. Make sure the signal hooking doesn't interfere with other things we are doing to Unix signals and process groups. (e.g. main process setting up process groups ([Foreground process group management, again #6584](https://github.com/nushell/nushell/pull/6584)) and setting the Ctrl-C handler)

Now I remove the dependence of signal-hook. then it won't conflict with other signal hook .. and always, people can view the whole message from coredumpctl, we just need to tell them it is coredumped, so I think just show it has coredumped is enough, or maybe can be showed with red color?

@Decodetalkers
Decodetalkers force-pushed the coredump branch 2 times, most recently from a944eb0 to 37fefd2 Compare October 20, 2022 10:12
@Decodetalkers

Decodetalkers commented Oct 20, 2022 •

Copy link
Copy Markdown
Contributor Author

image
I think now it is acceptable.. at least for me

But then the message won't be catched by piped..

@Decodetalkers
Decodetalkers force-pushed the coredump branch 2 times, most recently from 3abdcbc to 2a56440 Compare October 20, 2022 12:30
@Decodetalkers

Decodetalkers commented Oct 20, 2022 •

Copy link
Copy Markdown
Contributor Author

Now I add a code -2, will -2 used in other place? @sholderbach @WindSoilder
image
it is what it is now.. and I still print it , because I am afraid that the message may not be sended, Like such kind of thing:
image

@Decodetalkers
Decodetalkers force-pushed the coredump branch 2 times, most recently from cdb5126 to 52d9be1 Compare October 20, 2022 12:34
@WindSoilder

Copy link
Copy Markdown
Contributor

You can try to find all reference to PipelineData::ExternalStream's exit_code field:
Currently what I get the remaining are:

  1. complete command
  2. eval_block function
  3. PipelineData::into_value method

@Decodetalkers
Decodetalkers force-pushed the coredump branch 3 times, most recently from 3fee263 to 698f402 Compare October 20, 2022 15:47
fix issue in nushell#5903
return Error to pipeline_data, if match error, then return error
directly
@fdncred

fdncred commented Oct 22, 2022

Copy link
Copy Markdown
Contributor

What's the status on this? Are we ready to land it @WindSoilder @Decodetalkers @sholderbach?

@Decodetalkers

Copy link
Copy Markdown
Contributor Author

What's the status on this? Are we ready to land it @WindSoilder @Decodetalkers @sholderbach?

I think I have finished it..

@WindSoilder

Copy link
Copy Markdown
Contributor

Thanks, I think it's ok to me :)

@sholderbach sholderbach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, the exit code channel seems to be battle tested enough. And having this as an error is great!

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