public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/18375] New: Syscall param write(buf) points to uninitialised byte(s) (valgrind reports)
@ 2015-05-05  0:54 eugeniofonseca14 at gmail dot com
  2015-05-05  0:59 ` [Bug stdio/18375] " eugeniofonseca14 at gmail dot com
  2015-05-05 17:43 ` schwab@linux-m68k.org
  0 siblings, 2 replies; 3+ messages in thread
From: eugeniofonseca14 at gmail dot com @ 2015-05-05  0:54 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 18375
           Summary: Syscall param write(buf) points to uninitialised
                    byte(s) (valgrind reports)
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: eugeniofonseca14 at gmail dot com
  Target Milestone: ---

Created attachment 8300
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8300&action=edit
Code that reproduces the error.

Hello all,

The code I'm sending generates a valid output file, but valgrind accuses
fclose() of violating memory, when flushing the file buffer to disk. fcloses
does what it is supposed to do, despite the memory access error.

#include<stdio.h>
#include<stdlib.h>

typedef struct{
    int x;
    int y;
    double distanceFromBase;
    unsigned int tanks;
    long long int ackIndex;
} TankAttack;


int main(){
    FILE* arq;
    TankAttack* p = (TankAttack*)malloc(sizeof(TankAttack));

    arq = fopen("0","wb");

    p->x = 10;
    p->y = 10;
    p->distanceFromBase = 10.0;
    p->tanks = 10;
    p->ackIndex = 10;

    fwrite(p,sizeof(TankAttack),1,arq);

    fclose(arq);
    free(p);
    return 0;
}

==6143== Syscall param write(buf) points to uninitialised byte(s)
==6143==    at 0x4F2F4E0: __write_nocancel (syscall-template.S:81)
==6143==    by 0x4EB1BFE: _IO_file_write@@GLIBC_2.2.5 (fileops.c:1251)
==6143==    by 0x4EB30E8: new_do_write (fileops.c:506)
==6143==    by 0x4EB30E8: _IO_do_write@@GLIBC_2.2.5 (fileops.c:482)
==6143==    by 0x4EB296F: _IO_file_close_it@@GLIBC_2.2.5 (fileops.c:164)
==6143==    by 0x4EA6851: fclose@@GLIBC_2.2.5 (iofclose.c:59)
==6143==    by 0x4006E5: main (in /home/eugenio/AEDS/WW2/out)
==6143==  Address 0x4026014 is not stack'd, malloc'd or (recently) free'd
==6143== 
==6143== 
==6143== HEAP SUMMARY:
==6143==     in use at exit: 0 bytes in 0 blocks
==6143==   total heap usage: 2 allocs, 2 frees, 584 bytes allocated
==6143== 
==6143== All heap blocks were freed -- no leaks are possible

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


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

* [Bug stdio/18375] Syscall param write(buf) points to uninitialised byte(s) (valgrind reports)
  2015-05-05  0:54 [Bug stdio/18375] New: Syscall param write(buf) points to uninitialised byte(s) (valgrind reports) eugeniofonseca14 at gmail dot com
@ 2015-05-05  0:59 ` eugeniofonseca14 at gmail dot com
  2015-05-05 17:43 ` schwab@linux-m68k.org
  1 sibling, 0 replies; 3+ messages in thread
From: eugeniofonseca14 at gmail dot com @ 2015-05-05  0:59 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #1 from Eugênio Fonseca <eugeniofonseca14 at gmail dot com> ---
Command lines used:

gcc teste.c -o out
valgrind ./out

GCC version:
gcc (Ubuntu 4.9.2-10ubuntu13) 4.9.2

