Skip to content

Close file destroys wrong buffer #114

Description

@ricochet1k

This fix allows the current tab to be the one targeted by typing and commands: limetext/lime-qml@5416f3b
After that commit, it is now possible to crash lime-qml by opening a file, closing an older one and typing in it. It looks like the backend is destroying a buffer it shouldn't when the close command is issued.

Steps to reproduce:

  1. Run lime-qml
  2. Use File ->Open File... to open a file
  3. Click on the first "untitled" tab
  4. Click File -> CloseFile
  5. Type in the newly opened file
[07/25/16 11:07:49] [DEBG] frontend.HandleInput: text=a, key=41, modifiers=0
[07/25/16 11:07:49] [EROR] Panic in RunTextCommand: runtime error: invalid memory address or nil pointer dereference
View{id:10, buffer: %!s(<nil>)} "insert" backend.Args{"characters":"a"}
/home/matt/work/src/github.com/limetext/backend/commandhandler.go:123 (0x5178b5)
    (*commandHandler).RunTextCommand.func1: log.Error("Panic in RunTextCommand: %v\n%v %#v %#v\n%s", r, view, name, args, string(debug.Stack()))
/home/matt/opt/go/src/runtime/asm_amd64.s:437 (0x4bd0ce)
    call32: CALLFN(·call32, 32)
/home/matt/opt/go/src/runtime/panic.go:423 (0x48d709)
    gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/home/matt/opt/go/src/runtime/panic.go:42 (0x48bdc9)
    panicmem: panic(memoryError)
/home/matt/opt/go/src/runtime/sigpanic_unix.go:24 (0x4a246a)
    sigpanic: panicmem()
/home/matt/work/src/github.com/limetext/backend/view.go:989 (0x514bd4)
    (*View).ChangeCount: return v.buffer.ChangeCount()
/home/matt/work/src/github.com/limetext/backend/edit.go:34 (0x4fd090)
    newEdit: savedCount: v.ChangeCount(),
/home/matt/work/src/github.com/limetext/backend/view.go:395 (0x50e615)
    (*View).BeginEdit: e := newEdit(v)
/home/matt/work/src/github.com/limetext/backend/view.go:605 (0x51166d)
    (*View).runCommand: e := v.BeginEdit()
/home/matt/work/src/github.com/limetext/backend/commandhandler.go:139 (0x4fb1db)
    (*commandHandler).RunTextCommand: } else if err := view.runCommand(c, name); err != nil {
/home/matt/work/src/github.com/limetext/backend/editor.go:337 (0x518fda)
    (*Editor).inputthread.func1: if err := e.CommandHandler().RunTextCommand(v, "insert", Args{"characters": kp.Text}); err != nil {
/home/matt/work/src/github.com/limetext/backend/editor.go:344 (0x5026e1)
    (*Editor).inputthread: doinput(kp)
/home/matt/opt/go/src/runtime/asm_amd64.s:1721 (0x4bf421)
    goexit: BYTE    $0x90   // NOP

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/36333201-close-file-destroys-wrong-buffer?utm_campaign=plugin&utm_content=tracker%2F15716642&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F15716642&utm_medium=issues&utm_source=github).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions