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

File.ReadAsLinesSync silently does not read the whole of very large file on Linux #29161

Open
lukechurch opened this issue Mar 24, 2017 · 2 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@lukechurch
Copy link
Contributor

lukechurch commented Mar 24, 2017

Generate a large file, piping something like the following into a file:

import 'dart:io';

main() {
	for (int i = 0; i < 1000 * 1000 * 1000; i++) {
	   print ("$i: Long line of text to pad the file");
	}
}

Run this until the file is ~2.5Gb

Then load the file back

main() {
   var lst = new File('BigListOfNumbers.log').readAsLinesSync();

   print (lst.length);
   print (lst.last);
}

On OS X this will fail with an error message

FileSystemException: readSync failed, path = 'BigListOfNumbers.log' (OS Error: Invalid argument, errno = 22)

On Linux this appears to read only part of the file. The number reported is less than number reported by running 'tail' on the same file.

If there is a size limit on the files that can be read, this should reported as an error, rather than silently failing. This has resulted in a bug that proved very difficult to locate.

@lukechurch lukechurch added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io labels Mar 24, 2017
@lukechurch lukechurch changed the title File.ReadAsLinesSync silently does not read the whole of very large file File.ReadAsLinesSync silently does not read the whole of very large file on Linux Mar 24, 2017
@lrhn
Copy link
Member

lrhn commented Mar 28, 2017

The 2.5Gb size suggests a signed 32-bit integer overflow, and Dart doesn't have 32-bit integers, so the problem is likely in the OS glue code or maybe in not using the correct "big file aware" API (if one exists).

@zanderso zanderso added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Apr 7, 2017
@Szaki
Copy link

Szaki commented Jan 9, 2021

Can confirm this issue on Dart SDK version: 2.10.4 (stable) (Wed Nov 11 13:35:58 2020 +0100) on "macos_x64".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants