Linker deadlock.

Pawel Jakub Dawidek pjd at FreeBSD.org
Sun Aug 3 11:35:59 UTC 2008


On Sun, Aug 03, 2008 at 02:09:26PM +0300, Kostik Belousov wrote:
> Source line backtraces would be nicer, since gcc inliner forces me to make
> a guess. It seems that linker_load_module() calls linker_load_file()
> that drops and reaquires the linker lock.
> 
> Then, it seems that dropping the module' vnode lock around the call to
> linker_load_dependencies() should help.

Yes, it doesn't deadlock now, thanks!

> diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
> index 2664ba9..52b3f8f 100644
> --- a/sys/kern/link_elf.c
> +++ b/sys/kern/link_elf.c
> @@ -802,7 +802,9 @@ link_elf_load_file(linker_class_t cls, const char* filename,
>  	goto out;
>      link_elf_reloc_local(lf);
>  
> +    VOP_UNLOCK(nd.ni_vp, 0);
>      error = linker_load_dependencies(lf);
> +    vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY);
>      if (error)
>  	goto out;
>  #if 0	/* this will be more trouble than it's worth for now */
> diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
> index d8e9219..657dd0e 100644
> --- a/sys/kern/link_elf_obj.c
> +++ b/sys/kern/link_elf_obj.c
> @@ -798,7 +798,9 @@ link_elf_load_file(linker_class_t cls, const char *filename,
>  	link_elf_reloc_local(lf);
>  
>  	/* Pull in dependencies */
> +	VOP_UNLOCK(nd.ni_vp);
>  	error = linker_load_dependencies(lf);
> +	vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY);
>  	if (error)
>  		goto out;

-- 
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20080803/def74d03/attachment.pgp


More information about the freebsd-hackers mailing list