gcl-devel
[Top][All Lists]
Advanced

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

Re: posix_spawn


From: Camm Maguire
Subject: Re: posix_spawn
Date: Sun, 24 Dec 2023 09:31:20 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Greetings!

"Kirill A. Korinsky" <kirill@korins.ky> writes:

> A file fix-memory-corruption-on-macOS.patch contains two patches. I just 
> removed the second one (vsystem -> system) in favour of posix_spawn and 
> applied it on 33a195d5cec2a7f8f563e11c0f1a3011ea0b30a0 which allows me to 
> build GCL on macOS 12. It requires
> something like 3 hours I guess, but I did it from clean system.
>
> Summary: posix_spawn works but it requires one more patch:
>

Great!

> --- o/main.c
> +++ o/main.c
> @@ -432,7 +432,11 @@ gcl_cleanup(int gc) {
>    if (gc) {
>  
>      saving_system=TRUE;
> +
> +/* on macOS it leads to ERROR "Caught fatal error [memory may be damaged]" */
> +#ifndef __APPLE__
>      GBC(t_other);
> +#endif
>      saving_system=FALSE;
>      
>      minimize_image();
>
> If I recall right I made this patch as result of git bisect that points that 
> this issue was introduced by cb842e61fd2d0ff5baf51918112003a3a1b69b45 when 
> this line was introduced.
>

  OK we need to get to the bottom of this too.  It seems the problem
  area is:      

  if (saving_system) {

    struct pageinfo *v;
    void *x;
    struct typemanager *tm=tm_of(t_stream);
    unsigned j;

    for (v=cell_list_head;v;v=v->next) 
      if (tm->tm_type==v->type)
        for (x=pagetochar(page(v)),j=tm->tm_nppage;j--;x+=tm->tm_size) {
          object o=x;
          if (type_of(o)==t_stream && !is_free(o) && o->sm.sm_fp && 
o->sm.sm_fp!=stdin && o->sm.sm_fp!=stdout && o->sm.sm_fp!=stderr)
            close_stream(o);
        }

    gc_time = -1;
    }

  Problem should also go away if you remove the saving_system=TRUE
  line.  I suspect mac is naming stdin,stdout,stderr in an unusual way
  and gcl is trying to close one of these.


> From my point of view posix_spawn is the right move and it really fixes 
> things. If you think to commit it, please do!

Its looking good so far for me too.  Need to check the oom behavior.

By the way, regarding your previous comments on large memory
consumption.  Please export GCL_MEM_MULTIPLE=0.1 or similar to limit gcl
to 1/10 of system memory.  There are also ways to do this at the lisp
level.

Take care,
-- 
Camm Maguire                                        camm@maguirefamily.org
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

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