Valgrind version:
valgrind-3.10.1

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From glibc-bugs-return-28156-listarch-glibc-bugs=sources.redhat.com@sourceware.org Tue May 05 01:03:23 2015
Return-Path: <glibc-bugs-return-28156-listarch-glibc-bugs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-glibc-bugs@sources.redhat.com
Received: (qmail 100509 invoked by alias); 5 May 2015 01:03:23 -0000
Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <glibc-bugs.sourceware.org>
List-Subscribe: <mailto:glibc-bugs-subscribe@sourceware.org>
List-Post: <mailto:glibc-bugs@sourceware.org>
List-Help: <mailto:glibc-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: glibc-bugs-owner@sourceware.org
Delivered-To: mailing list glibc-bugs@sourceware.org
Received: (qmail 100414 invoked by uid 48); 5 May 2015 01:03:13 -0000
From: "eugeniofonseca14 at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug stdio/18375] Syscall param write(buf) points to uninitialised byte(s) (valgrind reports)
Date: Tue, 05 May 2015 01:03:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: glibc
X-Bugzilla-Component: stdio
X-Bugzilla-Version: 2.21
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: eugeniofonseca14 at gmail dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: version
Message-ID: <bug-18375-131-rgKGre5FK2@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-18375-131@http.sourceware.org/bugzilla/>
References: <bug-18375-131@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-05/txt/msg00021.txt.bz2
Content-length: 390

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

Eugênio Fonseca <eugeniofonseca14 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |2.21

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From glibc-bugs-return-28157-listarch-glibc-bugs=sources.redhat.com@sourceware.org Tue May 05 09:21:01 2015
Return-Path: <glibc-bugs-return-28157-listarch-glibc-bugs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-glibc-bugs@sources.redhat.com
Received: (qmail 112447 invoked by alias); 5 May 2015 09:21:00 -0000
Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <glibc-bugs.sourceware.org>
List-Subscribe: <mailto:glibc-bugs-subscribe@sourceware.org>
List-Post: <mailto:glibc-bugs@sourceware.org>
List-Help: <mailto:glibc-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: glibc-bugs-owner@sourceware.org
Delivered-To: mailing list glibc-bugs@sourceware.org
Received: (qmail 112389 invoked by uid 48); 5 May 2015 09:20:57 -0000
From: "maiku.fabian at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug localedata/15593] [PATCH] Add transliteration data for "LATIN SMALL LETTER O WITH STROKE" (=?UTF-8?Q?ø?=).
Date: Tue, 05 May 2015 09:21:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: glibc
X-Bugzilla-Component: localedata
X-Bugzilla-Version: unspecified
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: maiku.fabian at gmail dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Resolution: FIXED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags: security-
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-15593-131-sM5ePMIpdr@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-15593-131@http.sourceware.org/bugzilla/>
References: <bug-15593-131@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-05/txt/msg00022.txt.bz2
Content-length: 399

https://sourceware.org/bugzilla/show_bug.cgi?id\x15593

Mike FABIAN <maiku.fabian at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maiku.fabian at gmail dot com

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


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

* [Bug stdio/18375] Syscall param write(buf) points to uninitialised byte(s) (valgrind reports)
  2015-05-05  0:54 [Bug stdio/18375] New: Syscall param write(buf) points to uninitialised byte(s) (valgrind reports) eugeniofonseca14 at gmail dot com
  2015-05-05  0:59 ` [Bug stdio/18375] " eugeniofonseca14 at gmail dot com
@ 2015-05-05 17:43 ` schwab@linux-m68k.org
  1 sibling, 0 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2015-05-05 17:43 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
>     fwrite(p,sizeof(TankAttack),1,arq);

You are passing a (partly) uninitialized memory block to fwrite.

This is really a bug in valgrind, since it doesn't know about struct padding.

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


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

end of thread, other threads:[~2015-05-05 17:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-05  0:54 [Bug stdio/18375] New: Syscall param write(buf) points to uninitialised byte(s) (valgrind reports) eugeniofonseca14 at gmail dot com
2015-05-05  0:59 ` [Bug stdio/18375] " eugeniofonseca14 at gmail dot com
2015-05-05 17:43 ` schwab@linux-m68k.org

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).