From: Constantine Vetoshev <vetoshev@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 32338@debbugs.gnu.org, Alan Third <alan@idiocy.org>,
Noam Postavsky <npostavs@gmail.com>
Subject: bug#32338: 26.1; term.el broken on macOS
Date: Tue, 2 Oct 2018 15:51:11 -0700 [thread overview]
Message-ID: <CA+CaSqqRR62QNqpKN-ssHXPoD3cd_tV0+iOfrc5VWYcG3_rP9w@mail.gmail.com> (raw)
In-Reply-To: <83k1n252ns.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 3912 bytes --]
On Sun, Sep 30, 2018 at 10:14 AM Eli Zaretskii <eliz@gnu.org> wrote:
> Then please step with a debugger through the code starting from the
> call to getrlimit, and please show the values of related variables,
> such as newlim, all the way until the call to setrlimit and the
> computed value of emacs_re_safe_alloca. Please do that once with the
> current code and then once again with the code before the offending
> commit. I'd like to see the differences, because I meanwhile see
> nothing wrong with using rlim_t here.
One change from my past reports: after compiling Emacs with -g flags,
I have now managed to reproduce the crash under lldb, including
attaching to the forked process which eats CPU after the crash.
Backtrace from that process is attached.
Here are my results from stepping through the code. Note this all runs
at Emacs startup, long before anything forks.
The highlights (as far as I noticed) are:
- emacs_re_max_failures and the older re_max_failures are not
initialized at this point
- in the working branch, newlim is reset to rlim.rlim_max; in the
broken branch, it is not
- in the working branch, setrlimit does not get called; in the broken
branch, it does
I'm guessing the problem is with the uninitialized values for
*_re_max_failures and the resulting values being assigned to lim and
newlim. It seems to only work on the working branch by accident
because, for whatever reason, newlim always gets reset to
rlim.rlim_max and setrlimit doesn't get called.
-----
master branch (commit 3eedabaef37e), use of rlim_t:
- immediately after getrlimit call, lim is assigned, value: 0
- lim is then assigned rlim.rlim_cur, value: 67104768
- min_ratio is initialized, value: 160
- ratio is initialized, value: 213
- try_to_grow_stack ends up assigned, value: true
The code proceeds into the try_to_grow_stack condition:
- newlim is assigned, value: 10020000
- BUT: emacs_re_max_failures defined at that point and used to
calculate newlim has a very large size_t value: 6500256977556508423
- looks like newlim has overflown here to fit unsigned long long
- pagesize is assigned, value 4096
- newlim is decremented, value: 10024095
- condition checking if rlim.rlim_max < newlim; rlim.rlim_max is
67104768 so the condition evaluates to false (emacs.c:880)
- condition checking if pagesize <= (newlim - lim) evaluates to true:
this happens because (newlim < rlim), and the subtraction causes an
overflow (newlim - lim returns an unsigned long long with value
18446744073652469760); consequently, setrlimit is called and succeeds
The try_to_grow_stack condition ends.
- emacs_re_safe_alloca is assigned, value: 4435280473597425792. I'm
not sure if that's a reasonable value for a value of type ptrdiff_t.
-----
-----
last working revision (commit 6cdd1c333034b), use of long:
Please note that this code predates the introduction of emacs_re_safe_alloca.
- immediately after getrlimit call, lim is assigned, value: 0
- lim then is assigned rlim.rlim_curr, value: 67104768
- ratio is then initialized: 160
- and subsequently incremented, value: 213
- try_to_grow_stack ends up assigned, value: true
The code proceeds into the try_to_grow_stack condition:
- newlim is assigned, value: 67104578
- BUT: re_max_failures defined at that point and used to calculate
newlim has a very large size_t value: 16107485546189635934
- newlim has obviously overflown here to fit a signed long
- pagesize is assigned, value 4096
- newlim is decremented, value: 67108673
- condition checking if rlim.rlim_max < newlim; rlim.rlim_max is
67104768 so the condition evaluates to true and newlim is set to
rlim.rlim_max (emacs.c:862)
- newlim decrement by newlim % pagesize is a noop
- condition checking if pagesize <= (newlim - lim) evaluates to false,
skipping the setrlimit call
-----
I am attaching lldb session transcripts for both runs in case you want
to look more closely at what's going on.
[-- Attachment #2: fork-process-crash-backtrace.txt --]
[-- Type: text/plain, Size: 5862 bytes --]
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
* frame #0: 0x00007fff709835e2 libsystem_platform.dylib`_os_unfair_lock_recursive_abort + 23
frame #1: 0x00007fff70983710 libsystem_platform.dylib`_os_unfair_lock_lock_slow + 226
frame #2: 0x00007fff7081b2ee libsystem_malloc.dylib`szone_malloc_should_clear + 213
frame #3: 0x00007fff7081b1bd libsystem_malloc.dylib`malloc_zone_malloc + 103
frame #4: 0x00007fff487db6f4 CoreFoundation`CFBasicHashCreateCopy + 116
frame #5: 0x00007fff487e3936 CoreFoundation`CFDictionaryCreateCopy + 134
frame #6: 0x00007fff48982a28 CoreFoundation`__40-[_CFXPreferences synchronizeEverything]_block_invoke + 24
frame #7: 0x00007fff4891b4cf CoreFoundation`-[_CFXPreferences(SourceAdditions) withSources:] + 79
frame #8: 0x00007fff489829b3 CoreFoundation`-[_CFXPreferences synchronizeEverything] + 115
frame #9: 0x00007fff4884cef9 CoreFoundation`_CFPrefsSynchronizeForProcessTermination + 73
frame #10: 0x00007fff4a91df65 Foundation`-[NSUserDefaults(NSUserDefaults) synchronize] + 51
frame #11: 0x0000000100335e72 Emacs`ns_term_shutdown(sig=4) at nsterm.m:5487
frame #12: 0x000000010014edf4 Emacs`shut_down_emacs(sig=4, stuff=0x0000000000000000) at emacs.c:2136
frame #13: 0x000000010014ea7f Emacs`terminate_due_to_signal(sig=4, backtrace_limit=40) at emacs.c:383
frame #14: 0x0000000100182288 Emacs`handle_fatal_signal(sig=4) at sysdep.c:1769
frame #15: 0x0000000100182322 Emacs`deliver_thread_signal(sig=4, handler=(Emacs`handle_fatal_signal at sysdep.c:1768)) at sysdep.c:1743
frame #16: 0x00000001001800ea Emacs`deliver_fatal_thread_signal(sig=4) at sysdep.c:1781
frame #17: 0x00007fff70980f5a libsystem_platform.dylib`_sigtramp + 26
frame #18: 0x00007fff709835e3 libsystem_platform.dylib`_os_unfair_lock_recursive_abort + 24
frame #19: 0x00007fff70983710 libsystem_platform.dylib`_os_unfair_lock_lock_slow + 226
frame #20: 0x00007fff7081b7f2 libsystem_malloc.dylib`szone_malloc_should_clear + 1497
frame #21: 0x00007fff7081b1bd libsystem_malloc.dylib`malloc_zone_malloc + 103
frame #22: 0x00007fff7081a4c7 libsystem_malloc.dylib`malloc + 24
frame #23: 0x00000001002b4fc2 Emacs`unexec_malloc(size=1024) at unexmacosx.c:1331
frame #24: 0x00000001001f2555 Emacs`lmalloc(size=1024) at alloc.c:1461
frame #25: 0x00000001001f24e5 Emacs`xmalloc(size=1024) at alloc.c:872
frame #26: 0x00000001001e5064 Emacs`regex_compile(pattern="\\$\\(?:\\(?1:[[:alnum:]_]+\\)\\|{\\(?1:[^{}]+\\)}\\|\\$\\)", size=49, posix_backtracking=false, whitespace_regexp=0x0000000000000000, bufp=0x00000001007e05d8) at regex-emacs.c:1766
frame #27: 0x00000001001e4f98 Emacs`rpl_re_compile_pattern(pattern="\\$\\(?:\\(?1:[[:alnum:]_]+\\)\\|{\\(?1:[^{}]+\\)}\\|\\$\\)", length=49, posix_backtracking=false, whitespace_regexp=0x0000000000000000, bufp=0x00000001007e05d8) at regex-emacs.c:5091
frame #28: 0x00000001001d5c4c Emacs`compile_pattern_1(cp=0x00000001007e05b8, pattern=0x0000000100416f94, translate=0x000000010688786d, posix=false) at search.c:147
frame #29: 0x00000001001cef70 Emacs`compile_pattern(pattern=0x0000000100416f94, regp=0x00000001007fa478, translate=0x000000010688786d, posix=false, multibyte=false) at search.c:258
frame #30: 0x00000001001ce9c0 Emacs`string_match_1(regexp=0x0000000100416f94, string=0x000000010045b414, start=0x0000000000000002, posix=false) at search.c:419
frame #31: 0x00000001001ce747 Emacs`Fstring_match(regexp=0x0000000100416f94, string=0x000000010045b414, start=0x0000000000000002) at search.c:466
frame #32: 0x0000000100248ca8 Emacs`funcall_subr(subr=0x00000001003e00b8, numargs=3, args=0x00007ffeefbf8ad8) at eval.c:2936
frame #33: 0x00000001002479fe Emacs`Ffuncall(nargs=4, args=0x00007ffeefbf8ad0) at eval.c:2856
frame #34: 0x00000001002b997e Emacs`exec_byte_code(bytestr=0x0000000100416fe4, vector=0x0000000100417005, maxdepth=0x000000000000002a, args_template=0x0000000000000806, nargs=2, args=0x00007ffeefbf9208) at bytecode.c:632
frame #35: 0x00000001002490dc Emacs`funcall_lambda(fun=0x0000000100416fb5, nargs=2, arg_vector=0x00007ffeefbf91f8) at eval.c:3057
frame #36: 0x0000000100247a46 Emacs`Ffuncall(nargs=3, args=0x00007ffeefbf91f0) at eval.c:2858
frame #37: 0x00000001002b997e Emacs`exec_byte_code(bytestr=0x00000001004170b4, vector=0x00000001004170d5, maxdepth=0x0000000000000016, args_template=0x0000000000000406, nargs=1, args=0x00007ffeefbf98b8) at bytecode.c:632
frame #38: 0x00000001002490dc Emacs`funcall_lambda(fun=0x0000000100417085, nargs=1, arg_vector=0x00007ffeefbf98b0) at eval.c:3057
frame #39: 0x0000000100247a46 Emacs`Ffuncall(nargs=2, args=0x00007ffeefbf98a8) at eval.c:2858
frame #40: 0x0000000100248554 Emacs`call1(fn=0x000000000000b220, arg1=0x000000010045b414) at eval.c:2707
frame #41: 0x00000001001af51c Emacs`Fsubstitute_in_file_name(filename=0x000000010045b414) at fileio.c:1763
frame #42: 0x000000010028b3e4 Emacs`Fload(file=0x000000010045b414, noerror=0x0000000000000000, nomessage=0x000000000000b460, nosuffix=0x0000000000000000, must_suffix=0x000000000000b460) at lread.c:1175
frame #43: 0x000000010023fca6 Emacs`Fautoload_do_load(fundef=0x000000010045b3f3, funname=0x0000000000003ea0, macro_only=0x0000000000000000) at eval.c:2109
frame #44: 0x0000000100247b90 Emacs`Ffuncall(nargs=3, args=0x00007ffeefbf9fd0) at eval.c:2873
frame #45: 0x00000001002477ca Emacs`Fapply(nargs=2, args=0x00007ffeefbfa0d8) at eval.c:2476
frame #46: 0x0000000100239305 Emacs`apply1(fn=0x0000000000003ea0, arg=0x00000001038c9d53) at eval.c:2692
frame #47: 0x0000000100238cdf Emacs`call_debugger(arg=0x00000001038c9d53) at eval.c:358
frame #48: 0x0000000100247c1a Emacs`Ffuncall(nargs=8, args=0x00007ffeefbfa470) at eval.c:2883
[-- Attachment #3: lldb-session-working.txt --]
[-- Type: text/plain, Size: 9852 bytes --]
(lldb) target create "nextstep/Emacs.app/Contents/MacOS/Emacs"
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/opt/brew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/opt/brew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Current executable set to 'nextstep/Emacs.app/Contents/MacOS/Emacs' (x86_64).
(lldb) b emacs.c:832
Breakpoint 1: where = Emacs`main + 1463 at emacs.c:832, address = 0x0000000100133ef7
(lldb) run -Q
Process 96113 launched: '/Users/kostya/Downloads/emacs-working.git/nextstep/Emacs.app/Contents/MacOS/Emacs' (x86_64)
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100133ef7 Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:832
829 if (getrlimit (RLIMIT_STACK, &rlim) == 0
830 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= LONG_MAX)
831 {
-> 832 long lim = rlim.rlim_cur;
833
834 /* Approximate the amount regex.c needs per unit of
835 re_max_failures, then add 33% to cover the size of the
Target 0: (Emacs) stopped.
(lldb) e lim
(long) $0 = 0
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133f05 Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:838
835 re_max_failures, then add 33% to cover the size of the
836 smaller stacks that regex.c successively allocates and
837 discards on its way to the maximum. */
-> 838 int ratio = 20 * sizeof (char *);
839 ratio += ratio / 3;
840
841 /* Extra space to cover what we're likely to use for other reasons. */
Target 0: (Emacs) stopped.
(lldb) e lim
(long) $1 = 67104768
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133f0f Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:839
836 smaller stacks that regex.c successively allocates and
837 discards on its way to the maximum. */
838 int ratio = 20 * sizeof (char *);
-> 839 ratio += ratio / 3;
840
841 /* Extra space to cover what we're likely to use for other reasons. */
842 int extra = 200000;
Target 0: (Emacs) stopped.
(lldb) e ratio
(int) $2 = 160
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133f38 Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:842
839 ratio += ratio / 3;
840
841 /* Extra space to cover what we're likely to use for other reasons. */
-> 842 int extra = 200000;
843
844 bool try_to_grow_stack = true;
845 #ifndef CANNOT_DUMP
Target 0: (Emacs) stopped.
(lldb) e ratio
(int) $3 = 213
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133f42 Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:844
841 /* Extra space to cover what we're likely to use for other reasons. */
842 int extra = 200000;
843
-> 844 bool try_to_grow_stack = true;
845 #ifndef CANNOT_DUMP
846 try_to_grow_stack = !noninteractive || initialized;
847 #endif
Target 0: (Emacs) stopped.
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133f49 Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:846
843
844 bool try_to_grow_stack = true;
845 #ifndef CANNOT_DUMP
-> 846 try_to_grow_stack = !noninteractive || initialized;
847 #endif
848
849 if (try_to_grow_stack)
Target 0: (Emacs) stopped.
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133f7d Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:849
846 try_to_grow_stack = !noninteractive || initialized;
847 #endif
848
-> 849 if (try_to_grow_stack)
850 {
851 long newlim = re_max_failures * ratio + extra;
852
Target 0: (Emacs) stopped.
(lldb) e try_to_grow_stack
(bool) $4 = true
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133f91 Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:851
848
849 if (try_to_grow_stack)
850 {
-> 851 long newlim = re_max_failures * ratio + extra;
852
853 /* Round the new limit to a page boundary; this is needed
854 for Darwin kernel 15.4.0 (see Bug#23622) and perhaps
Target 0: (Emacs) stopped.
(lldb) e newlim
(long) $5 = 0
(lldb) e re_max_failures
(size_t) $6 = 16107485546189635934
(lldb) e extra
(int) $7 = 200000
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133fb0 Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:860
857 RLIM_INFINITY etc. since in practice when they are
858 nonnegative they are so large that the code does the
859 right thing anyway. */
-> 860 long pagesize = getpagesize ();
861 newlim += pagesize - 1;
862 if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
863 newlim = rlim.rlim_max;
Target 0: (Emacs) stopped.
(lldb) e newlim
(long) $8 = 67104578
(lldb) e re_max_failures
(size_t) $9 = 16107485546189635934
(lldb) e ratio
(int) $10 = 213
(lldb) e re_max_failures * ratio
(unsigned long) $11 = 18246767702125404982
(lldb) e re_max_failures * ratio + extra
(unsigned long) $12 = 18246767702125604982
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133fc3 Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:861
858 nonnegative they are so large that the code does the
859 right thing anyway. */
860 long pagesize = getpagesize ();
-> 861 newlim += pagesize - 1;
862 if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
863 newlim = rlim.rlim_max;
864 newlim -= newlim % pagesize;
Target 0: (Emacs) stopped.
(lldb) e pagesize
(long) $13 = 4096
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133fdc Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:862
859 right thing anyway. */
860 long pagesize = getpagesize ();
861 newlim += pagesize - 1;
-> 862 if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
863 newlim = rlim.rlim_max;
864 newlim -= newlim % pagesize;
865
Target 0: (Emacs) stopped.
(lldb) e newlim
(long) $14 = 67108673
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100133ffd Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:863
860 long pagesize = getpagesize ();
861 newlim += pagesize - 1;
862 if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
-> 863 newlim = rlim.rlim_max;
864 newlim -= newlim % pagesize;
865
866 if (pagesize <= newlim - lim)
Target 0: (Emacs) stopped.
(lldb) e rlim.rlim_max
(rlim_t) $15 = 67104768
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010013400b Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:864
861 newlim += pagesize - 1;
862 if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
863 newlim = rlim.rlim_max;
-> 864 newlim -= newlim % pagesize;
865
866 if (pagesize <= newlim - lim)
867 {
Target 0: (Emacs) stopped.
(lldb) e newlim
(long) $16 = 67104768
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010013402c Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:866
863 newlim = rlim.rlim_max;
864 newlim -= newlim % pagesize;
865
-> 866 if (pagesize <= newlim - lim)
867 {
868 rlim.rlim_cur = newlim;
869 if (setrlimit (RLIMIT_STACK, &rlim) == 0)
Target 0: (Emacs) stopped.
(lldb) e newlim
(long) $17 = 67104768
(lldb) e newlim % pagesize
(long) $18 = 0
(lldb) e pagesize
(long) $19 = 4096
(lldb) e newlim - lim
(long) $20 = 0
(lldb) n
Process 96113 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000100134085 Emacs`main(argc=2, argv=0x00007ffeefbff520) at emacs.c:872
869 if (setrlimit (RLIMIT_STACK, &rlim) == 0)
870 lim = newlim;
871 }
-> 872 }
873
874 /* Don't let regex.c overflow the stack. */
875 re_max_failures = lim < extra ? 0 : min (lim - extra, SIZE_MAX) / ratio;
Target 0: (Emacs) stopped.
(lldb) c
Process 96113 resuming
2018-10-02 14:11:54.227006-0700 Emacs[96113:1856908] MessageTracer: Falling back to default whitelist
2018-10-02 14:11:54.331905-0700 Emacs[96113:1900949] flock failed to lock maps file: errno = 35
2018-10-02 14:11:54.332259-0700 Emacs[96113:1900949] flock failed to lock maps file: errno = 35
Process 96113 exited with status = 0 (0x00000000)
[-- Attachment #4: lldb-session-broken.txt --]
[-- Type: text/plain, Size: 12747 bytes --]
(lldb) target create "nextstep/Emacs.app/Contents/MacOS/Emacs"
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/opt/brew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/opt/brew/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Current executable set to 'nextstep/Emacs.app/Contents/MacOS/Emacs' (x86_64).
(lldb) b emacs.c:848
Breakpoint 1: where = Emacs`main + 1489 at emacs.c:848, address = 0x000000010014f431
(lldb) run -Q
Process 97130 launched: '/Users/kostya/Downloads/emacs-master.git/nextstep/Emacs.app/Contents/MacOS/Emacs' (x86_64)
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x000000010014f431 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:848
845 if (getrlimit (RLIMIT_STACK, &rlim) == 0
846 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= LONG_MAX)
847 {
-> 848 rlim_t lim = rlim.rlim_cur;
849
850 /* Approximate the amount regex-emacs.c needs per unit of
851 emacs_re_max_failures, then add 33% to cover the size of the
Target 0: (Emacs) stopped.
(lldb) e lim
(rlim_t) $0 = 0
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f43f Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:854
851 emacs_re_max_failures, then add 33% to cover the size of the
852 smaller stacks that regex-emacs.c successively allocates and
853 discards on its way to the maximum. */
-> 854 int min_ratio = 20 * sizeof (char *);
855 int ratio = min_ratio + min_ratio / 3;
856
857 /* Extra space to cover what we're likely to use for other
Target 0: (Emacs) stopped.
(lldb) e lim
(rlim_t) $1 = 67104768
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f449 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:855
852 smaller stacks that regex-emacs.c successively allocates and
853 discards on its way to the maximum. */
854 int min_ratio = 20 * sizeof (char *);
-> 855 int ratio = min_ratio + min_ratio / 3;
856
857 /* Extra space to cover what we're likely to use for other
858 reasons. For example, a typical GC might take 30K stack
Target 0: (Emacs) stopped.
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f478 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:860
857 /* Extra space to cover what we're likely to use for other
858 reasons. For example, a typical GC might take 30K stack
859 frames. */
-> 860 int extra = (30 * 1000) * 50;
861
862 bool try_to_grow_stack = true;
863 #ifndef CANNOT_DUMP
Target 0: (Emacs) stopped.
(lldb) e min_ratio
(int) $2 = 160
(lldb) e ratio
(int) $3 = 213
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f482 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:862
859 frames. */
860 int extra = (30 * 1000) * 50;
861
-> 862 bool try_to_grow_stack = true;
863 #ifndef CANNOT_DUMP
864 try_to_grow_stack = !noninteractive || initialized;
865 #endif
Target 0: (Emacs) stopped.
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f489 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:864
861
862 bool try_to_grow_stack = true;
863 #ifndef CANNOT_DUMP
-> 864 try_to_grow_stack = !noninteractive || initialized;
865 #endif
866
867 if (try_to_grow_stack)
Target 0: (Emacs) stopped.
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f4bd Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:867
864 try_to_grow_stack = !noninteractive || initialized;
865 #endif
866
-> 867 if (try_to_grow_stack)
868 {
869 rlim_t newlim = emacs_re_max_failures * ratio + extra;
870
Target 0: (Emacs) stopped.
(lldb) e try_to_grow_stack
(bool) $4 = true
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f4d1 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:869
866
867 if (try_to_grow_stack)
868 {
-> 869 rlim_t newlim = emacs_re_max_failures * ratio + extra;
870
871 /* Round the new limit to a page boundary; this is needed
872 for Darwin kernel 15.4.0 (see Bug#23622) and perhaps
Target 0: (Emacs) stopped.
(lldb) e emacs_re_max_failures
(size_t) $5 = 6500256977556508423
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f4f0 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:878
875 RLIM_INFINITY etc. since in practice when they are
876 nonnegative they are so large that the code does the
877 right thing anyway. */
-> 878 long pagesize = getpagesize ();
879 newlim += pagesize - 1;
880 if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
881 newlim = rlim.rlim_max;
Target 0: (Emacs) stopped.
(lldb) e newlim
(rlim_t) $6 = 10020000
(lldb) e emacs_re_max_failures
(size_t) $7 = 6500256977556508423
(lldb) e ratio
(int) $8 = 213
(lldb) e emacs_re_max_failures * ratio
(unsigned long) $9 = 1048930691319922899
(lldb) e emacs_re_max_failures * ratio + extra
(unsigned long) $10 = 1048930691321422899
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f503 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:879
876 nonnegative they are so large that the code does the
877 right thing anyway. */
878 long pagesize = getpagesize ();
-> 879 newlim += pagesize - 1;
880 if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
881 newlim = rlim.rlim_max;
882 newlim -= newlim % pagesize;
Target 0: (Emacs) stopped.
(lldb) e pagesize
(long) $11 = 4096
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f51c Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:880
877 right thing anyway. */
878 long pagesize = getpagesize ();
879 newlim += pagesize - 1;
-> 880 if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
881 newlim = rlim.rlim_max;
882 newlim -= newlim % pagesize;
883
Target 0: (Emacs) stopped.
(lldb) e newlim
(rlim_t) $12 = 10024095
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f54b Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:882
879 newlim += pagesize - 1;
880 if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
881 newlim = rlim.rlim_max;
-> 882 newlim -= newlim % pagesize;
883
884 if (pagesize <= newlim - lim)
885 {
Target 0: (Emacs) stopped.
(lldb) e rlim.rlim_max
(rlim_t) $13 = 67104768
(lldb) e newlim
(rlim_t) $14 = 10024095
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f56e Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:884
881 newlim = rlim.rlim_max;
882 newlim -= newlim % pagesize;
883
-> 884 if (pagesize <= newlim - lim)
885 {
886 rlim.rlim_cur = newlim;
887 if (setrlimit (RLIMIT_STACK, &rlim) == 0)
Target 0: (Emacs) stopped.
(lldb) e newlim
(rlim_t) $15 = 10022912
(lldb) e newlim - lim
(unsigned long long) $16 = 18446744073652469760
(lldb) e lim
(rlim_t) $17 = 67104768
(lldb) e newlim
(rlim_t) $18 = 10022912
(lldb) e pagesize
(long) $19 = 4096
(lldb) e newlim
(rlim_t) $20 = 10022912
(lldb) e lim
(rlim_t) $21 = 67104768
(lldb) e newlim - lim
(unsigned long long) $22 = 18446744073652469760
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f598 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:886
883
884 if (pagesize <= newlim - lim)
885 {
-> 886 rlim.rlim_cur = newlim;
887 if (setrlimit (RLIMIT_STACK, &rlim) == 0)
888 lim = newlim;
889 }
Target 0: (Emacs) stopped.
(lldb) e newlim
(rlim_t) $23 = 10022912
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f5a6 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:887
884 if (pagesize <= newlim - lim)
885 {
886 rlim.rlim_cur = newlim;
-> 887 if (setrlimit (RLIMIT_STACK, &rlim) == 0)
888 lim = newlim;
889 }
890 }
Target 0: (Emacs) stopped.
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f5b4 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:888
885 {
886 rlim.rlim_cur = newlim;
887 if (setrlimit (RLIMIT_STACK, &rlim) == 0)
-> 888 lim = newlim;
889 }
890 }
891 /* If the stack is big enough, let regex-emacs.c more of it before
Target 0: (Emacs) stopped.
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f5c2 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:889
886 rlim.rlim_cur = newlim;
887 if (setrlimit (RLIMIT_STACK, &rlim) == 0)
888 lim = newlim;
-> 889 }
890 }
891 /* If the stack is big enough, let regex-emacs.c more of it before
892 falling back to heap allocation. */
Target 0: (Emacs) stopped.
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f5c7 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:890
887 if (setrlimit (RLIMIT_STACK, &rlim) == 0)
888 lim = newlim;
889 }
-> 890 }
891 /* If the stack is big enough, let regex-emacs.c more of it before
892 falling back to heap allocation. */
893 emacs_re_safe_alloca = max
Target 0: (Emacs) stopped.
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f5cc Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:893
890 }
891 /* If the stack is big enough, let regex-emacs.c more of it before
892 falling back to heap allocation. */
-> 893 emacs_re_safe_alloca = max
894 (min (lim - extra, SIZE_MAX) * (min_ratio / ratio),
895 MAX_ALLOCA);
896 }
Target 0: (Emacs) stopped.
(lldb) e emacs_re_safe_alloca
(ptrdiff_t) $24 = 4435280473597425792
(lldb) n
Process 97130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010014f701 Emacs`main(argc=2, argv=0x00007ffeefbff518) at emacs.c:899
896 }
897 #endif /* HAVE_SETRLIMIT and RLIMIT_STACK and not CYGWIN */
898
-> 899 clearerr_unlocked (stdin);
900
901 emacs_backtrace (-1);
902
Target 0: (Emacs) stopped.
(lldb) e emacs_re_safe_alloca
(ptrdiff_t) $25 = 4435280473597425792
(lldb) c
Process 97130 resuming
2018-10-02 15:38:55.115287-0700 Emacs[97130:1949757] MessageTracer: Falling back to default whitelist
2018-10-02 15:38:55.225413-0700 Emacs[97130:2016511] flock failed to lock maps file: errno = 35
2018-10-02 15:38:55.227137-0700 Emacs[97130:2016511] flock failed to lock maps file: errno = 35
Process 97130 exited with status = 0 (0x00000000)
next prev parent reply other threads:[~2018-10-02 22:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-31 19:29 bug#32338: 26.1; term.el broken on macOS Constantine Vetoshev
2018-09-19 23:30 ` Noam Postavsky
2018-09-20 14:15 ` Constantine Vetoshev
2018-09-21 0:35 ` Noam Postavsky
2018-09-22 18:12 ` Constantine Vetoshev
2018-09-22 22:14 ` Noam Postavsky
2018-09-23 5:42 ` Eli Zaretskii
2018-09-29 23:52 ` Constantine Vetoshev
2018-09-30 5:59 ` Eli Zaretskii
2018-09-30 15:25 ` Constantine Vetoshev
2018-09-30 17:13 ` Eli Zaretskii
2018-10-02 22:51 ` Constantine Vetoshev [this message]
2018-10-03 14:59 ` Eli Zaretskii
2018-10-03 19:21 ` Constantine Vetoshev
2018-10-04 16:15 ` Eli Zaretskii
2018-09-30 9:16 ` Alan Third
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+CaSqqRR62QNqpKN-ssHXPoD3cd_tV0+iOfrc5VWYcG3_rP9w@mail.gmail.com \
--to=vetoshev@gmail.com \
--cc=32338@debbugs.gnu.org \
--cc=alan@idiocy.org \
--cc=eliz@gnu.org \
--cc=npostavs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.