emacs-devel
[Top][All Lists]
Advanced

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

Re: Warning starting Emacs (Cygwin)


From: Angelo Graziosi
Subject: Re: Warning starting Emacs (Cygwin)
Date: Sat, 02 Aug 2008 16:29:10 +0200
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

Dan Nicolaescu ha scritto:
Angelo Graziosi <address@hidden> writes:

  > So if you have simple suggestions I will try.

Thanks.

I don't know anything about the code in question, and it looks like it
hasn't been touched in a while...

But please look at src/vm-limit.c:check_memory_limits and see why it
prints that memory full message.  It's not too many lines of code.

This is what I have done.

The first thing has been to verify what code is executed in
'check_memory_limits'.

Using

#ifdef HAVE_GETRLIMIT
  ...
  dataa_size = rlimit.rlim_cur; /* instead of data_size */

#else /* not HAVE_GETRLIMIT */

  ...
  dataaa_size = (char *) cp - (char *) data_space_start;

#endif /* not HAVE_GETRLIMIT */


the compiler fails on:

1) 'dataa_size', when src/config.in has #undef HAVE_GETRLIMIT (in
   current CVS trunk) and Emacs warns starting;

2) 'dataaa_size', when I remove #undef HAVE_GETRLIMIT (previous CVS)
    and Emacs starts normally.

So the warning results when this code is executed:

#ifdef HAVE_GETRLIMIT
  struct rlimit rlimit;

  getrlimit (RLIMIT_AS, &rlimit);

  if (RLIM_INFINITY == rlimit.rlim_max)
    return;

  /* This is a nonsensical case, but it happens -- rms.  */
  if (rlimit.rlim_cur > rlimit.rlim_max)
    return;

  five_percent = rlimit.rlim_max / 20;
  data_size = rlimit.rlim_cur;
#else /* not HAVE_GETRLIMIT */
...
#endif /* not HAVE_GETRLIMIT */

...
if (data_size > five_percent * 19)
    new_warnlevel = warned_95;

with 'data_size > five_percent * 19' (note 5%*19 == 95%).

Since the code is very simple, the only thing I can think is that
'getrlimit' returns wrong values in struct 'rlimit'

The obvious thing to do is to know the values of:

data_size, five_percent, rlimit.rlim_cur, rlimit.rlim_max

so I have tried to add

...
five_percent = rlimit.rlim_max / 20;
data_size = rlimit.rlim_cur;

printf("have getrlimit %lu, %lu %lu %lu\n",
          data_size,five_percent,rlimit.rlim_cur,rlimit.rlim_max);

and rebuild... but 'temacs' stack dumps...; perhaps a known problem
since unicode branch was merged to trunk and solved in 'sheap.c 'with

-#define STATIC_HEAP_SIZE       (12 * 1024 * 1024)
+#define STATIC_HEAP_SIZE       (25 * 1024 * 1024)

In this case I have tried up to (45 * 1024 * 1024) without success.

Then I have tried with GDB:

------------------------------------------
$ gdb build/src/emacs.exe
GNU gdb 6.8.0.20080328-cvs (cygwin-special)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
(gdb) break check_memory_limits
Breakpoint 1 at 0x56db96: file /work/emacs/src/vm-limit.c, line 159.
(gdb) run -Q
Starting program: /work/build/src/emacs.exe -Q
[New thread 556.0xa0c]
[New thread 556.0xcc4]
[New thread 556.0x8d8]
[New thread 556.0xdac]
[New thread 556.0xb80]
[New thread 556.0xe00]
[New thread 556.0x1b4]
<blinking cursor>
------------------------------------------

GDB does not stop on 'check_memory_limits' which is executed with the
warning, and it does not return the prompt '(gdb)'.

At the end I have tried this simple test case, which is 'out context'
(so it could be not meaningful), but it seems to return wrong values:

-----------------------------------------------
$ cat test_printf.c
#include <stdio.h>
#include <sys/resource.h>

int main()
{
   struct rlimit rlimit;

   unsigned long five_percent;
   unsigned long data_size;

   getrlimit (RLIMIT_AS, &rlimit);

   if (RLIM_INFINITY == rlimit.rlim_max)
      return 1;

   /* This is a nonsensical case, but it happens -- rms.  */
   if (rlimit.rlim_cur > rlimit.rlim_max)
      return 2;

   five_percent = rlimit.rlim_max / 20;
   data_size = rlimit.rlim_cur;

   printf("have getrlimit %lu, %lu %lu %lu\n",
          data_size,five_percent,rlimit.rlim_cur,rlimit.rlim_max);

   if (data_size > five_percent * 19)
      printf("past 95 percent of memory limit\n");

   return 0;
}

$ gcc -o test_printf test_printf.c

$ ./test_printf
have getrlimit 2147483648, 107374182 2147483648 2147483648
past 95 percent of memory limit

-----------------------------------------------


Cheers,
   Angelo.

---
... e la terra ritornata alla forma di nebulosa errerĂ  nei cieli priva
di parassiti e di malattie.
.
                         Italo SVEVO, "La coscienza di Zeno"




reply via email to

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