This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug stdio/18375] New: Syscall param write(buf) points to uninitialised byte(s) (valgrind reports)
- From: "eugeniofonseca14 at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Tue, 05 May 2015 00:54:19 +0000
- Subject: [Bug stdio/18375] New: Syscall param write(buf) points to uninitialised byte(s) (valgrind reports)
- Auto-submitted: auto-generated
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.