Modify

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#13771 closed defect (not_a_bug)

Writing in a File when disk is full does not cause OSError - Python 2.7.3

Reported by: carlosmf.pt@… Owned by: developers
Priority: high Milestone: Barrier Breaker 14.07
Component: packages Version: Trunk
Keywords: python2 Cc:

Description

When writing in a file, if the disk or partition is full, python does not raise the Exception OSError with the appropriate errno related to disk being full.

The bug can be reproduced by inputting this simple code on the console.

fp = open("/dev/test.file", "w")
while True:
    fp.write(str([0]*1000))

I open the file inside dev because it has very low space and it should raise an exception immediately.

There's an strace output annexed to this bug report.

Maybe a Python2 source update to 2.7.5 would solve it.
This bug is not present in Python3.3 compiled to OpenWRT.

Attachments (1)

python2-openwrt.txt (57.4 KB) - added by big.claymore@… 5 years ago.
Strace python2

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by big.claymore@…

Strace python2

comment:1 Changed 5 years ago by Carlos Ferreira <carlosmf.pt@…>

For a proper evaluation, I change the file for the one that is used for these specific cases. The problem is the same.

fp = open("/dev/full", "w")
while True:
    fp.write(str([0]*1000))

comment:2 Changed 5 years ago by Cybjit <cybjit@…>

Similar issue for glibc http://bugs.python.org/issue17976

Python relies on the return value of fwrite, which seem unreliable in ulibc.
errno/ferror is a bit better, but I am not sure why they do not detect error on the first write.

Breakpoint 1, file_write (f=0x77ea2e38, args=0x77e73a30) at Objects/fileobject.c:1784
1784        n2 = fwrite(s, 1, n, f->f_fp);
(gdb) step
1785        FILE_END_ALLOW_THREADS(f)
(gdb) print n2
$1 = 3000
(gdb) print errno
$2 = 0
(gdb) print ferror(f->f_fp)
$3 = 0
(gdb) c
Continuing.

Breakpoint 1, file_write (f=0x77ea2e38, args=0x77e73a30) at Objects/fileobject.c:1784
1784        n2 = fwrite(s, 1, n, f->f_fp);
(gdb) step
1785        FILE_END_ALLOW_THREADS(f)
(gdb) print n2
$4 = 3000
(gdb) print errno
$5 = 28
(gdb) print ferror(f->f_fp)
$6 = 8

The code has not changed substantially in 2.7.5, so I doubt this is fixed
http://hg.python.org/cpython/file/e95161820160/Objects/fileobject.c#l1851

comment:3 Changed 5 years ago by Carlos Ferreira <carlosmf.pt@…>

Thanks for the Info! I didn't notice that there was already a bug report at python bug tracking system.

comment:4 Changed 5 years ago by blogic

  • Resolution set to not_a_bug
  • Status changed from new to closed

not a openwrt bug really.

comment:5 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.