Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yet another "runtime error: index out of range" #1250

Closed
msiism opened this issue Dec 7, 2018 · 14 comments
Closed

Yet another "runtime error: index out of range" #1250

msiism opened this issue Dec 7, 2018 · 14 comments

Comments

@msiism
Copy link
Contributor

msiism commented Dec 7, 2018

When I was editing a Tcl script today and hit Ctrl+S to save it, I got the following error:

runtime error: index out of range
stack traceback:
	[G]: ?

Press enter to continue 

After hitting Enter got me back to my script, I hit Crtl+S again and got:

runtime error: index out of range
stack traceback:
	linter:60: in main chunk
	[G]: ?

Press enter to continue

I've been using micro for about two weeks to work on that script now and this is the first time that error has occured.

Version: 1.4.1
Commit hash: 1856891
OS: Linux
Terminal: urxvt

@Splizard
Copy link

Here is another one, on OSX.

Micro encountered an error: runtime error: index out of range
runtime.errorString runtime error: index out of range
/usr/local/go/src/runtime/panic.go:513 (0x102c579)
	gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/usr/local/go/src/runtime/panic.go:44 (0x102b3ba)
	panicindex: panic(indexError)
/Users/em12256/go/src/github.com/zyedidia/micro/cmd/micro/search.go:125 (0x14c72dc)
	searchDown: l = v.Buf.lines[i].data
/Users/em12256/go/src/github.com/zyedidia/micro/cmd/micro/search.go:203 (0x14c79aa)
	Search: found = searchDown(r, v, v.Buf.Start(), searchStart)
/Users/em12256/go/src/github.com/zyedidia/micro/cmd/micro/search.go:93 (0x14c6d97)
	HandleSearchEvent: Search(messenger.response, v, true)
/Users/em12256/go/src/github.com/zyedidia/micro/cmd/micro/micro.go:580 (0x14a4f06)
	main: HandleSearchEvent(event, CurView())
/usr/local/go/src/runtime/proc.go:201 (0x102e3b7)
	main: fn()
/usr/local/go/src/runtime/asm_amd64.s:1333 (0x105a371)
	goexit: BYTE	$0x90	// NOP

@varjolintu
Copy link

I'm also having this error on macOS.

@colinrioux
Copy link
Contributor

Have you confirmed that you have no illegal/invalid characters in the file which you are trying to save?

@varjolintu
Copy link

What are illegal/invalid characters in this case? My file was just plaintext, including scandinavian letters ä and ö.

@jdnewman85
Copy link

Have you confirmed that you have no illegal/invalid characters in the file which you are trying to save?

I seriously hope that you understand/agree that 'illegal/invalid' characters should be handled without crashing.

A quick glance at search.go:125, it's easy to see that you do not bounds check 'end.Y'. Although this means you also have a bug causing this function to be called with out of range parameters, the function itself should check and error accordingly.

@Silhalnor
Copy link

Silhalnor commented Feb 26, 2019

I--or rather, a friend of mine--have also received this error. Are there any fixes or progress on it?

runtime error: index out of range
stack traceback:
    autoclose:226: in function <autoclose:198>
    (tailcall): ?
    autoclose:1067: in main chunk
    [G]: ?

Press enter to continuedoe
runtime error: index out of range
stack traceback:
    autoclose:190: in function 'len'
    autoclose:1047: in function 'charAt'
    autoclose:1067: in main chunk
    [G]: ?

Press enter to continueo
runtime error: index out of range
stack traceback:
    autoclose:1047: in function 'charAt'
    autoclose:1128: in main chunk
    [G]: ?

Press enter to continue
runtime error: index out of range
stack traceback:
    autoclose:1047: in function 'charAt'
    autoclose:1067: in main chunk
    [G]: ?

Press enter to continue
runtime error: index out of range
stack traceback:
    autoclose:1047: in function 'charAt'
    autoclose:1101: in main chunk
    [G]: ?

Press enter to continue
runtime error: index out of range
stack traceback:
    linter:60: in main chunk
    [G]: ?

