guile-devel
[Top][All Lists]
Advanced

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

Re: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-213-gb43e8


From: Mark H Weaver
Subject: Re: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-213-gb43e81d
Date: Fri, 04 Oct 2013 00:20:46 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hi Andy,

"Andy Wingo" <address@hidden> writes:

> diff --git a/libguile/programs.c b/libguile/programs.c
> index 37130d0..5039d2a 100644
> --- a/libguile/programs.c
> +++ b/libguile/programs.c
> @@ -297,7 +297,7 @@ SCM_DEFINE (scm_program_bindings, "program-bindings", 1, 
> 0, 0,
>  }
>  #undef FUNC_NAME
>  
> -SCM_DEFINE (scm_program_sources, "program-sources", 1, 0, 0,
> +SCM_DEFINE (scm_program_sources, "%program-sources", 1, 0, 0,
>           (SCM program),
>           "")
>  #define FUNC_NAME s_scm_program_sources
> @@ -365,32 +365,24 @@ scm_i_program_properties (SCM program)
>  }
>  #undef FUNC_NAME
>  
> -static SCM
> -program_source (SCM program, size_t ip, SCM sources)
> +SCM
> +scm_program_source (SCM program, SCM ip, SCM sources)
>  {
> -  SCM source = SCM_BOOL_F;
> +  static SCM program_source = SCM_BOOL_F;
>  
> -  while (!scm_is_null (sources)
> -         && scm_to_size_t (scm_caar (sources)) <= ip)
> -    {
> -      source = scm_car (sources);
> -      sources = scm_cdr (sources);
> -    }
> -  
> -  return source; /* (addr . (filename . (line . column))) */
> -}
> +  if (scm_is_false (program_source)) {
> +    if (!scm_module_system_booted_p)
> +      return SCM_BOOL_F;
> +
> +    program_source =
> +      scm_c_private_variable ("system vm program", "program-source");
> +  }

This lazy initialization pattern is not safe on modern weakly ordered
memory architectures.  I've already raised this issue on the mailing
list more than once, and I've been trying to fix these bugs wherever I
can find them, but they are non-trivial to search for.  Please do not
add more.

We need to either use a mutex to guard both reads and writes of
'program_source' (including the "scm_is_false (program_source)" check),
or we need to arrange for 'program_source' to be initialized during
guile's initialization before any other threads are created.

     Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]