rtld: eliminate double call to close(2) that may occur in load_object

The second close(2) call resulted in heisenbugs in some multi-threaded
applications where e.g. dlopen(3) call in one thread could close a file
descriptor for a file having been opened in other thread concurrently.

My litmus test for this issue was an openoffice.org build.

Reviewed by:	jhb
MFC after:	2 weeks
This commit is contained in:
Andriy Gapon 2011-03-25 18:23:10 +00:00
parent af32c4196f
commit 6014c8de1d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=220004

View File

@ -1633,12 +1633,9 @@ load_object(const char *name, const Obj_Entry *refobj, int flags)
free(path);
return NULL;
}
for (obj = obj_list->next; obj != NULL; obj = obj->next) {
if (obj->ino == sb.st_ino && obj->dev == sb.st_dev) {
close(fd);
for (obj = obj_list->next; obj != NULL; obj = obj->next)
if (obj->ino == sb.st_ino && obj->dev == sb.st_dev)
break;
}
}
if (obj != NULL) {
object_add_name(obj, name);
free(path);