~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH aerc v1] fix segfault when copy-pasting into compose editor

Details
Message ID
<20220111110228.539596-1-koni.marti@gmail.com>
DKIM signature
pass
Download raw message
Patch: +3 -0
fixes the segmentation fault when copy-pasting a large text into the
composer editor. The problem is a concurrent read of the vterm field in the
Terminal widget in its flushTerminal() method which can be avoided with a mutex.

Fixes: https://todo.sr.ht/~rjarry/aerc/12
Signed-off-by: Koni Marti <koni.marti@gmail.com>
---
 widgets/terminal.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/widgets/terminal.go b/widgets/terminal.go
index 2a1afa5..68c9553 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -106,6 +106,7 @@ type Terminal struct {
	damage      []vterm.Rect // protected by damageMutex
	damageMutex sync.Mutex
	writeMutex  sync.Mutex
	readMutex   sync.Mutex

	OnClose func(err error)
	OnEvent func(event tcell.Event) bool
@@ -155,7 +156,9 @@ func NewTerminal(cmd *exec.Cmd) (*Terminal, error) {
func (term *Terminal) flushTerminal() {
	buf := make([]byte, 4096)
	for {
		term.readMutex.Lock()
		n, err := term.vterm.Read(buf)
		term.readMutex.Unlock()
		if err != nil {
			term.Close(err)
			return
-- 
2.34.1

[aerc/patches/.build.yml] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CH2SMPNXG1UY.LBK6UAGEO8U9@cirno2>
In-Reply-To
<20220111110228.539596-1-koni.marti@gmail.com> (view parent)
DKIM signature
missing
Download raw message
aerc/patches/.build.yml: SUCCESS in 1m4s

[fix segfault when copy-pasting into compose editor][0] from [Koni Marti][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/28158
[1]: koni.marti@gmail.com

✓ #669301 SUCCESS aerc/patches/.build.yml https://builds.sr.ht/~rjarry/job/669301
Details
Message ID
<CH4DPR1UNTBA.2CGL9V0JUBI3X@bisio>
In-Reply-To
<20220111110228.539596-1-koni.marti@gmail.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
Yay!! It works!

Thanks! :)


On Tue Jan 11, 2022 at 12:02 PM CET, Koni Marti wrote:
> fixes the segmentation fault when copy-pasting a large text into the
> composer editor. The problem is a concurrent read of the vterm field in
> the
> Terminal widget in its flushTerminal() method which can be avoided with
> a mutex.
>
> Fixes: https://todo.sr.ht/~rjarry/aerc/12
> Signed-off-by: Koni Marti <koni.marti@gmail.com>
> ---
> widgets/terminal.go | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/widgets/terminal.go b/widgets/terminal.go
> index 2a1afa5..68c9553 100644
> --- a/widgets/terminal.go
> +++ b/widgets/terminal.go
> @@ -106,6 +106,7 @@ type Terminal struct {
> damage []vterm.Rect // protected by damageMutex
> damageMutex sync.Mutex
> writeMutex sync.Mutex
> + readMutex sync.Mutex
>  
> OnClose func(err error)
> OnEvent func(event tcell.Event) bool
> @@ -155,7 +156,9 @@ func NewTerminal(cmd *exec.Cmd) (*Terminal, error) {
> func (term *Terminal) flushTerminal() {
> buf := make([]byte, 4096)
> for {
> + term.readMutex.Lock()
> n, err := term.vterm.Read(buf)
> + term.readMutex.Unlock()
> if err != nil {
> term.Close(err)
> return
> --
> 2.34.1
Details
Message ID
<CH5NHVISDZ34.ZR37R8TJTLVF@diabtop>
In-Reply-To
<20220111110228.539596-1-koni.marti@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Koni Marti, Jan 11, 2022 at 12:02:
> fixes the segmentation fault when copy-pasting a large text into the
> composer editor. The problem is a concurrent read of the vterm field in the
> Terminal widget in its flushTerminal() method which can be avoided with a mutex.
>
> Fixes: https://todo.sr.ht/~rjarry/aerc/12
> Signed-off-by: Koni Marti <koni.marti@gmail.com>

Nice catch. Thanks!

To git.sr.ht:~rjarry/aerc
   71eda7d37c8e..4782473064fa  4782473064fa -> master
Reply to thread Export thread (mbox)