Port-amd64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: panic with LOCKDEBUG



On Tuesday 20 May 2008 02:59:00 Geoff Wing wrote:
> On Monday 2008-05-19 17:21 +0200, Christoph_Egger%gmx.de@localhost output:
> :On Monday 19 May 2008 15:32:42 Sverre Froyen wrote:
> :> Try the patch provided by Yamamoto Takashi in
> :> http://mail-index.netbsd.org/current-users/2008/05/13/msg002424.html
> :
> :This patch does not apply cleanly.
> :yamamoto: can you provide new version, please?
>
> Read the bit where it says:
>
>       "xtraeme, simonb, tron - is it ok to revert your recent changes?",
>
> then "update" prop_array.c and prop_dictionary.c to the versions he's
> diff'ing against before applying the patch.
>
> The kernel works fine for me, though I couldn't do a full build which
> had src/sys/arch/i386/stand (*/amd64/stand for you) in it.

I updated yamt's diff to apply cleanly against -current and it works fine for 
me.

Christoph
Index: prop_array.c
===================================================================
RCS file: /cvsroot/src/common/lib/libprop/prop_array.c,v
retrieving revision 1.16
diff -u -p -r1.16 prop_array.c
--- prop_array.c        7 May 2008 10:16:41 -0000       1.16
+++ prop_array.c        20 May 2008 08:58:58 -0000
@@ -62,6 +62,10 @@ static bool  _prop_array_equals(prop_obje
                                   void **, void **,
                                   prop_object_t *, prop_object_t *);
 static void    _prop_array_equals_finish(prop_object_t, prop_object_t);