Press enter to continue
                       runtime error: index out of range
stack traceback:
    linter:60: in main chunk
    [G]: ?

Press enter to continue
runtime error: index out of range
stack traceback:
    linter:60: in main chunk
    [G]: ?

@zyedidia
Copy link
Owner

I have not been able to reproduce this error. However I believe this error is caused by some buggy interaction between gopher lua and the utf8 parser. I think this will be fixed when I get around to continuing the next version of micro which will involve rewriting the default plugins to use the go stdlib for handling utf8.

@Silhalnor
Copy link

Silhalnor commented Feb 27, 2019

Curious.
Here's my friend's system information. Was running in Terminator, I believe.

Operating System: Arch Linux
Kernel: Linux 4.20.11-arch1-1-ARCH
Architecture: x86-64

And here's my system information. I have not experienced this problem. At least... not yet.
I'm running i3 on Ubuntu 18.04.1 LTS and use Terminator and Guake. Mostly Guake.

Operating System: Ubuntu 18.04.1 LTS
Kernel: Linux 4.15.0-45-generic
Architecture: x86-64

@Silhalnor
Copy link

I got the error now too. (Or something kinda like it, I guess?)

Micro encountered an error: runtime error: index out of range
runtime.errorString runtime error: index out of range
/home/zbyedidia/go/src/runtime/panic.go:491 (0x42bbc3)
/home/zbyedidia/go/src/runtime/panic.go:28 (0x42a89e)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/vendor/github.com/yuin/gopher-lua/state.go:440 (0x578b76)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/vendor/github.com/yuin/gopher-lua/auxlib.go:250 (0x54617a)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/vendor/github.com/yuin/gopher-lua/state.go:452 (0x578dcb)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/vendor/github.com/yuin/gopher-lua/state.go:1661 (0x595868)
/home/zbyedidia/go/src/runtime/asm_amd64.s:510 (0x4584fb)
/home/zbyedidia/go/src/runtime/panic.go:491 (0x42bbc3)
/home/zbyedidia/go/src/runtime/panic.go:28 (0x42a89e)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/vendor/github.com/yuin/gopher-lua/vm.go:801 (0x59b1bf)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/vendor/github.com/yuin/gopher-lua/vm.go:31 (0x591a91)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/vendor/github.com/yuin/gopher-lua/state.go:876 (0x57bd48)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/vendor/github.com/yuin/gopher-lua/state.go:1610 (0x5824c8)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/vendor/github.com/yuin/gopher-lua/state.go:1671 (0x5825dd)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/vendor/github.com/yuin/gopher-lua/state.go:1689 (0x582a5a)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/plugin.go:38 (0x8d8f46)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/view.go:645 (0x912ad7)
/home/zbyedidia/gopath/src/github.com/zyedidia/micro/cmd/micro/micro.go:574 (0x8d7f30)
/home/zbyedidia/go/src/runtime/proc.go:185 (0x42d9cd)
/home/zbyedidia/go/src/runtime/asm_amd64.s:2337 (0x45acc1)

@Silhalnor
Copy link

Okay, this is more like the error I'm "supposed to" get. Seems to happen when I'm in the editor for a particularly long time.

$ micro sgs_dev
runtime error: index out of range
stack traceback:
	autoclose:226: in function <autoclose:198>
	(tailcall): ?
	autoclose:1067: in main chunk
	[G]: ?

Press enter to continue
runtime error: index out of range
stack traceback:
	autoclose:226: in function <autoclose:198>
	(tailcall): ?
	autoclose:1067: in main chunk
	[G]: ?

Press enter to continue

@prez
Copy link
Contributor

prez commented Sep 12, 2019

Not sure how to reproduce, but I'm getting this as well.

stack traceback:
	[G]: ?

Press enter to continue
runtime error: index out of range
stack traceback:
	linter:60: in main chunk
	[G]: ?

Press enter to continue

Edit: also seems to happen mostly after having the file open for long periods of time.

@MarcusE1W
Copy link

I get this, is that related ?

runtime error: index out of range [5120] with length 5120
stack traceback:
	autoclose:226: in function <autoclose:198>
	(tailcall): ?
	autoclose:1067: in main chunk
	[G]: ?

It comes every 10-20 min of writing (markdown in my case). @zyedidia mentions Lua above. Can I uninstall plugin autoclose ? What does it do ?

@tommyshem
Copy link
Contributor

To turn autoclose plugin off.

ctrl e

set autoclose off

zyedidia added a commit that referenced this issue Dec 25, 2019
The code from the refactor that I have been working on is
now more or less ready to be merged. These changes make some
breaking changes, notably with regards to the plugin
interface. Once a lot more documentation has been written, I
will release this code as micro 2.0. There are a lot of new
features, and in the coming days I will try to go through
the open issues to see exactly which ones are addressed by
the new features, and write lots more documentation
regarding what has been implemented.

Some highlights include:

* Simple autocompletion.
    * Autocompletion (tab by default) will do a simple
      "buffer completion" which will autocomplete according
      to words used elsewhere in the buffer. In the future
      plugin support could be added along with support for
      interfacing with language-specific autocompletion
      tools.
* Automatic backups.
    * Backup files are stored in `~/.config/micro/backups`
      for every open buffer and are saved roughly every 8
      seconds if the buffer is being modified. Backups
      are removed when the buffer is closed, but if micro
      or the system crashes, any unsaved changes can be
      recovered by re-opening the file (micro will auto-
      recover) or by manually viewing the backup in the
      `~/.config/micro/backups` directory.
* Configurable statusline.
* Configurable linter plugin.
* Resizeable splits.
* Complete re-organization of the code to support better go
  modules and maintain a better directory structure.
* Better plugin interface with better access to the Go
  standard library and internal Micro functions (lots of
  documentation still needs to be written).
    * Documentation still needs to be written, but in the
      meantime please see the default plugins as examples
      as they have been converted from their old versions
      to be compatible with the new interface.
* Buffer synchronization when the same file is opened
  multiple times.
* Keybindings and mouse support in the command bar.
* Support for non-utf8 encodings.
* General QoL improvements and bug fixes.
    * Notably I believe the autoclose plugin crash issue is
      fixed.
* No more plugin manager.
    * Plugin installation will now be performed manually
      by git cloning into the `~/.config/micro/plug`
      directory. This may not be a highlight for some but
      I believe it is much simpler, and there is no need
      to have a heavyweight dependency manager. Perhaps
      in the future, a good command-line tool can be made
      to manage plugins if people would find it useful.
* Other features that I have forgotten.

Next I plan to write up more documentation for all the new
features, and make a "release candidate" for micro 2.0. I
will also be working to fix any bugs that come up (hopefully
not too many, but this is a big change and bound to have
some issues). After release I hope to focus more on
optimization (for example loading syntax files is currently
somewhat inefficient, and the bottleneck for startup time #1427).

Sorry for not being so active recently, but I hope merging
this big change can help me get back to more regular
development. Thanks to everyone for using micro and for
giving feedback and engaging with development online (even
if I don't always respond).

Merry Christmas!

Issues that are fixed/affected by this change:

Ref #1419 (configurable statusline)
Ref #1413 (cursor behaves better)
Ref #1401 (softwrap problems)
Ref #1383 (better save with sudo)
Ref #1424 (better save with sudo)
Ref #1382 (go modules)
Ref #1381 (install plugins from command line)
Ref #1357 (sorting -- textfilter)
Ref #1351 (custom linting)
Ref #1350 (sudo problem might be fixed)
Ref #1298 (readonly option)
Ref #1250 (autoclose bug)
Ref #1239 (go modules)
Ref #813  (autoclose bug)
Ref #812  (cursor sync across same buffers)
Ref #770  (resizeable panes)
Ref #635  (keybindings in infobar)
Ref #596  (disable builtin plugins)
Ref #550  (backups)
Ref #174  (autocompletion)
@zyedidia
Copy link
Owner

This issue was caused by the autoclose plugin and should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants