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

new-build: Outputs to console after "exiting"? #3407

Closed
BardurArantsson opened this issue May 6, 2016 · 18 comments · Fixed by #3416
Closed

new-build: Outputs to console after "exiting"? #3407

BardurArantsson opened this issue May 6, 2016 · 18 comments · Fixed by #3416

Comments

@BardurArantsson
Copy link
Collaborator

BardurArantsson commented May 6, 2016

There seems to be something weird going on wrt. terminal output. (I must admit I'm not sure whether it's just me or it's an actual problem with cabal-install new-build.)

Here's a little example. When I run cabal-new blah1 blah2 on one of my projects, I get this output:

[... ELIDED...]
Preprocessing library cqrs-memory-0.11.0...
Preprocessing library cqrs-postgresql-0.11.0...
[10 of 10] Compiling Data.CQRS.PostgreSQL.Internal.Query ( src/Data/CQRS/PostgreSQL/Internal/Query.hs, /home/bardur/wd/cqrs/dist-newstyle/build/cqrs-postgresql-0.11.0/build/Data/CQRS/PostgreSQL/Internal/Query.o )

src/Data/CQRS/PostgreSQL/Internal/Query.hs:75:20:
    Not in scope: type constructor or class ‘Ops’
[MY_NORMAL_PROMPT] Preprocessing test suite 'tests' for cqrs-memory-0.11.0...
Linking /home/bardur/wd/cqrs/dist-newstyle/build/cqrs-memory-0.11.0/build/tests/tests ...

Notice the [MY_NORMAL_PROMPT] bit? It seems that the prompt somehow gets intermingled with Cabal's output.

(In some cases I even get two prompts, though I haven't been able to reproduce it reliably.)

Is there some forking happening in Cabal which could explain this?

EDIT: Should add this is as of cabal 030259c71a8c182c169e18bb7c67467a3d292f00

@BardurArantsson
Copy link
Collaborator Author

/cc @ezyang

@BardurArantsson
Copy link
Collaborator Author

Addendum: I think this is also causing some weird issues when using @ndmitchell's excellent ghcid with a command of cabal new-repl foo bar.

@23Skidoo
Copy link
Member

23Skidoo commented May 6, 2016

/cc @dcoutts

@23Skidoo
Copy link
Member

23Skidoo commented May 6, 2016

A small reproducible test case would be nice.

@ezyang
Copy link
Contributor

ezyang commented May 6, 2016

I've seen this error. It's reasonably easy to reproduce by hand by C^C'ing the process, then you see some extra output. The usual cause for a problem like this is that the C^C is being delivered to the wrong process, and the process which printing output never receives the signal.

@BardurArantsson
Copy link
Collaborator Author

Hm. I'm definitely not ^C the process. I'm just letting it run normally and error out.

I'll see if I can get a reproducer with public code.

@ezyang
Copy link
Contributor

ezyang commented May 6, 2016

I'm just saying that it's a similar effect: something is causing the "main" process to exit (but the reporting subprocess is still running.)

@BardurArantsson
Copy link
Collaborator Author

Ah, OK, sorry misunderstood :).

@ndmitchell
Copy link

If you run ghcid with --test it does send Ctrl-C to the process, which might explain why it happens with ghcid (or maybe you aren't doing that and it's something else)

@BardurArantsson
Copy link
Collaborator Author

OK, good information. It actually happens regardless of whether I'm using ghcid or not, but it seems to really send ghcid into a tail spin or repeated recompilation :).

@BardurArantsson
Copy link
Collaborator Author

BardurArantsson commented May 6, 2016

Reproducer: https://github.com/BardurArantsson/cqrs/tree/tmp-reproducer

Clone and run

cabal new-build cqrs-core cqrs-testkit cqrs-memory cqrs-postgresql cqrs-example

@BardurArantsson
Copy link
Collaborator Author

BardurArantsson commented May 6, 2016

I should add: The problem doesn't happen all the time. It seems to be timing-dependent, which perhaps isn't that surprising.

Just adding/moving incorrect code in some .hs files at random seems to be good at provoking the problem. EDIT: Maybe just touching all .hs files is sufficent -- anything which forces recompilation, basically.

@dcoutts
Copy link
Contributor

dcoutts commented May 8, 2016

I suspect this is all to do with exception handling in the execution of the plan, when using multiple processes. The exception handling is a big TODO (which I'm currently working on) so we can see if that fixes it and if not investigate further.

In the absence of ctl-c then we should expect the main process to exit last, having waited for all the other processes it started.

@dcoutts
Copy link
Contributor

dcoutts commented May 14, 2016

Not sure why this got closed automatically, it needs testing.

@dcoutts dcoutts reopened this May 14, 2016
@23Skidoo
Copy link
Member

Looks like GitHub can't distinguish "might fix" from "fix".

@dcoutts
Copy link
Contributor

dcoutts commented May 15, 2016

@BardurArantsson Thanks for supplying the test case with the repo and the git id. Unfortunately I cannot reproduce the original behaviour, using that repo and build of cabal. So I also cannot check if it is now fixed, but I suspect it may be, since we now handle failure to build a package properly. (Rather than just propagating the exception and terminating leaving other child processes running, but we continue with the build, waiting for things to finish etc and return info on all the successes/failures).

So since you can reproduce it, could I ask you to try the latest cabal from the master branch (at or after ff6e495) and see if it's fixed? That'd be much appreciated.

@BardurArantsson
Copy link
Collaborator Author

Haven't tried more than a couple of builds, but seemed to work OK for those. So let's call it "probably fixed" and we can re-open if necessary :).

@dcoutts
Copy link
Contributor

dcoutts commented May 23, 2016

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants