10000 fix(subst): skip large files on 32-bit by emillon · Pull Request #9811 · ocaml/dune · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(subst): skip large files on 32-bit #9811

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

Merged
merged 3 commits into from
Jan 30, 2024
Merged

fix(subst): skip large files on 32-bit #9811

merged 3 commits into from
Jan 30, 2024

Conversation

emillon
Copy link
Collaborator
@emillon emillon commented Jan 23, 2024

Fixes #9538

When subst tries to work on a file, it first loads it in memory as an OCaml string. This type has a maximum size, Sys.max_string_length. This is not an issue on 64-bit systems, but the 32-bit limit can be below the size of actual files.

However, it is unlikely that these files need substitutions, so we just log a warning in this case.

@rgrinberg
Copy link
Member

The change looks fine, but we need to be careful with introducing new exceptions. The issue is that exceptions don't get marshalled automatically over RPC so you can just break things internally when this error is raised. Instead, I propose the following:

  1. Introduce a function val read_file_unless_large : path -> (string, unit) result
  2. use this function to implement the current read_file. The Error case can be turned into a Code_error which is a safe exceptions to use
  3. In the subst code, use read_file_unless_large directly.

Fixes #9538

This logs a warning for large files (>16MB on 32-bit systems).

Signed-off-by: Etienne Millon <me@emillon.org>
@emillon
Copy link
Collaborator Author
emillon commented Jan 30, 2024

Thanks. I adapted that to the new API.

@emillon emillon merged commit c11c1f1 into main Jan 30, 2024
@emillon emillon deleted the fix-9538 branch January 30, 2024 14:47
@emillon emillon mentioned this pull request Feb 5, 2024
15 tasks
emillon added a commit to emillon/dune that referenced this pull request Feb 5, 2024
Fixes ocaml#9538

This logs a warning for large files (>16MB on 32-bit systems).

Signed-off-by: Etienne Millon <me@emillon.org>
@emillon emillon mentioned this pull request Feb 5, 2024
emillon added a commit to emillon/dune that referenced this pull request Feb 5, 2024
Fixes ocaml#9538

This logs a warning for large files (>16MB on 32-bit systems).

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit that referenced this pull request Feb 5, 2024
* test: add repro for #9538 (subst on 32-bit) (#9539)

Signed-off-by: Etienne Millon <me@emillon.org>

* refactor: detect large files in Io functions (#9828)

`Io.read_all` and related functions read the contents of a file in a
string, which has a size limit (`Sys.max_string_length`) and can be an
issue in 32-bit systems. This makes an explicit check and raises a
`Code_error` in these situations.

Signed-off-by: Etienne Millon <me@emillon.org>

* fix(subst): ignore large files (#9811)

Fixes #9538

This logs a warning for large files (>16MB on 32-bit systems).

Signed-off-by: Etienne Millon <me@emillon.org>

---------

Signed-off-by: Etienne Mi
8000
llon <me@emillon.org>
emillon added a commit to emillon/opam-repository that referenced this pull request Feb 5, 2024
CHANGES:

- Fix performance regression for incremental builds (ocaml/dune#9769, fixes ocaml/dune#9738,
  @rgrinberg)

- Fix `dune ocaml top-module` to correctly handle absolute paths. (ocaml/dune#8249, fixes
  ocaml/dune#7370, @Alizter)

- subst: ignore broken symlinks when looking at source files (ocaml/dune#9810, fixes
  ocaml/dune#9593, @emillon)

- subst: do not fail on 32-bit systems when large files are encountered. Just
  log a warning in this case. (ocaml/dune#9811, fixes ocaml/dune#9538, @emillon)

- boot: sort directory entries in readdir. This makes the dune binary
  reproducible in terms of filesystem order. (ocaml/dune#9861, fixes ocaml/dune#9794, @emillon)
nberth pushed a commit to nberth/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

- Fix performance regression for incremental builds (ocaml/dune#9769, fixes ocaml/dune#9738,
  @rgrinberg)

- Fix `dune ocaml top-module` to correctly handle absolute paths. (ocaml/dune#8249, fixes
  ocaml/dune#7370, @Alizter)

- subst: ignore broken symlinks when looking at source files (ocaml/dune#9810, fixes
  ocaml/dune#9593, @emillon)

- subst: do not fail on 32-bit systems when large files are encountered. Just
  log a warning in this case. (ocaml/dune#9811, fixes ocaml/dune#9538, @emillon)

- boot: sort directory entries in readdir. This makes the dune binary
  reproducible in terms of filesystem order. (ocaml/dune#9861, fixes ocaml/dune#9794, @emillon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dune subst crashes on large files (32-bit systems)
3 participants
0