[haiku-commits] haiku: hrev48644 - src/system/kernel

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 10 Jan 2015 01:42:35 +0100 (CET)

hrev48644 adds 1 changeset to branch 'master'
old head: 9550c5ec8efe8d30e9639e4d3b7e9ce405f02309
new head: d05a5a70e0413af2ecea0b8c0b03d7c871973634
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=d05a5a7+%5E9550c5e

----------------------------------------------------------------------------

d05a5a7: kernel: Fix ELF hashtable iterator handling.
  
  As a result of the refactoring for OpenHashTable, the iterator semantics
  have changed a bit, such that the end of the table is no longer signalled
  by the iterator returning NULL. This wasn't taken into account during
  refactoring, which would lead to various places returning the last item
  in the list in the case where no matching item was found, causing e.g.
  drivers not to be loaded properly. This fixes the boot hang regressions
  introduced in hrev48640.

                                      [ Rene Gollent <anevilyak@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev48644
Commit:      d05a5a70e0413af2ecea0b8c0b03d7c871973634
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d05a5a7
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Fri Jan  9 19:29:48 2015 UTC

----------------------------------------------------------------------------

1 file changed, 17 insertions(+), 19 deletions(-)
src/system/kernel/elf.cpp | 36 +++++++++++++++++-------------------

----------------------------------------------------------------------------

diff --git a/src/system/kernel/elf.cpp b/src/system/kernel/elf.cpp
index 97b6ba3..e0bcd78 100644
--- a/src/system/kernel/elf.cpp
+++ b/src/system/kernel/elf.cpp
@@ -165,8 +165,6 @@ register_elf_image(struct elf_image_info *image)
 static struct elf_image_info *
 find_image_at_address(addr_t address)
 {
-       struct elf_image_info *image = NULL;
-
 #if KDEBUG
        if (!debug_debugger_running())
                ASSERT_LOCKED_MUTEX(&sImageMutex);
@@ -177,16 +175,16 @@ find_image_at_address(addr_t address)
        // get image that may contain the address
 
        while (iterator.HasNext()) {
-               image = iterator.Next();
+               struct elf_image_info* image = iterator.Next();
                if ((address >= image->text_region.start && address
                                <= (image->text_region.start + 
image->text_region.size))
                        || (address >= image->data_region.start
                                && address
                                        <= (image->data_region.start + 
image->data_region.size)))
-                       break;
+                       return image;
        }
 
-       return image;
+       return NULL;
 }
 
 
@@ -235,20 +233,16 @@ find_image(image_id id)
 static struct elf_image_info *
 find_image_by_vnode(void *vnode)
 {
-       struct elf_image_info *image = NULL;
+       MutexLocker locker(sImageMutex);
 
-       mutex_lock(&sImageMutex);
        ImageHash::Iterator iterator(sImagesHash);
-
        while (iterator.HasNext()) {
-               image = iterator.Next();
+               struct elf_image_info* image = iterator.Next();
                if (image->vnode == vnode)
-                       break;
+                       return image;
        }
 
-       mutex_unlock(&sImageMutex);
-
-       return image;
+       return NULL;
 }
 
 
@@ -411,11 +405,13 @@ dump_symbols(int argc, char **argv)
 
                                ImageHash::Iterator iterator(sImagesHash);
                                while (iterator.HasNext()) {
-                                       image = iterator.Next();
-                                       if (image->text_region.start <= num
-                                               && image->text_region.start + 
image->text_region.size
-                                                       >= num)
+                                       elf_image_info* current = 
iterator.Next();
+                                       if (current->text_region.start <= num
+                                               && current->text_region.start + 
current->text_region.size
+                                                       >= num) {
+                                               image = current;
                                                break;
+                                       }
                                }
 
                                if (image == NULL) {
@@ -433,9 +429,11 @@ dump_symbols(int argc, char **argv)
                        // look for image by name
                        ImageHash::Iterator iterator(sImagesHash);
                        while (iterator.HasNext()) {
-                               image = iterator.Next();
-                               if (!strcmp(image->name, argv[1]))
+                               elf_image_info* current = iterator.Next();
+                               if (!strcmp(current->name, argv[1])) {
+                                       image = current;
                                        break;
+                               }
                        }
 
                        if (image == NULL)


Other related posts:

  • » [haiku-commits] haiku: hrev48644 - src/system/kernel - anevilyak