Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 149158 Details for
Bug 230793
File descriptors leakage
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Fix + a testcase.
elfutils-0.126-fd-leak.patch (text/plain), 5.86 KB, created by
Jan Kratochvil
on 2007-03-02 21:46:00 UTC
(
hide
)
Description:
Fix + a testcase.
Filename:
MIME Type:
Creator:
Jan Kratochvil
Created:
2007-03-02 21:46:00 UTC
Size:
5.86 KB
patch
obsolete
>diff -ru elfutils-0.126-orig/libdwfl/dwfl_module.c elfutils-0.126/libdwfl/dwfl_module.c >--- elfutils-0.126-orig/libdwfl/dwfl_module.c 2007-01-10 21:49:04.000000000 +0100 >+++ elfutils-0.126/libdwfl/dwfl_module.c 2007-03-02 20:07:58.000000000 +0100 >@@ -49,6 +49,7 @@ > > #include "libdwflP.h" > #include <search.h> >+#include <unistd.h> > > static void > free_cu (struct dwfl_cu *cu) >@@ -91,6 +92,11 @@ > if (mod->main.elf != NULL) > elf_end (mod->main.elf); > >+ if (mod->debug.fd != mod->main.fd && mod->debug.fd != -1) >+ close (mod->debug.fd); >+ if (mod->main.fd != -1) >+ close (mod->main.fd); >+ > free (mod->name); > } > >@@ -139,6 +145,8 @@ > Dwfl_Module *mod = calloc (1, sizeof *mod); > if (mod == NULL) > goto nomem; >+ mod->main.fd = -1; >+ mod->debug.fd = -1; > > mod->name = strdup (name); > if (mod->name == NULL) >diff -ru elfutils-0.126-orig/tests/Makefile.am elfutils-0.126/tests/Makefile.am >--- elfutils-0.126-orig/tests/Makefile.am 2007-02-05 08:25:40.000000000 +0100 >+++ elfutils-0.126/tests/Makefile.am 2007-03-02 20:39:25.000000000 +0100 >@@ -58,7 +58,7 @@ > get-aranges allfcts line2addr addrscopes funcscopes \ > show-abbrev hash newscn ecp dwflmodtest \ > find-prologues funcretval allregs rdwrmmap \ >- dwfl-bug-addr-overflow arls >+ dwfl-bug-addr-overflow arls dwfl-bug-fd-leak > # get-ciefde > asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ > asm-tst6 asm-tst7 asm-tst8 asm-tst9 >@@ -76,7 +76,7 @@ > run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ > run-find-prologues.sh run-allregs.sh run-readelf-test1.sh \ > run-native-test.sh run-bug1-test.sh \ >- dwfl-bug-addr-overflow run-addrname-test.sh >+ dwfl-bug-addr-overflow run-addrname-test.sh dwfl-bug-fd-leak > # run-show-ciefde.sh > > if !STANDALONE >@@ -203,6 +203,7 @@ > rdwrmmap_LDADD = $(libelf) > dwfl_bug_addr_overflow_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl > arls_LDADD = $(libelf) $(libmudflap) >+dwfl_bug_fd_leak_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl > > CLEANFILES = xxx *.gcno *.gcda *gconv > >diff -ru elfutils-0.126-orig/tests/dwfl-bug-fd-leak.c elfutils-0.126/tests/dwfl-bug-fd-leak.c >--- elfutils-0.126-orig/tests/dwfl-bug-fd-leak.c 1970-01-01 01:00:00.000000000 +0100 >+++ elfutils-0.126/tests/dwfl-bug-fd-leak.c 2007-03-02 21:05:39.000000000 +0100 >@@ -0,0 +1,137 @@ >+/* Test program for libdwfl file decriptors leakage. >+ Copyright (C) 2007 Red Hat, Inc. >+ This file is part of Red Hat elfutils. >+ >+ Red Hat elfutils is free software; you can redistribute it and/or modify >+ it under the terms of the GNU General Public License as published by the >+ Free Software Foundation; version 2 of the License. >+ >+ Red Hat elfutils is distributed in the hope that it will be useful, but >+ WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ General Public License for more details. >+ >+ You should have received a copy of the GNU General Public License along >+ with Red Hat elfutils; if not, write to the Free Software Foundation, >+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. >+ >+ Red Hat elfutils is an included package of the Open Invention Network. >+ An included package of the Open Invention Network is a package for which >+ Open Invention Network licensees cross-license their patents. No patent >+ license is granted, either expressly or impliedly, by designation as an >+ included package. Should you wish to participate in the Open Invention >+ Network licensing program, please visit www.openinventionnetwork.com >+ <http://www.openinventionnetwork.com>. */ >+ >+#include <config.h> >+#include <assert.h> >+#include <inttypes.h> >+#include <stdio.h> >+#include <stdio_ext.h> >+#include <locale.h> >+#include <dirent.h> >+#include <stdlib.h> >+#include <errno.h> >+#include <unistd.h> >+#include <dwarf.h> >+#include ELFUTILS_HEADER(dwfl) >+ >+ >+static void >+elfutils_open (pid_t pid, Dwarf_Addr ip, Dwfl **dwfl_return, >+ Dwarf_Die **funcdie_return) >+{ >+ static char *debuginfo_path; >+ static const Dwfl_Callbacks proc_callbacks = >+ { >+ .find_debuginfo = dwfl_standard_find_debuginfo, >+ .debuginfo_path = &debuginfo_path, >+ >+ .find_elf = dwfl_linux_proc_find_elf, >+ }; >+ Dwfl *dwfl = dwfl_begin (&proc_callbacks); >+ assert (dwfl != NULL); >+ *dwfl_return = dwfl; >+ >+ if (dwfl_linux_proc_report (dwfl, pid) != 0) >+ abort (); >+ >+ if (dwfl_report_end (dwfl, NULL, NULL) != 0) >+ abort (); >+ >+ Dwfl_Module *mod = dwfl_addrmodule (dwfl, ip); >+ assert (mod != NULL); >+ >+ Dwarf_Addr bias = 0; >+ Dwarf_Die *cudie = dwfl_module_addrdie (mod, ip, &bias); >+ assert (cudie != NULL); >+ >+ Dwarf_Die *scopes; >+ int nscopes = dwarf_getscopes (cudie, ip - bias, &scopes); >+ assert (nscopes > 0); >+ >+ Dwarf_Die *funcdie = NULL; >+ int i; >+ for (i = 0; i < nscopes; ++i) >+ if (dwarf_tag (&scopes[i]) == DW_TAG_subprogram) >+ { >+ funcdie = &scopes[i]; >+ break; >+ } >+ assert (funcdie != NULL); >+ *funcdie_return = funcdie; >+} >+ >+static void >+elfutils_close (Dwfl *dwfl) >+{ >+ dwfl_end (dwfl); >+} >+ >+/* Function returns even "."/".." entries. >+ We compare only that count did not change. */ >+ >+static int >+fd_count (void) >+{ >+ DIR *dir; >+ int retval = 0; >+ >+ dir = opendir ("/proc/self/fd"); >+ assert (dir != NULL); >+ >+ while (errno = 0, readdir (dir) != 0) >+ retval++; >+ assert (errno == 0); >+ >+ if (closedir (dir) != 0) >+ abort(); >+ >+ return retval; >+} >+ >+int >+main (void) >+{ >+ int fd_counted; >+ >+ fd_counted = fd_count (); >+ >+ /* We use no threads here which can interfere with handling a stream. */ >+ (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER); >+ >+ /* Set locale. */ >+ (void) setlocale (LC_ALL, ""); >+ >+ assert (fd_counted == fd_count ()); >+ >+ Dwfl *dwfl; >+ Dwarf_Die *funcdie; >+ elfutils_open (getpid (), (Dwarf_Addr) main, &dwfl, &funcdie); >+ >+ elfutils_close (dwfl); >+ >+ assert (fd_counted == fd_count ()); >+ >+ return 0; >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 230793
: 149158