air icon indicating copy to clipboard operation
air copied to clipboard

Sometimes `air` panics when ran

Open MilkeeyCat opened this issue 1 year ago • 2 comments

Sometimes when I run command air I get such an error

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x90 pc=0x527620]

goroutine 40 [running]:
regexp.(*Regexp).doExecute(0xc00032be00?, {0x0?, 0x0?}, {0xc000380050?, 0x7fcd05?, 0xc00032be26?}, {0x0?, 0xc00032be00?}, 0x4d?, 0x0, ...)
        /home/alex/Downloads/go/src/regexp/exec.go:527 +0x80
regexp.(*Regexp).doMatch(...)
        /home/alex/Downloads/go/src/regexp/exec.go:514
regexp.(*Regexp).Match(...)
        /home/alex/Downloads/go/src/regexp/regexp.go:537
github.com/cosmtrek/air/runner.(*Engine).isExcludeRegex(0xc0001d6000?, {0xc00032be00, 0x4d})
        /home/alex/go/pkg/mod/github.com/cosmtrek/[email protected]/runner/util.go:149 +0xcb
github.com/cosmtrek/air/runner.(*Engine).watchPath.func1()
        /home/alex/go/pkg/mod/github.com/cosmtrek/[email protected]/runner/engine.go:257 +0x3d3
created by github.com/cosmtrek/air/runner.(*Engine).watchPath in goroutine 1
        /home/alex/go/pkg/mod/github.com/cosmtrek/[email protected]/runner/engine.go:224 +0x23f

I had version 1.52.0 but the place where the error occurred doesn't seem to be updated since 1.52.0 version

OS: Linux

MilkeeyCat avatar Sep 25 '24 06:09 MilkeeyCat

@MilkeeyCat please provide more details to reproduce it

cosmtrek avatar Sep 25 '24 11:09 cosmtrek

I don't have a way how to reproduce it, it just happens sometimes

MilkeeyCat avatar Sep 25 '24 12:09 MilkeeyCat

This seems to be the same issue as #530 that is reported on an even older version of air. It seems that the compiled regex is nil when it is dereferenced in regexp/exec.go:527, but it isn't immediately obvious what could have caused that when reading through the code higher up in the call stack ... This smells like some sort of memory issue ... (edit: or a race, see PR below)

istyf avatar Nov 02 '24 14:11 istyf

should be fixed by https://github.com/air-verse/air/pull/677

xiantang avatar Dec 16 '24 15:12 xiantang