+static prop_object_iterator_t _prop_array_iterator_locked(prop_array_t);
+static prop_object_t _prop_array_iterator_next_object_locked(void *);
+static void _prop_array_iterator_reset_locked(void *);
+
 
 static const struct _prop_object_type _prop_object_type_array = {
        .pot_type               =       PROP_TYPE_ARRAY,
@@ -160,14 +164,14 @@ _prop_array_externalize(struct _prop_obj
            _prop_object_externalize_append_char(ctx, '\n') == false)
                goto out;
 
-       pi = prop_array_iterator(pa);
+       pi = _prop_array_iterator_locked(pa);
        if (pi == NULL)
                goto out;
        
        ctx->poec_depth++;
        _PROP_ASSERT(ctx->poec_depth != 0);
 
-       while ((po = prop_object_iterator_next(pi)) != NULL) {
+       while ((po = _prop_array_iterator_next_object_locked(pi)) != NULL) {
                if ((*po->po_type->pot_extern)(ctx, po) == false) {
                        prop_object_iterator_release(pi);
                        goto out;
@@ -307,16 +311,13 @@ _prop_array_expand(prop_array_t pa, unsi
 }
 
 static prop_object_t
-_prop_array_iterator_next_object(void *v)
+_prop_array_iterator_next_object_locked(void *v)
 {
        struct _prop_array_iterator *pai = v;
        prop_array_t pa = pai->pai_base.pi_obj;
        prop_object_t po = NULL;
-       bool acquired;
 
        _PROP_ASSERT(prop_object_is_array(pa));
-       acquired = _PROP_RWLOCK_TRYRDLOCK(pa->pa_rwlock);
-       _PROP_RWLOCK_OWNED(pa->pa_rwlock);
 
        if (pa->pa_version != pai->pai_base.pi_version)
                goto out;       /* array changed during iteration */
@@ -330,29 +331,47 @@ _prop_array_iterator_next_object(void *v
        pai->pai_index++;
 
  out:
-       if (acquired) {
-               _PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
-       }
        return (po);
 }
 
-static void
-_prop_array_iterator_reset(void *v)
+static prop_object_t
+_prop_array_iterator_next_object(void *v)
 {
        struct _prop_array_iterator *pai = v;
        prop_array_t pa = pai->pai_base.pi_obj;
-       bool acquired;
-
+       prop_object_t po;
+  
        _PROP_ASSERT(prop_object_is_array(pa));
-       acquired = _PROP_RWLOCK_TRYRDLOCK(pa->pa_rwlock);
-       _PROP_RWLOCK_OWNED(pa->pa_rwlock);
+  
+       _PROP_RWLOCK_RDLOCK(pa->pa_rwlock);
+       po = _prop_array_iterator_next_object_locked(pai);
+       _PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
+       return (po);
+}
 
+static void
+_prop_array_iterator_reset_locked(void *v)
+{
+       struct _prop_array_iterator *pai = v;
+       prop_array_t pa = pai->pai_base.pi_obj;
+  
+       _PROP_ASSERT(prop_object_is_array(pa));
+  
        pai->pai_index = 0;
        pai->pai_base.pi_version = pa->pa_version;
+}
 
-       if (acquired) {
-               _PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
-       }
+static void
+_prop_array_iterator_reset(void *v)
+{
+       struct _prop_array_iterator *pai = v;
+       prop_array_t pa = pai->pai_base.pi_obj;
+
+       _PROP_ASSERT(prop_object_is_array(pa));
+
+       _PROP_RWLOCK_RDLOCK(pa->pa_rwlock);
+       _prop_array_iterator_reset_locked(pai);
+       _PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
 }
 
 /*
@@ -488,13 +507,8 @@ prop_array_ensure_capacity(prop_array_t 
        return (rv);
 }
 
-/*
- * prop_array_iterator --
- *     Return an iterator for the array.  The array is retained by
- *     the iterator.
- */
-prop_object_iterator_t
-prop_array_iterator(prop_array_t pa)
+static prop_object_iterator_t
+_prop_array_iterator_locked(prop_array_t pa)
 {
        struct _prop_array_iterator *pai;
 
@@ -508,14 +522,28 @@ prop_array_iterator(prop_array_t pa)
        pai->pai_base.pi_reset = _prop_array_iterator_reset;
        prop_object_retain(pa);
        pai->pai_base.pi_obj = pa;
-       _PROP_RWLOCK_RDLOCK(pa->pa_rwlock);
-       _prop_array_iterator_reset(pai);
-       _PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
+       _prop_array_iterator_reset_locked(pai);
 
        return (&pai->pai_base);
 }
 
 /*
+ * prop_array_iterator --
+ *     Return an iterator for the array. The array is retained by
+ *     the iterator.
+ */
+prop_object_iterator_t
+prop_array_iterator(prop_array_t pa)
+{
+       prop_object_iterator_t pi;
+
+       _PROP_RWLOCK_RDLOCK(pa->pa_rwlock);
+       pi = _prop_array_iterator_locked(pa);
+       _PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
+       return (pi);
+}
+
+/*
  * prop_array_make_immutable --
  *     Make the array immutable.
  */
Index: prop_dictionary.c
===================================================================
RCS file: /cvsroot/src/common/lib/libprop/prop_dictionary.c,v
retrieving revision 1.28
diff -u -p -r1.28 prop_dictionary.c
--- prop_dictionary.c   7 May 2008 10:16:41 -0000       1.28
+++ prop_dictionary.c   20 May 2008 08:58:58 -0000
@@ -113,6 +113,15 @@ static bool        _prop_dictionary_equals(prop
                                        void **, void **,
                                        prop_object_t *, prop_object_t *);
 static void    _prop_dictionary_equals_finish(prop_object_t, prop_object_t);
+static prop_object_iterator_t _prop_dictionary_iterator_locked(
+                                prop_dictionary_t);
+static prop_object_t _prop_dictionary_iterator_next_object_locked(void *);
+static prop_object_t _prop_dictionary_get_keysym(prop_dictionary_t,
+                                                 prop_dictionary_keysym_t,
+                                                 bool);
+static prop_object_t _prop_dictionary_get(prop_dictionary_t, const char *,
+                                          bool);
+
 
 static const struct _prop_object_type _prop_object_type_dictionary = {
        .pot_type               =       PROP_TYPE_DICTIONARY,
@@ -410,15 +419,15 @@ _prop_dictionary_externalize(struct _pro
            _prop_object_externalize_append_char(ctx, '\n') == false)
                goto out;
 
-       pi = prop_dictionary_iterator(pd);
+       pi = _prop_dictionary_iterator_locked(pd);
        if (pi == NULL)
                goto out;
        
        ctx->poec_depth++;
        _PROP_ASSERT(ctx->poec_depth != 0);
 
-       while ((pdk = prop_object_iterator_next(pi)) != NULL) {
-               po = prop_dictionary_get_keysym(pd, pdk);
+       while ((pdk = _prop_dictionary_iterator_next_object_locked(pi)) != 
NULL) {
+               po = _prop_dictionary_get_keysym(pd, pdk, true);
                if (po == NULL ||
                    _prop_object_externalize_start_tag(ctx, "key") == false ||
                    _prop_object_externalize_append_encoded_cstring(ctx,
@@ -566,16 +575,13 @@ _prop_dictionary_expand(prop_dictionary_
 }
 
 static prop_object_t
-_prop_dictionary_iterator_next_object(void *v)
+_prop_dictionary_iterator_next_object_locked(void *v)
 {
        struct _prop_dictionary_iterator *pdi = v;
        prop_dictionary_t pd = pdi->pdi_base.pi_obj;
        prop_dictionary_keysym_t pdk = NULL;
-       bool acquired;
 
        _PROP_ASSERT(prop_object_is_dictionary(pd));
-       acquired = _PROP_RWLOCK_TRYRDLOCK(pd->pd_rwlock);
-       _PROP_RWLOCK_OWNED(pd->pd_rwlock);
 
        if (pd->pd_version != pdi->pdi_base.pi_version)
                goto out;       /* dictionary changed during iteration */
@@ -589,29 +595,47 @@ _prop_dictionary_iterator_next_object(vo
        pdi->pdi_index++;
 
  out:
-       if (acquired) {
-               _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
-       }
        return (pdk);
 }
 
-static void
-_prop_dictionary_iterator_reset(void *v)
+static prop_object_t
+_prop_dictionary_iterator_next_object(void *v)
 {
        struct _prop_dictionary_iterator *pdi = v;
        prop_dictionary_t pd = pdi->pdi_base.pi_obj;
-       bool acquired;
+       prop_dictionary_keysym_t pdk;
 
        _PROP_ASSERT(prop_object_is_dictionary(pd));
-       acquired = _PROP_RWLOCK_TRYRDLOCK(pd->pd_rwlock);
-       _PROP_RWLOCK_OWNED(pd->pd_rwlock);
+
+       _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
+       pdk = _prop_dictionary_iterator_next_object_locked(pdi);
+       _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
+       return (pdk);
+}
+
+static void
+_prop_dictionary_iterator_reset_locked(void *v)
+{
+       struct _prop_dictionary_iterator *pdi = v;
+       prop_dictionary_t pd = pdi->pdi_base.pi_obj;
+ 
+       _PROP_ASSERT(prop_object_is_dictionary(pd));
 
        pdi->pdi_index = 0;
        pdi->pdi_base.pi_version = pd->pd_version;
+}
 
-       if (acquired) {
-               _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
-       }
+static void
+_prop_dictionary_iterator_reset(void *v)
+{
+       struct _prop_dictionary_iterator *pdi = v;
+       prop_dictionary_t pd = pdi->pdi_base.pi_obj;
+
+       _PROP_ASSERT(prop_object_is_dictionary(pd));
+
+       _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
+       _prop_dictionary_iterator_reset_locked(pdi);
+       _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
 }
 
 /*
@@ -751,13 +775,8 @@ prop_dictionary_ensure_capacity(prop_dic
        return (rv);
 }
 
-/*
- * prop_dictionary_iterator --
- *     Return an iterator for the dictionary.  The dictionary is retained by
- *     the iterator.
- */
-prop_object_iterator_t
-prop_dictionary_iterator(prop_dictionary_t pd)
+static prop_object_iterator_t
+_prop_dictionary_iterator_locked(prop_dictionary_t pd)
 {
        struct _prop_dictionary_iterator *pdi;
 
@@ -771,14 +790,28 @@ prop_dictionary_iterator(prop_dictionary
        pdi->pdi_base.pi_reset = _prop_dictionary_iterator_reset;
        prop_object_retain(pd);
        pdi->pdi_base.pi_obj = pd;
-       _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
-       _prop_dictionary_iterator_reset(pdi);
-       _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
+       _prop_dictionary_iterator_reset_locked(pdi);
 
        return (&pdi->pdi_base);
 }
 
 /*
+ * prop_dictionary_iterator --
+ *     Return an iterator for the dictionary.  The dictionary is retained by
+ *     the iterator.
+ */
+prop_object_iterator_t
+prop_dictionary_iterator(prop_dictionary_t pd)
+{
+       prop_object_iterator_t pi;
+ 
+       _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
+       pi = _prop_dictionary_iterator_locked(pd);
+       _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
+       return (pi);
+}
+
+/*
  * prop_dictionary_all_keys --
  *     Return an array containing a snapshot of all of the keys
  *     in the dictionary.
@@ -848,12 +881,8 @@ _prop_dict_lookup(prop_dictionary_t pd, 
        return (NULL);
 }
 
-/*
- * prop_dictionary_get --
- *     Return the object stored with specified key.
- */
-prop_object_t
-prop_dictionary_get(prop_dictionary_t pd, const char *key)
+static prop_object_t
+_prop_dictionary_get(prop_dictionary_t pd, const char *key, bool locked)
 {
        const struct _prop_dict_entry *pde;
        prop_object_t po = NULL;
@@ -861,29 +890,54 @@ prop_dictionary_get(prop_dictionary_t pd
        if (! prop_object_is_dictionary(pd))
                return (NULL);
 
-       _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
+       if (!locked)
+               _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
        pde = _prop_dict_lookup(pd, key, NULL);
        if (pde != NULL) {
                _PROP_ASSERT(pde->pde_objref != NULL);
                po = pde->pde_objref;
        }
-       _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
+       if (!locked)
+               _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
        return (po);
 }
 
 /*
- * prop_dictionary_get_keysym --
- *     Return the object stored at the location encoded by the keysym.
+ * prop_dictionary_get --
+ *     Return the object stored with specified key.
  */
 prop_object_t
-prop_dictionary_get_keysym(prop_dictionary_t pd, prop_dictionary_keysym_t pdk)
+prop_dictionary_get(prop_dictionary_t pd, const char *key)
 {
+       prop_object_t po;
+ 
+       _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
+       po = _prop_dictionary_get(pd, key, true);
+       _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
+       return (po);
+}
 
+static prop_object_t
+_prop_dictionary_get_keysym(prop_dictionary_t pd, prop_dictionary_keysym_t pdk,
+    bool locked)
+{
+ 
        if (! (prop_object_is_dictionary(pd) &&
               prop_object_is_dictionary_keysym(pdk)))
                return (NULL);
+ 
+       return (_prop_dictionary_get(pd, pdk->pdk_key, locked));
+}
+
+/*
+ * prop_dictionary_get_keysym --
+ *     Return the object stored at the location encoded by the keysym.
+ */
+prop_object_t
+prop_dictionary_get_keysym(prop_dictionary_t pd, prop_dictionary_keysym_t pdk)
+{
 
-       return (prop_dictionary_get(pd, pdk->pdk_key));
+       return (_prop_dictionary_get_keysym(pd, pdk, false));
 }
 
 /*


Home | Main Index | Thread Index | Old Index