Bug 6284

Summary: fclose(NULL) causes segmentation error
Product: [Retired] Red Hat Linux Reporter: Andrew Wiseman <a.wiseman>
Component: libcAssignee: Cristian Gafton <gafton>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 5.2   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-01-06 21:07:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Andrew Wiseman 1999-10-23 10:49:56 UTC
When I compile and run the example program shown below,
under RedHat Linux 5.2 (Kernel 2.0.36) with gcc
(v2.7.2.3), I get a segmentation error. The same code has
been run on many other Unix systems and even other versions
of Linux without failure. Granted fclose(NULL) is not a
useful thing to do, but nevertheless it should not cause a
segmentation error.

main()
{
     long *file_rep = 0x0;
     fclose(file_rep);
}

Comment 1 Cristian Gafton 2000-01-06 21:07:59 UTC
This is a programming error. POSIX says that the behavior is unspecified. And
glibc segfaults to signal a major error in a program, and it is also withing
POSIX's specification.