This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug stdio/22796] New: fread with a large number of elements sometimes doesn't set orientation


https://sourceware.org/bugzilla/show_bug.cgi?id=22796

            Bug ID: 22796
           Summary: fread with a large number of elements sometimes
                    doesn't set orientation
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: antonios.motakis at huawei dot com
  Target Milestone: ---

Created attachment 10788
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10788&action=edit
Check orientation after fread

Tested on glibc master as of 6th of February 2017, commit
6d7aa2b531088c3a277911534179975eb2622954 on Linux/x86_64

The attached C source file can demonstrate the bug. Before running the test I
create a testfile:
$ echo hello, world! > testfile

The key/interesting part in the source is:
        ret = fread(buffer, 4, BUFSIZ/4, f);
        printf("fread returned %d\n", ret);

        ret = fwide(f, 0);
        printf("fwide after fread %d\n", ret);

Running the test on my machine:
        fwide after open 0
        fread returned 3
        fwide after fread 0

I would expect, according to POSIX, fwide to return -1 after fread, since
otherwise no error has occurred. Instead I get 0 (unchanged orientation).

If I replace the fread with this one:
        ret = fread(buffer, 4, 4, f);

fwide will return -1 as expected. There seems to be a certain number of
elements, where fread doesn't affect orientation as expected.

POSIX reference:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_05_02

Extra info:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-18'
--with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared
--enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--with-target-system-zlib --enable-objc-gc=auto --enable-multiarch
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18) 

$ ld -v
GNU ld (GNU Binutils for Debian) 2.28

$ uname -a
Linux Arya 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23) x86_64
GNU/Linux

Only configure option used with glibc was --prefix

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]