Mercury Bugs - mercury
View Issue Details
0000336mercuryBugpublic2014-06-20 10:302018-03-13 14:38
Reporterwangp 
Assigned Topbone 
PrioritylowSeverityminorReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version 
Target Version15.11Fixed in Version 
Summary0000336: java programs do not wait for all threads to finish
DescriptionThe program terminates soon after the main thread exits, even if other threads are running.
TagsNo tags attached.
Attached Files

Notes
(0000702)
pbone   
2014-06-20 11:49   
Hi Peter,

I'm about to do some work on the Java concurrency stuff for MCit. So I'll look at this at the same time.

Thanks.
(0000705)
juliensf   
2014-06-24 12:37   
The behaviour of multi-threaded programs when the main thread terminates needs to be specified
somewhere, reference manual(?) or in the comment at the head of thread.m. Furthermore the behaviour
should be consistent across backends.
(0000712)
pbone   
2014-06-26 18:50   
Hi.

What should be the behavior if an error is raised. For example:
 + The exit status is set to non-zero (I think it should wait).
 + An exception is uncaught in main/2 (Should it exit immediately?)
 + Can a mercury program call abort() like one can in C?
 + An internal error (in Mercury) (it should exit immediately).

Thanks
(0000714)
wangp   
2014-06-27 10:51   
> What should be the behavior if an error is raised. For example:
> + The exit status is set to non-zero (I think it should wait).

Yes. It just sets a global variable.

> + An exception is uncaught in main/2 (Should it exit immediately?)

I think so.

> + Can a mercury program call abort() like one can in C?

Yes. Mercury can't prevent anyone doing so anyway.

> + An internal error (in Mercury) (it should exit immediately).

Yes. We can't continue after an internal (fatal) error.
(0000715)
pbone   
2014-06-27 10:55   
> > + Can a mercury program call abort() like one can in C?
>
> Yes. Mercury can't prevent anyone doing so anyway.

What I mean is, do we provide something like abort in Mercury? (I don't remember one myself), something like:

:- pred abort(int::in, io::di, io::uo) is det.

Which doesn't return.
(0000716)
juliensf   
2014-06-27 11:09   
By making the determinism of abort/3 det, you are telling the compiler that it _does_ return.
A better signature would be:

    :- pred abort(int::in, io::di) is erroneous.

In any case, I don't see the need for abort in Mercury. Every time I have needed something like it, throwing an exception back to the top-level has always sufficed.
(0000718)
pbone   
2014-06-27 11:20   
Okay cool, I wasn't proposing abort/3 just asking if we already had something like this.
(0000980)
pbone   
2018-03-13 14:38   
Unassigned things from me.

Issue History
2014-06-20 10:30wangpNew Issue
2014-06-20 11:49pboneAssigned To => pbone
2014-06-20 11:49pboneStatusnew => assigned
2014-06-20 11:49pboneNote Added: 0000702
2014-06-24 12:37juliensfNote Added: 0000705
2014-06-26 18:50pboneNote Added: 0000712
2014-06-27 10:51wangpNote Added: 0000714
2014-06-27 10:55pboneNote Added: 0000715
2014-06-27 11:09juliensfNote Added: 0000716
2014-06-27 11:20pboneNote Added: 0000718
2015-11-02 11:41pboneTarget Version => 15.11
2018-03-13 14:38pboneStatusassigned => acknowledged
2018-03-13 14:38pboneNote Added: 0000980