Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: gentoo_eshoes@tutanota.com Newsgroups: gnu.bash.bug Subject: Re: [PATCH] Add active mark, face support; activate mark on paste Date: Sun, 12 Apr 2020 07:04:05 +0200 (CEST) Lines: 197 Approved: bug-bash@gnu.org Message-ID: References: <875c423e-0420-78d2-af4b-dfb168432e2d@case.edu> <902c38ef-7534-8f6d-51b7-daa0843b8440@case.edu> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_154860_1656829858.1586667845294" X-Trace: usenet.stanford.edu 1586667853 22517 209.51.188.17 (12 Apr 2020 05:04:13 GMT) X-Complaints-To: action@cs.stanford.edu Cc: chet.ramey@case.edu, bug-bash@gnu.org To: Chet Ramey Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586667845; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=6RDARTzwK7D4a2HCS0Xf6t+mJDQKP1zvlObyiR1lXcI=; b=ktKf2gGAbkAAj+V9A2ttLYqIAOhQHKYLK213jPiBeevY8kVLqhCpsbBtj1GCSw21 Ao0L0SrBWnz9x10ou4ifXUbCD+nuLDljHK7kZ795Ts0L3ULMFkTZUVQD7ZtzqM9MK5Z Bl0gVP7FPHgzPapsbNiRSvNCzDC7p6/zHyivv4t7OjVGlucR4O9EY+me1vx9Cbyp3M8 xml3m6lzUSxo3+TSap4fS3SEbCz1hSrcA+bg66uTUZTLUld21IyQyqkpHBUwmqs1xw+ U/XMTGWooMiqN3+LLny2EJEtazXOdmGokoBeIgjHOx+eUi8fjrM/4LB+YpgcrP5CV12 nD28QOMheQ== In-Reply-To: <902c38ef-7534-8f6d-51b7-daa0843b8440@case.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 81.3.6.162 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <875c423e-0420-78d2-af4b-dfb168432e2d@case.edu> <902c38ef-7534-8f6d-51b7-daa0843b8440@case.edu> Xref: csiph.com gnu.bash.bug:16124 ------=_Part_154860_1656829858.1586667845294 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Apr 11, 2020, 23:11 by chet.ramey@case.edu: > On 4/11/20 12:04 PM, gentoo_eshoes@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 "${__e= arlyec[@]}" ) \ \[\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 strin= gs > 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);i= s the strlen correct or should it be strlen (old_face+oldbytes) ? ie. old g= ets 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 !=3D newbytes)' isn't entered in my tests. Oh, if I remo= ve the 'if' I see that both strlen variants return the same value, so I gue= ss 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 s= egfaults it works (that is, `coredumpctl -r`=C2=A0 does list it), yet it do= esn't happen for bash and I thought it's because bash is somehow catching i= t and handling it internally,=20 >> > > 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 a= s > 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=3D'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 ut20= 69 !76112 1 0=C2=A0 5.6.3-gf9fb85751506 #90 SMP PREEMPT Thu Apr 9 19:22:52 CES= T 2020 /home/user/build/1packages/4used/bash-devel-git/makepkg_pacman/bash/src/bas= h=20 $ !1! !2! !3! !4! that "!4!" is in sig.c here: =C2=A0=C2=A0=C2=A0 if (dollar_dollar_pid !=3D 1) { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fprintf (stderr, "!4!\n");fflush (stderr); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 exit (128+sig);=C2=A0=C2=A0 /* just in case = the kill fails? */ =C2=A0=C2=A0=C2=A0 } (the attached patch shows exact context) Is there anything you could do to fix it? Thanks in advance. > Chet > --=20 > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/ > ------=_Part_154860_1656829858.1586667845294 Content-Type: text/x-patch; charset=us-ascii; name=le.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=le.patch 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); } ------=_Part_154860_1656829858.1586667845294--