ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:102751] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)"
@ 2021-03-05 23:03 cart4for1
  2021-03-05 23:14 ` [ruby-core:102752] " merch-redmine
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: cart4for1 @ 2021-03-05 23:03 UTC (permalink / raw
  To: ruby-core

Issue #17673 has been reported by stiuna (Juan Gregorio).

----------------------------------------
Bug #17673: sysseek(0)  and '1A' in header return "EOFError (end of file reached)"
https://bugs.ruby-lang.org/issues/17673

* Author: stiuna (Juan Gregorio)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------

The first byte of my file starts with the value **'1A'** .

Then:

``` ruby
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
#=> "EOFError (end of file reached)"
```

But when I change the first byte of my file to 'AA' for example.
Then:
``` ruby
#=> "aa45"
```


Is it a bug or am I missing something? I thought sysseek only changed the cursor and nothing else.

This error only occurs with byte **'1A'** I did the test with the rest of the bytes [00..FF] and there is no problem except with "1A".



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:102752] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)"
  2021-03-05 23:03 [ruby-core:102751] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)" cart4for1
@ 2021-03-05 23:14 ` merch-redmine
  2021-03-05 23:28 ` [ruby-core:102753] " cart4for1
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: merch-redmine @ 2021-03-05 23:14 UTC (permalink / raw
  To: ruby-core

Issue #17673 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Feedback

I tried your example and was unable to reproduce your problem:

```ruby
filePath = 'test.txt'
File.binwrite(filePath, "\x1A\x45")
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
# => ["1a45"]
```

Can you try on a different machine to check if this is a local problem?

----------------------------------------
Bug #17673: sysseek(0)  and '1A' in header return "EOFError (end of file reached)"
https://bugs.ruby-lang.org/issues/17673#change-90765

* Author: stiuna (Juan Gregorio)
* Status: Feedback
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------

The first byte of my file starts with the value **'1A'** .

Then:

``` ruby
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
#=> "EOFError (end of file reached)"
```

But when I change the first byte of my file to **'AA'** for example.
Then:
``` ruby
#=> "aa45"
```


Is it a bug or am I missing something? I thought sysseek only changed the cursor and nothing else.

This error only occurs with byte **'1A'** I did the test with the rest of the bytes **[00..FF]** and there is no problem except with **'1A'** .



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:102753] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)"
  2021-03-05 23:03 [ruby-core:102751] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)" cart4for1
  2021-03-05 23:14 ` [ruby-core:102752] " merch-redmine
@ 2021-03-05 23:28 ` cart4for1
  2021-03-05 23:39 ` [ruby-core:102754] " cart4for1
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cart4for1 @ 2021-03-05 23:28 UTC (permalink / raw
  To: ruby-core

Issue #17673 has been updated by stiuna (Juan Gregorio).


Can you try on a different machine to check if this is a local problem?

Unfortunately I don't have another computer to test the bug with, what version of ruby do you use?

----------------------------------------
Bug #17673: sysseek(0)  and '1A' in header return "EOFError (end of file reached)"
https://bugs.ruby-lang.org/issues/17673#change-90766

* Author: stiuna (Juan Gregorio)
* Status: Feedback
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------

The first byte of my file starts with the value **'1A'** .

Then:

``` ruby
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
#=> "EOFError (end of file reached)"
```

But when I change the first byte of my file to **'AA'** for example.
Then:
``` ruby
#=> "aa45"
```


Is it a bug or am I missing something? I thought sysseek only changed the cursor and nothing else.

This error only occurs with byte **'1A'** I did the test with the rest of the bytes **[00..FF]** and there is no problem except with **'1A'** .



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:102754] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)"
  2021-03-05 23:03 [ruby-core:102751] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)" cart4for1
  2021-03-05 23:14 ` [ruby-core:102752] " merch-redmine
  2021-03-05 23:28 ` [ruby-core:102753] " cart4for1
@ 2021-03-05 23:39 ` cart4for1
  2021-03-05 23:46 ` [ruby-core:102755] " merch-redmine
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cart4for1 @ 2021-03-05 23:39 UTC (permalink / raw
  To: ruby-core

Issue #17673 has been updated by stiuna (Juan Gregorio).


Aaah! I don't know if it matters but I use Windows, did you run it on Linux all of a sudden?

----------------------------------------
Bug #17673: sysseek(0)  and '1A' in header return "EOFError (end of file reached)"
https://bugs.ruby-lang.org/issues/17673#change-90767

* Author: stiuna (Juan Gregorio)
* Status: Feedback
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------

The first byte of my file starts with the value **'1A'** .

Then:

``` ruby
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
#=> "EOFError (end of file reached)"
```

But when I change the first byte of my file to **'AA'** for example.
Then:
``` ruby
#=> "aa45"
```


Is it a bug or am I missing something? I thought sysseek only changed the cursor and nothing else.

This error only occurs with byte **'1A'** I did the test with the rest of the bytes **[00..FF]** and there is no problem except with **'1A'** .



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:102755] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)"
  2021-03-05 23:03 [ruby-core:102751] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)" cart4for1
                   ` (2 preceding siblings ...)
  2021-03-05 23:39 ` [ruby-core:102754] " cart4for1
