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 Process.run uses in compiler to handle exec failure #9893

Conversation

straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Nov 6, 2020

Fixes more uses of Process.run to handle exec error (see #9867 and #9789). Also refactors the git code used in ProjectInfo to a common location for reusability.

See #9867 (comment)

Depends on #9867 includes #9867
Fixes #9789

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler labels Nov 6, 2020
@straight-shoota
Copy link
Member Author

straight-shoota commented Nov 6, 2020

This could also be merged directly instead of #9867

src/compiler/crystal/tools/doc/project_info.cr Outdated Show resolved Hide resolved
src/compiler/crystal/tools/init.cr Outdated Show resolved Hide resolved
@bcardiff
Copy link
Member

bcardiff commented Nov 9, 2020

@straight-shoota I think we can go with this PR as is instead of #9867, but I would need you to remove the Draft status.

@straight-shoota straight-shoota marked this pull request as ready for review November 9, 2020 21:26
@bcardiff bcardiff added this to the 1.0.0 milestone Nov 10, 2020
@straight-shoota straight-shoota changed the title Fix/compiler init missing executable Fix Process.run uses in compiler to handle exec failure Nov 11, 2020
@straight-shoota straight-shoota merged commit 11e1053 into crystal-lang:master Nov 11, 2020
@straight-shoota straight-shoota deleted the fix/compiler-init-missing-executable branch November 11, 2020 14:19
@oprypin
Copy link
Member

oprypin commented Nov 12, 2020

This PR never passed Windows CI, and that was not a fluke.

https://github.com/crystal-lang/crystal/actions?query=workflow%3A%22Windows+CI%22+branch%3Amaster

image

We need quick action; unfortunately Windows CI is broken in three different way on master right now.

@bcardiff
Copy link
Member

I can merge #9912 right away. After that the specs of this PR can be worked. Does that sound good?

@straight-shoota
Copy link
Member Author

@oprypin Sorry, I didn't realize the failure was an acutal bug in this PR. Let's make CI reliable again =)

assert_with_defaults(ProjectInfo.new("bar", "2.0"), ProjectInfo.new("bar", "2.0", refname: nil))
assert_with_defaults(ProjectInfo.new(nil, "2.0"), ProjectInfo.new("foo", "2.0", refname: nil))
ensure
Crystal::Git.executable = "git"
Copy link
Member

Choose a reason for hiding this comment

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

I confirm that the specs get stuck immediately after exiting this spec. But I can't figure out where. Both the around_each and before_each above also finish, and then somehow spec gets stuck, before entering the next spec.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should probably just add a quick fix to disable this spec on win32 to get CI working.

Copy link
Member

@oprypin oprypin Nov 12, 2020

Choose a reason for hiding this comment

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

I think I understand now. Of course, the bug in entirely in Crystal's support of Windows.

This leaves a dangling fiber that's still trying to pipe output of the non-launched process. While background fibers getting permanently stuck is a known (horrible) bug, perhaps there's another bug that forgets to close something if the process never actually launched.

Repro in cmd:

crystal eval "p! Process.run(%(missing), output: IO::Memory.new) rescue nil; p! Process.run(%(git), output: IO::Memory.new)"

Copy link
Member

Choose a reason for hiding this comment

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

@straight-shoota Yes, and looks like that'll even be the somewhat long-term fix. #9913

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing assertion error when building docs without git installed
4 participants