|
From: | Андрей Аладьев |
Subject: | Re: [Tinycc-devel] tinycc segfault with gnu getline for unknown reason |
Date: | Mon, 28 Jan 2013 20:20:08 +0300 |
test.c#define _GNU_SOURCE#include <stdio.h>#include <stdlib.h>void read_file ( FILE * file ) {size_t len = 0;char * line = NULL;ssize_t bytes_read;while ( ( bytes_read = getline ( &line, &len, file ) ) != -1 ) {printf ( "%s", line );}free ( line );}int main ( void ) {FILE * file;file = fopen ( "/etc/fstab", "r" );read_file ( file );fclose ( file );return 0;}tcc -run test.c# /etc/fstab: static file system information.Segmentation faultThen swap lines from:
size_t len = 0;char * line = NULL;to:char * line = NULL;size_t len = 0;tcc -run test.c# /etc/fstab: static file system information.
## noatime turns off ...So this swap fixed the problem. It is real magick
[Prev in Thread] | Current Thread | [Next in Thread] |