@ 2021-03-05 23:46 ` merch-redmine
  2021-03-06  0:04 ` [ruby-core:102756] " cart4for1
  2021-03-08  8:41 ` [ruby-core:102773] " nobu
  5 siblings, 0 replies; 7+ messages in thread
From: merch-redmine @ 2021-03-05 23:46 UTC (permalink / raw
  To: ruby-core

Issue #17673 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Feedback to Closed

I tried on Windows and I was able to reproduce the issue:

```
C:\Users\jeremye>c:\Ruby30-x64\bin\ruby

filePath = 'test.txt'
File.binwrite(filePath, "\x1A\x45")
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
__END__
-:7:in `sysread': end of file reached (EOFError)
        from -:7:in `<main>'
```

From some brief research, this is expected behavior on Windows for text files.  You need to put the file in binary mode (IO#binmode):

```
:\Users\jeremye>c:\Ruby30-x64\bin\ruby
filePath = 'test.txt'
File.binwrite(filePath, "\x1A\x45")
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.binmode
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
__END__
["1a45"]
```

----------------------------------------
Bug #17673: sysseek(0)  and '1A' in header return "EOFError (end of file reached)"
https://bugs.ruby-lang.org/issues/17673#change-90768

* Author: stiuna (Juan Gregorio)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------

The first byte of my file starts with the value **'1A'** .

Then:

``` ruby
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
#=> "EOFError (end of file reached)"
```

But when I change the first byte of my file to **'AA'** for example.
Then:
``` ruby
#=> "aa45"
```


Is it a bug or am I missing something? I thought sysseek only changed the cursor and nothing else.

This error only occurs with byte **'1A'** I did the test with the rest of the bytes **[00..FF]** and there is no problem except with **'1A'** .



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:102756] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)"
  2021-03-05 23:03 [ruby-core:102751] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)" cart4for1
                   ` (3 preceding siblings ...)
  2021-03-05 23:46 ` [ruby-core:102755] " merch-redmine
@ 2021-03-06  0:04 ` cart4for1
  2021-03-08  8:41 ` [ruby-core:102773] " nobu
  5 siblings, 0 replies; 7+ messages in thread
From: cart4for1 @ 2021-03-06  0:04 UTC (permalink / raw
  To: ruby-core

Issue #17673 has been updated by stiuna (Juan Gregorio).


Right, that solved it, the Ruby documentation should specify that. Ok, thanks.

----------------------------------------
Bug #17673: sysseek(0)  and '1A' in header return "EOFError (end of file reached)"
https://bugs.ruby-lang.org/issues/17673#change-90769

* Author: stiuna (Juan Gregorio)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------

The first byte of my file starts with the value **'1A'** .

Then:

``` ruby
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
#=> "EOFError (end of file reached)"
```

But when I change the first byte of my file to **'AA'** for example.
Then:
``` ruby
#=> "aa45"
```


Is it a bug or am I missing something? I thought sysseek only changed the cursor and nothing else.

This error only occurs with byte **'1A'** I did the test with the rest of the bytes **[00..FF]** and there is no problem except with **'1A'** .



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:102773] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)"
  2021-03-05 23:03 [ruby-core:102751] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)" cart4for1
                   ` (4 preceding siblings ...)
  2021-03-06  0:04 ` [ruby-core:102756] " cart4for1
@ 2021-03-08  8:41 ` nobu
  5 siblings, 0 replies; 7+ messages in thread
From: nobu @ 2021-03-08  8:41 UTC (permalink / raw
  To: ruby-core

Issue #17673 has been updated by nobu (Nobuyoshi Nakada).


This is not specific to Ruby, but the very (in)famous text mode spec of Windows (and other dosish systems).

----------------------------------------
Bug #17673: sysseek(0)  and '1A' in header return "EOFError (end of file reached)"
https://bugs.ruby-lang.org/issues/17673#change-90793

* Author: stiuna (Juan Gregorio)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------

The first byte of my file starts with the value **'1A'** .

Then:

``` ruby
descriptor = IO.sysopen(filePath)
file2Read = IO.new(descriptor)
file2Read.sysseek(0)
p file2Read.sysread(2).unpack('H*')
#=> "EOFError (end of file reached)"
```

But when I change the first byte of my file to **'AA'** for example.
Then:
``` ruby
#=> "aa45"
```


Is it a bug or am I missing something? I thought sysseek only changed the cursor and nothing else.

This error only occurs with byte **'1A'** I did the test with the rest of the bytes **[00..FF]** and there is no problem except with **'1A'** .



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-08  8:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-05 23:03 [ruby-core:102751] [Ruby master Bug#17673] sysseek(0) and '1A' in header return "EOFError (end of file reached)" cart4for1
2021-03-05 23:14 ` [ruby-core:102752] " merch-redmine
2021-03-05 23:28 ` [ruby-core:102753] " cart4for1
2021-03-05 23:39 ` [ruby-core:102754] " cart4for1
2021-03-05 23:46 ` [ruby-core:102755] " merch-redmine
2021-03-06  0:04 ` [ruby-core:102756] " cart4for1
2021-03-08  8:41 ` [ruby-core:102773] " nobu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).