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

Fatal error: exception Sys_error("Bad file descriptor") Raised by primitive operation at file "pervasives.ml" #7487

Closed
vicuna opened this issue Feb 18, 2017 · 4 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Feb 18, 2017

Original bug ID: 7487
Reporter: berenger
Assigned to: @gasche
Status: resolved (set by @gasche on 2017-02-18T01:32:55Z)
Resolution: not a bug
Priority: normal
Severity: major
Version: 4.04.0
Category: standard library

Bug description

line 330, characters 2-47
Called from file "printf.ml", line 20, characters 28-44

I tried with 4.01.0, 4.03.0 and 4.04.0.
They all crash.

I am very surprised. Please tell me if you also observe this behavior.

Steps to reproduce

git clone https://github.com/UnixJunkie/ocaml_bug_01.git
cd ocaml_bug_01
./crashme.sh

Additional information

I suspect some recent change in the format module introduced this problem.

@vicuna
Copy link
Author

vicuna commented Feb 18, 2017

Comment author: berenger

Same thing with bytecode. :(

@vicuna
Copy link
Author

vicuna commented Feb 18, 2017

Comment author: berenger

That style would not crash:

let out = open_out out_fn in
(* Utls.with_out_file out_fn (fun out -> *)
List.iteri (fun i x ->
    fprintf out "%d %.3f\n" i x
  ) cum_curve;
close_out out

I.e. when we are not using the with_out_file function.

@vicuna
Copy link
Author

vicuna commented Feb 18, 2017

Comment author: @sliquister

This is not a compiler issue, your code is just broken: the function passed to with_out_file, instead of using the channel, returns a function that closes over the channel and then tries to use the channel after with_out_file returns.
Though it is true that functions of type .. -> (foo -> 'a) -> (foo -> 'a) are error prone because of currying.

@vicuna vicuna closed this as completed Feb 18, 2017
@vicuna
Copy link
Author

vicuna commented Feb 20, 2017

Comment author: berenger

This can be closed.
Sorry for the noise, my mistake, my function was not supposed to be partially applied.

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

No branches or pull requests

2 participants