Project

General

Profile

Bug #4251

libdtrace leaks open file handles

Added by Robert Mustacchi about 7 years ago. Updated about 7 years ago.

Status:
Resolved
Priority:
Normal
Category:
DTrace
Start date:
2013-10-20
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

From dt_load_libs_dir:

2091                 if ((fp = fopen(fname, "r")) == NULL) {
2092                         dt_dprintf("skipping library %s: %s\\n",
2093                             fname, strerror(errno));
2094                         continue;
2095                 }
2096 
2097                 /*
2098                  * Skip files whose name match an already processed library
2099                  */
2100                 for (dld = dt_list_next(&dtp->dt_lib_dep); dld != NULL;
2101                     dld = dt_list_next(dld)) {
2102                         end = strrchr(dld->dtld_library, '/');
2103                         /* dt_lib_depend_add ensures this */
2104                         assert(end != NULL);
2105                         if (strcmp(end + 1, dp->d_name) == 0)
2106                                 break;
2107                 }
2108 
2109                 if (dld != NULL) {
2110                         dt_dprintf("skipping library %s, already processed " 
2111                             "library with the same name: %s", dp->d_name,
2112                             dld->dtld_library);
2113                         continue;
2114                 }
2115 
2116                 dtp->dt_filetag = fname;
2117                 if (dt_lib_depend_add(dtp, &dtp->dt_lib_dep, fname) != 0)
2118                         return (-1); /* preserve dt_errno */
2119 
2120                 rv = dt_compile(dtp, DT_CTX_DPROG,
2121                     DTRACE_PROBESPEC_NAME, NULL,
2122                     DTRACE_C_EMPTY | DTRACE_C_CTL, 0, NULL, fp, NULL);
2123 
2124                 if (rv != NULL && dtp->dt_errno &&
2125                     (dtp->dt_errno != EDT_COMPILER ||
2126                     dtp->dt_errtag != dt_errtag(D_PRAGMA_DEPEND)))
2127                         return (-1); /* preserve dt_errno */

When we "continue" on line 2113, we're definitely leaking "fp", which is not just memory but one of what might be a limited number of open file handles. We're probably also leaking it on lines 2118 and 2127.

#1

Updated by Robert Mustacchi about 7 years ago

  • Status changed from New to Resolved
  • % Done changed from 90 to 100

Resolved in 93ed8d0d4b068b95d0bb50d57bb854df462a8485.

Also available in: Atom PDF