From: Bart Schaefer <schaefer@brasslantern.com>
To: "Sebastian Götte" <jaseg@physik.tu-berlin.de>, zsh-workers@zsh.org
Subject: Re: Segfault in hrealloc somewhere between rpromts and syntax highlighting
Date: Sun, 06 Apr 2014 00:05:41 -0700 [thread overview]
Message-ID: <140406000541.ZM14625@torch.brasslantern.com> (raw)
In-Reply-To: =?iso-8859-1?Q?=3C53381887=2E2040201=40physik=2Etu-berlin=2Ed?= =?iso-8859-1?Q?e=3E?= =?iso-8859-1?Q?Comments=3A_In_reply_to_Sebastian_G=F6tte_=3Cjaseg=40physi?= =?iso-8859-1?Q?k=2Etu-berlin=2Ede=3E?= =?iso-8859-1?Q?________=22Segfault_in_hrealloc_somewhere_between_rpromts_?= =?iso-8859-1?Q?and_syntax_highlighting=22_=28Mar_30=2C__3=3A13pm=29?=
I'm only a little surprised that nobody else responded to this while I was
offline. It's been known for quite some time that there are crash bugs in
region_highlight that are violently tickled by zsh-syntax-highlighting.
None of the regular developers uses zsh-syntax-highlighting as far as I
know (I certainly don't), so we're not encountering this directly.
Unfortunately, the actual error is somewhere far removed from the point
where the crash occurs -- something is leaving a corrupted heap as an
unintentional booby-trap for hrealloc to trip only after the evidence
has been destroyed -- so the stack traces we get are not helpful.
I do have one question for you:
On Mar 30, 3:13pm, Sebastian Götte said this was a minimal zshrc:
}
} setopt promptsubst
} RPROMPT='$("%s")'
} ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
} source ~/dotfiles/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
If I make that my .zshrc (with appropriate tweak to the path to the
zsh-syntax-highlighting clone), I get this:
zsh: command not found: %s
torch%
zsh: command not found: %s
torch%
Obviously something is missing here. What's supposed to fill in that %s
in the RPROMPT?
I'm otherwise not able to reproduce the crash with the sample you provided,
though running under valgrind creates a continuous stream of leaked memory
warnings during highlighting. Here's a patch for those leaks.
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 8ce6787..80be27f 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -444,6 +444,7 @@ void
set_region_highlight(UNUSED(Param pm), char **aval)
{
int len;
+ char **av = aval;
struct region_highlight *rhp;
len = aval ? arrlen(aval) : 0;
@@ -490,6 +491,8 @@ set_region_highlight(UNUSED(Param pm), char **aval)
match_highlight(strp, &rhp->atr);
}
+
+ freearray(av);
}
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 3c7cff9..b916bd6 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2795,6 +2795,7 @@ doexpandhist(void)
if (!err) {
zlemetacs = excs;
if (strcmp(zlemetaline, ol)) {
+ zle_restore_positions();
unmetafy_line();
/* For vi mode -- reset the beginning-of-insertion pointer *
* to the beginning of the line. This seems a little silly, *
diff --git a/Src/hist.c b/Src/hist.c
index 1845bd8..1624912 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -1764,7 +1764,8 @@ chrealpath(char **junkptr)
str++;
}
- *junkptr = metafy(bicat(real, nonreal), -1, META_HEAPDUP);
+ *junkptr = metafy(str = bicat(real, nonreal), -1, META_HEAPDUP);
+ zsfree(str);
#ifdef HAVE_CANONICALIZE_FILE_NAME
free(real);
#endif
next prev parent reply other threads:[~2014-04-06 7:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-30 13:13 Sebastian Götte
2014-04-06 7:05 ` Bart Schaefer [this message]
2014-04-06 16:02 ` Peter Stephenson
2014-04-06 16:50 ` Bart Schaefer
2014-04-06 17:06 ` Peter Stephenson
2014-04-12 17:29 ` Jun T.
2014-04-13 1:35 ` Bart Schaefer
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=140406000541.ZM14625@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=jaseg@physik.tu-berlin.de \
--cc=zsh-workers@zsh.org \
/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 public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).