Hello, Brent W. Baccala, on ven. 05 janv. 2018 19:47:37 -0500, wrote: > Well, in that case, perhaps it should work by checking to see if the port is > in > the hash, rather than by looking at how many weak references it's got. > Something more like this: > > if ((refcounts_hard_references(&i->pi.refcounts) == 0) > && (* i->id_hashloc == i)) > { > /* Nobody got a send right in between, we can remove from the hash. */ > hurd_ihash_locp_remove (&idhash, i->id_hashloc); > ports_port_deref_weak (&i->pi); > }
You can't afford dereferencing id_hashloc like that: it could have gotten away in between. Could you try the attached patch instead? > Also, what documentation? The hurd texinfo file? That's the only place that > I > know of where this is documented. Yes: “If nonzero, @var{dropweak_routine} will be called to request weak references to be dropped.” It doesn't say "one weak reference", but "weak references". Samuel
diff --git a/libfshelp/get-identity.c b/libfshelp/get-identity.c index f88e0f82..ac1b4f0b 100644 --- a/libfshelp/get-identity.c +++ b/libfshelp/get-identity.c @@ -70,10 +70,12 @@ id_clean (void *cookie) { struct idspec *i = cookie; pthread_mutex_lock (&idlock); - if (refcounts_hard_references(&i->pi.refcounts) == 0) + if (refcounts_hard_references(&i->pi.refcounts) == 0 + && i->id_hashloc != NULL) { - /* Nobody got a send right in between, we can remove from the hash. */ + /* Nobody got a send right in between, we can remove i from the hash. */ hurd_ihash_locp_remove (&idhash, i->id_hashloc); + i->id_hashloc = NULL; ports_port_deref_weak (&i->pi); } pthread_mutex_unlock (&idlock);