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

Unix.select bug (triggered if linked against threads) #4844

Closed
vicuna opened this issue Aug 7, 2009 · 4 comments
Closed

Unix.select bug (triggered if linked against threads) #4844

vicuna opened this issue Aug 7, 2009 · 4 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Aug 7, 2009

Original bug ID: 4844
Reporter: Christoph Bauer
Assigned to: gildor
Status: closed (set by @xavierleroy on 2012-03-24T14:01:02Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.11.0
Fixed in version: 3.12.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @ygrek gildor

Bug description

The attached program fails, if compiled with
ocamlopt -thread -o selectbug.exe unix.cmxa threads.cmxa selectbug.ml
and runs, if compiled with
ocamlopt -thread -o selectbug.exe unix.cmxa selectbug.ml

If you run it, please type some input, because it makes a Unix.select on stdin.

Additional information

There was a discussion on the mailing (8-July-2009) list about the problem.

File attachments

@vicuna
Copy link
Author

vicuna commented Aug 7, 2009

Comment author: gildor

Discussion is here
http://groups.google.com/group/fa.caml/browse_thread/thread/c634c736765897ee#

Possible problem/solution:

I use "lpOrig = (void *)fd;" where fd is an OCaml value (in select.c). Without thread and during the enter/leave_blocking_section(), there is less chance to trigger the GC and to modify "fd" value. This is the reason why it seems correct without thread and fall into a bug with thread.

The obvious solution is to replace "lpOrig = (void *)fd" by a non-OCaml value (e.g. EMode + nth in ocaml list).

@vicuna
Copy link
Author

vicuna commented Aug 10, 2009

Comment author: Christoph Bauer

The hinted solution seems to work. I'll attach a modified version of otherlibs/win32unix/select.c,
which solved the problems in selectbug.ml and my original program. But beware, I haven't it tested very well.

@vicuna
Copy link
Author

vicuna commented Jan 7, 2010

Comment author: Christoph Bauer

I use this patch (select.c) every day - and it works. So now I could say, it's well tested.

@vicuna
Copy link
Author

vicuna commented May 25, 2010

Comment author: gildor

Apply patch by C. Bauer, replace lpOrig by lpOrigIdx which can survive a GC collection

@vicuna vicuna closed this as completed Mar 24, 2012
@vicuna vicuna added the bug label Mar 20, 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