Apr 11, 2020, 23:11 by chet.ra...@case.edu:

> On 4/11/20 12:04 PM, gentoo_esh...@tutanota.com wrote:
>
>>>
>>> What's your $PS1?
>>>
>> $ echo $PS1
>> \ -----------\n\ \[\a\]\ \[\e[1;37m\e[42m\]\u@\H\[\e[0m\] \ 
>> \[\033[1;30m\]$(date "+%Y/%m/%d %H:%M:%S")\[\033[0m\] \ \[\e[0;37m\]\s\V 
>> t:\l j:\j \ d:${SHLVL} pp:${PPID} p:$$ ut`cat /proc/uptime | cut -f1 
>> -d.`\[\e[0m\]\n\ \[\e[0;37m\]!\!\[\e[0m\] \ \[\033[0;36m\]\#\[\033[0m\] \ 
>> $(evalexitcode "${__earlyec[@]}" ) \ \[\e[0m\]$(uname -r) $(uname -v) 
>> $(ps_lepath "\w")\[ \033];\w\a\] \[\e[1;32m\]\$\[\e[0m\] \
>>
>
> I have to hand it to you; that's one of the most complicated prompt strings
> I've ever seen.
>
> In any event, that didn't help me reproduce the seg fault, but I was able
> to use the stack traceback you sent to find a problem. I've attached a
> patch.
>

This is amazing, that patch completely fixed the issue, thank you!

I was wondering, in this line:
memmove (old_face+newbytes, old_face+oldbytes, strlen (old+oldbytes) + 1);is 
the strlen correct or should it be strlen (old_face+oldbytes) ? ie. old gets 
changed to old_face

in this context:
memmove (old+newbytes, old+oldbytes, strlen (old+oldbytes) + 1);
memmove (old_face+newbytes, old_face+oldbytes, strlen (old+oldbytes) + 1);
in file lib/readline/display.c
It's probably already correct even though I don't understand why(because I 
don't know what all those variables do), but still I wanted to ask just to be 
sure.

I've tested that it works with either variant... but that's likely because that 
'if (oldbytes != newbytes)' isn't entered in my tests. Oh, if I remove the 'if' 
I see that both strlen variants return the same value, so I guess it's correct 
either way. Nevermind then.


>>> You should just have to run `ulimit -c unlimited'.
>>>
>> Thank you for your reply. It was already 'unlimited'. But when firefox 
>> segfaults it works (that is, `coredumpctl -r`  does list it), yet it doesn't 
>> happen for bash and I thought it's because bash is somehow catching it and 
>> handling it internally, 
>>
>
> Bash does catch SIGSEGV and does some cleanup, to the extent that it can do
> anything, and kills itself with the same signal (that's why you see 139 as
> the exit status). That should still result in a core dump.
>
Oh that's good to know. I've tracked down the issue to an exit that happens 
before bash gets the chance to re-issue the coredump/kill self with SEGV, by 
using the attached patch to simulate a segmentation fault inside bash, I get 
this:
$ ./bash
TERM='xterm-256color'
/usr/bin/blugon
2069.22 7138.70
-----------
user@Z575 2020/04/12 07:00:36 bash5.0.16 t:6 j:0 d:4 pp:16407 p:155787 ut2069
!76112 1 0  5.6.3-gf9fb85751506 #90 SMP PREEMPT Thu Apr 9 19:22:52 CEST 2020
/home/user/build/1packages/4used/bash-devel-git/makepkg_pacman/bash/src/bash 
$ !1!
!2!
!3!
!4!

that "!4!" is in sig.c here:
    if (dollar_dollar_pid != 1) {
      fprintf (stderr, "!4!\n");fflush (stderr);
      exit (128+sig);   /* just in case the kill fails? */
    }
(the attached patch shows exact context)
Is there anything you could do to fix it?
Thanks in advance.

> Chet
> -- 
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/
>

diff --git a/lib/readline/display.c b/lib/readline/display.c
index 14af1e92..c50006ae 100644
--- a/lib/readline/display.c
+++ b/lib/readline/display.c
@@ -1584,6 +1584,8 @@ puts_face (const char *str, const char *face, int n)
   for (cur_face = FACE_NORMAL, i = 0; i < n; i++)
     putc_face (str[i], face[i], &cur_face);
   putc_face (EOF, FACE_NORMAL, &cur_face);
+  int *p=0;
+  *p=1;
 }
 
 #define ADJUST_CPOS(x) do { _rl_last_c_pos -= (x) ; cpos_adjusted = 1; } while (0)
@@ -1758,6 +1760,9 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
 		  ne = new + nmax;
 		  nd = newbytes;
 		  nfd = new + nd;
+		  ofdf = old_face;
+		  nfdf = new_face;
+
 		  goto dumb_update;
 		}
 	      if (oldbytes != 0 && newbytes != 0)
@@ -1773,7 +1778,8 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
 		  if (oldbytes != newbytes)
 		    {
 		      memmove (old+newbytes, old+oldbytes, strlen (old+oldbytes) + 1);
-		      memmove (old_face+newbytes, old_face+oldbytes, strlen (old+oldbytes) + 1);
+		      memmove (old_face+newbytes, old_face+oldbytes, strlen (old_face+oldbytes) + 1);
+          //fprintf(rl_outstream,"%d/%d\n", strlen (old+oldbytes), strlen (old_face+oldbytes));
 		    }
 		  memcpy (old, new, newbytes);
 		  memcpy (old_face, new_face, newbytes);
diff --git a/sig.c b/sig.c
index 54bf7d76..8288ae25 100644
--- a/sig.c
+++ b/sig.c
@@ -606,16 +606,22 @@ termsig_handler (sig)
 
   run_exit_trap ();	/* XXX - run exit trap possibly in signal context? */
 
+  fprintf (stderr, "!1!\n");fflush (stderr);
   /* We don't change the set of blocked signals. If a user starts the shell
      with a terminating signal blocked, we won't get here (and if by some
      magic chance we do, we'll exit below). */
   set_signal_handler (sig, SIG_DFL);
 
+  fprintf (stderr, "!2!\n");fflush (stderr);
   kill (getpid (), sig);
+  fprintf (stderr, "!3!\n");fflush (stderr);
 
-  if (dollar_dollar_pid != 1)
+  if (dollar_dollar_pid != 1) {
+    fprintf (stderr, "!4!\n");fflush (stderr);
     exit (128+sig);		/* just in case the kill fails? */
+  }
 
+  fprintf (stderr, "!5!\n");fflush (stderr);
   /* We get here only under extraordinary circumstances. */
 
   /* We are PID 1, and the kill above failed to kill the process. We assume
@@ -629,13 +635,20 @@ termsig_handler (sig)
     {
       set_signal_handler (XSIG (i), SIG_DFL);
       sigdelset (&mask, XSIG (i));
-      if (sig == XSIG (i))
+      if (sig == XSIG (i)) {
+        fprintf (stderr, "!6!\n");fflush (stderr);
 	core = XCOREDUMP (i);
+      }
     }
+  fprintf (stderr, "!7!\n");fflush (stderr);
   sigprocmask (SIG_SETMASK, &mask, (sigset_t *)NULL);
+  fprintf (stderr, "!8!\n");fflush (stderr);
 
-  if (core)
+  if (core) {
+      fprintf (stderr, "!9!\n");fflush (stderr);
     *((volatile unsigned long *) NULL) = 0xdead0000 + sig;	/* SIGSEGV */
+  }
+  fprintf (stderr, "!A!\n");fflush (stderr);
 
   exit (128+sig);
 }
              • ... Daniel Colascione
              • ... Chet Ramey
              • ... Daniel Colascione
              • ... Chet Ramey
              • ... Daniel Colascione
              • ... Chet Ramey
  • Re: [PATCH... gentoo_eshoes--- via Bug reports for the GNU Bourne Again SHell
    • Re: [... Chet Ramey
      • R... gentoo_eshoes--- via Bug reports for the GNU Bourne Again SHell
        • ... Chet Ramey
          • ... gentoo_eshoes--- via Bug reports for the GNU Bourne Again SHell
            • ... Chet Ramey
              • ... gentoo_eshoes--- via Bug reports for the GNU Bourne Again SHell
              • ... Chet Ramey
              • ... Daniel Colascione
              • ... gentoo_eshoes--- via Bug reports for the GNU Bourne Again SHell
              • ... Chet Ramey
            • ... Chet Ramey
              • ... gentoo_eshoes--- via Bug reports for the GNU Bourne Again SHell
              • ... Chet Ramey
        • ... Ángel

Reply via email to