Skip to content

[zsh 5.0.2] Referencing $WIDGET can cause a segfault. #336

Open
@tallus

Description

In zsh-syntax-highlighting/highlighters/main/main-highlighter.zsh on line 66 there's a reference to $WIDGET.
_zsh_highlight_main_highlighter_predicate()
{
[[ $WIDGET == accept-* ]] ||
_zsh_highlight_buffer_modified
}
Most of the time this is unproblematic. However if a TRAPWINCH function is defined that calls zle/zle reset-prompt (which is a typical use case for it) it will cause a segfault, though only if there has been no user interaction (typing anything will prevent it).

This is a fairly obscure issue and properly is an upstream bug* (which I've reported) but I'm also reporting it here as this is what originally triggered it. I came across it by having both zsh-syhntax-highlighting and vi-mode (which defines TRAPWINCH) enabled as plugins in on-my-zsh.

  • it can be triggered by defining a TRAPWINCH like, say TRAPWINCH(){echo $WIDGET}, absent z-sy-h, or reset-prompt. Though it seems that zle reset-prompt is the bit that results in the call to _zsh_highlight_main_highlighter_predicate via line 92 in zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions