Date: Fri, 25 Mar 2011 18:23:10 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r220004 - head/libexec/rtld-elf Message-ID: <201103251823.p2PINA4j089665@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Fri Mar 25 18:23:10 2011 New Revision: 220004 URL: http://svn.freebsd.org/changeset/base/220004 Log: 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 Modified: head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Fri Mar 25 18:16:49 2011 (r220003) +++ head/libexec/rtld-elf/rtld.c Fri Mar 25 18:23:10 2011 (r220004) @@ -1633,12 +1633,9 @@ load_object(const char *name, const Obj_ 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103251823.p2PINA4j089665>