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

Reading a file in writable mode will return bogus value and delete content of file #1017

Closed
ricowind opened this issue Jan 2, 2012 · 4 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.

Comments

@ricowind
Copy link
Contributor

ricowind commented Jan 2, 2012

What will reproduce the issue:

void main() {
  File file = new File("testing.tmp");
  if (!file.existsSync()) {
    file.createSync();
  }

  RandomAccessFile fs = file.openSync(true);
  for (int i = 0; i < 10; i++) {
    fs.writeByteSync(i);
  }
  fs.closeSync();

  fs = file.openSync(true);
  for (int i = 0; i < 10; i++) {
    print(fs.readByteSync());
  }
  fs.closeSync();
}

Expected output:
Writes out the numbers 0,1,2..,9

Actual output:
Writes out 8,8,8..,8

Changing the parameter of the second file.openSync call to false fixes the issue and writes out the numbers.

@ricowind
Copy link
Contributor Author

ricowind commented Jan 2, 2012

Actually, this is the currently intended approach, but being changed with this cl:
http://codereview.chromium.org/9034005/

The return value is a bit strange though (backspace)

@madsager
Copy link
Contributor

madsager commented Jan 3, 2012

cc @sgjesse.
Set owner to @madsager.
Added Started label.

@sgjesse
Copy link
Contributor

sgjesse commented Jan 3, 2012

http://codereview.chromium.org/9072003 should fix the wrong return value.

@madsager
Copy link
Contributor

The change to allow opening files for appending has landed too. Closing.


Added Fixed label.

@ricowind ricowind added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. labels Jan 18, 2012
dart-bot pushed a commit that referenced this issue Mar 17, 2021
2021-03-17 sgrekhov@unipro.ru Fixes #1017. Use => for setter returning value tests
2021-03-16 irina.arkhipets@gmail.com Issue #996: more tests for Generic functions as type arguments and bounds added.
2021-03-16 sgrekhov@unipro.ru Fixes #1005. Description updated for method_definition tests
2021-03-16 sgrekhov@unipro.ru Fixes #1011. Expect an error if non-function type is called as a function
2021-03-16 irina.arkhipets@gmail.com Issue #996: tests for Generic functions as type arguments and bounds re-factored, more tests added.
2021-03-15 irina.arkhipets@gmail.com Issue #996: tests for Generic functions as type arguments and bounds added.
2021-03-15 irina.arkhipets@gmail.com Issue #996: tests for Generic functions as type arguments and bounds added.
2021-03-15 sgrekhov@unipro.ru Missed experiment flag added
2021-03-12 irina.arkhipets@gmail.com Issue #996: tests for Generic functions as type arguments and bounds added.
2021-03-12 sgrekhov@unipro.ru #993. Added tests checking that Struct fields cannot have initializers
2021-03-12 sgrekhov@unipro.ru #993. Tests for not external members of Struct subtype added
2021-03-11 sgrekhov@unipro.ru #993. Use package ffi in co19 ffi tests
2021-03-09 sgrekhov@unipro.ru Fixes #995. Annotations with type arguments tests added
2021-03-09 irina.arkhipets@gmail.com Issue #997: existing triple-shift tests corrected.
2021-03-09 irina.arkhipets@gmail.com More fixes for #535: split constant evaluation tests because static behavior of the strong and weak mode is different.
2021-03-04 sgrekhov@unipro.ru #993. Array tests added
2021-03-04 sgrekhov@unipro.ru #993. Pointer equality tests added
2021-03-03 sgrekhov@unipro.ru #993. Pointer.elementAt() tests added
2021-03-02 sgrekhov@unipro.ru #993. Pointer.cast() tests added
2021-03-01 sgrekhov@unipro.ru #993. Pointer tests added
2021-03-01 sgrekhov@unipro.ru Fixes #936. Change expected result according to the new left top rule
2021-02-26 irina.arkhipets@gmail.com Fixed #998: tests checks output streams correctly now.
2021-02-26 sgrekhov@unipro.ru #993. IntPtr tests added
2021-02-26 sgrekhov@unipro.ru #993. More Struct tests added
2021-02-25 irina.arkhipets@gmail.com Tests updated, missing issue tags added.
2021-02-25 sgrekhov@unipro.ru #1003. Isolate test fixed to not to be a racy
2021-02-25 sgrekhov@unipro.ru Issue numbers added
2021-02-24 sgrekhov@unipro.ru Issue number added
2021-02-24 sgrekhov@unipro.ru #988. Typo in error message fixed
2021-02-24 sgrekhov@unipro.ru #988. Fix test expectations

Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try,dart2js-nnbd-linux-x64-chrome-try,ddc-nnbd-linux-release-chrome-try,front-end-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I718644028b1d2a9fbba0c7efdf2923bb67184fde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191409
Reviewed-by: William Hesse <whesse@google.com>
copybara-service bot pushed a commit that referenced this issue Sep 14, 2023
Revisions updated by `dart tools/rev_sdk_deps.dart`.

ecosystem (https://github.com/dart-lang/ecosystem/compare/e96fbdb..babf5d1):
  babf5d1  2023-09-13  Devon Carew  add additional lints to dart_flutter_team_lints (#167)
  7740bef  2023-09-13  Moritz  Write comments on forks for `firehose` (#165)

http (https://github.com/dart-lang/http/compare/de19214..e19094a):
  e19094a  2023-09-14  Brian Quinlan  Use efficient operations when copying bytes between Dart and Java (#1019)
  d7e4375  2023-09-13  Parker Lougheed  Cleanup `package:http` utils (#1011)
  eafbbb0  2023-09-12  Brian Quinlan  Separate the cronet callbacks from the `send` method (#1017)
  2cbb703  2023-09-12  Brian Quinlan  Switch `cronet_http` to use jnigen (#1016)

native (https://github.com/dart-lang/native/compare/bbcbc1f..7faf62c):
  7faf62c  2023-09-14  Gabriel Terwesten  Add `includes`, `flags`, `std`, `language`, `cppLinkStdLib` options (#125)

shelf (https://github.com/dart-lang/shelf/compare/2926f76..e2a02b7):
  e2a02b7  2023-09-13  Kevin Moore  Move to latest pkg:dart_flutter_team_lints, bump min sdk to Dart 3 (#378)

tools (https://github.com/dart-lang/tools/compare/fa01f9b..1512f3d):
  1512f3d  2023-09-13  Elias Yishak  Add Fake Analytics instance that uses list to save events sent (#149)

webdev (https://github.com/dart-lang/webdev/compare/6b21ecf..501ccc2):
  501ccc28  2023-09-12  Elliott Brooks  Update DCM triggers to match Dart DevTools (#2230)

Change-Id: Ic3dc1924da48454a28e4c0d8705244ac1565e74a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325967
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

3 participants