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

ocamlopt thread not dying when ^C interrupted #7763

Closed
vicuna opened this issue Oct 23, 2002 · 3 comments
Closed

ocamlopt thread not dying when ^C interrupted #7763

vicuna opened this issue Oct 23, 2002 · 3 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 23, 2002

Original bug ID: 1453
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Sven Luther
Version: 3.06
OS: Debian GNU/Linux
Submission from: astrasbourg-206-1-18-22.abo.wanadoo.fr (81.49.129.22)

Hello,

la@iki.fi submitted me this bug report :

===============BEGIN===============
Problem: take any program, such as:

(* t.ml *)

let rec thr str =
print_string str;
print_newline ();
Thread.delay 1.0;
thr str

let _ =
ignore (Thread.create thr "foo");
ignore (Thread.create thr "bar");
read_line ()

...and native-compile it with thread support:

$ ocamlopt -o t -thread unix.cmxa threads.cmxa t.ml

It works, all right:

$ ./t
foo
bar
foo
bar
foo
bar

...and creates two extra threads, one is ocaml's tick thread, the other,
dunno, something used internally by linuxthreads?

$ ps -C t
PID TTY TIME CMD
12240 pts/5 00:00:00 t
12241 pts/5 00:00:00 t
12242 pts/5 00:00:00 t
12243 pts/5 00:00:00 t
12244 pts/5 00:00:00 t

Now control-C the program, and it stops. But:

$ ps -C t
PID TTY TIME CMD
12242 pts/5 00:00:00 t

And this is apparently the "tick" thread:

$ strace -p 12242
select(0, NULL, NULL, NULL, {0, 10000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout)

It has to be killed with kill -9. Not fun.
===============END=======================

I confirmed this, but it doesn't happen all the time, maybe 1/2 or 1/3 of the
time.

Maybe it is related to the moment the threaded program is interrupted.

Friendly,

Sven Luther

@vicuna
Copy link
Author

vicuna commented Oct 29, 2002

Comment author: administrator

la@iki.fi submitted me this bug report :
["tick" thread not dying when program is terminated by signal]

It took me a while to figure this one out, but this is actually a
consequence of LinuxThreads' non-POSIX-conformant signal handling :-)
I added a workaround in ocaml/otherlibs/systhreads/posix.c
(you can see it on camlcvs.inria.fr if you're interested). Hopefully
this kludge will become unnecessary when / if Linux has a fully
conformant POSIX threads implementation.

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Oct 29, 2002

Comment author: administrator

LinuxThreads-specific problem. Added workaround 2002-10-29, XL

@vicuna vicuna closed this as completed Oct 29, 2002
@vicuna
Copy link
Author

vicuna commented Oct 29, 2002

Comment author: administrator

On Tue, Oct 29, 2002 at 05:07:21PM +0100, Xavier Leroy wrote:

la@iki.fi submitted me this bug report :
["tick" thread not dying when program is terminated by signal]

It took me a while to figure this one out, but this is actually a
consequence of LinuxThreads' non-POSIX-conformant signal handling :-)
I added a workaround in ocaml/otherlibs/systhreads/posix.c
(you can see it on camlcvs.inria.fr if you're interested). Hopefully
this kludge will become unnecessary when / if Linux has a fully
conformant POSIX threads implementation.

Ok, ...

Is it ok if i ship a version of ocaml with this one fixed ?

It would be simpler if you had a stable bug fix CVS branch or something
such, but you already know that.

Anyway, i will extract the patch and apply it.

Friendly,

Sven Luther

@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant