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 formatting panic for 0.13.x #749

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

VorpalBlade
Copy link
Contributor

Two commits are needed to fix this on 0.13:

  • Do not trace return value (causes panic on Result:Err). This is a cherry pick from main
  • Backport changes to Value::string_debug_with. This is manual backport of the way the code is now done in main and fixes the observed crash.

(fixes #747)

This ensures that we don't get an error on formatting a value without a debug protocol.

(fixes rune-rs#747)
@VorpalBlade
Copy link
Contributor Author

I'm not sure if there are any tests that also need to be backported or not.

@udoprog
Copy link
Collaborator

udoprog commented Jul 17, 2024

LGTM!

Did you intend to fix the Debug impl for Value as well to not return fmt::Error in case the debug impl errors?

@VorpalBlade
Copy link
Contributor Author

Did you intend to fix the Debug impl for Value as well to not return fmt::Error in case the debug impl errors?

The fix I did seems to work for my use case (no more panics), but it can still return error indeed. I'm not sure under what conditions that can happen though. But since posting this PR I did manage to hit that path again:

    let cmd = process::Command::new("ls");
    cmd.arg("-l");
    let child = cmd.spawn();
    dbg(cmd);

(This fails because cmd is apparently moved).

So perhaps we should also add something like the <object at address> format for the error case one level up?

Instead attempt to print *something*
@VorpalBlade
Copy link
Contributor Author

With the latest change we now get debug prints like: <unknown object at 0x7ffd3816a388: Cannot read, value is moved>, which seems maximally informative.

@udoprog
Copy link
Collaborator

udoprog commented Jul 17, 2024

That's great! I think there's still the is_err thing in the Debug impl (can't check right now) which we should probably get rid off?

Regardless I'll merge this when I'm home. Thanks!

@VorpalBlade
Copy link
Contributor Author

That's great! I think there's still the is_err thing in the Debug impl (can't check right now) which we should probably get rid off?

I must have missed this, not sure what is left at this point?

@udoprog udoprog merged commit 7ca2581 into rune-rs:0.13.x Jul 17, 2024
19 checks passed
@udoprog
Copy link
Collaborator

udoprog commented Jul 17, 2024

You're right. Thank you!

@udoprog udoprog added the bug Something isn't working label Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants