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

use parser.open rather than os.open when we encounter an error interpreting during parse #3030

Merged

Conversation

goddenrich
Copy link
Contributor

@goddenrich goddenrich commented Jan 9, 2024

Previously we were calling os.Open which could fail if the build file doesn't exist. Instead use the remote fs by calling parser.open instead.

this was causing

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

goroutine 9094 [running]:
os.(*File).Name(0xfade40?)
	os/file.go:56
github.com/thought-machine/please/src/parse/asp.NameOfReader(...)
	src/parse/asp/lexer.go:50
github.com/thought-machine/please/src/parse/asp.(*errorStack).AddReader(0xc00366f3b0, {0xfb3f28?, 0x0})
	src/parse/asp/errors.go:225 +0x1b4
github.com/thought-machine/please/src/parse/asp.AddReader(...)
	src/parse/asp/errors.go:79
github.com/thought-machine/please/src/parse/asp.(*Parser).annotate(0xc0000b84f8, {0xfafa00?, 0xc00366f3b0}, {0xfb3f28?, 0x0?})
	src/parse/asp/parser.go:174 +0x65
github.com/thought-machine/please/src/parse/asp.(*Parser).ParseFile(0xc0000b84f8, 0xc007298700, 0xc013805b00, 0xc013805b30, 0x1, {0xfae920, 0xc0053b6dc0}, {0xc019f99640, 0x1d})
	src/parse/asp/parser.go:87 +0x4b8
github.com/thought-machine/please/src/parse.(*aspParser).ParseFile(0xc00d3d2af8?, 0x0?, 0xfae920?, 0xc0053b6dc0?, 0xe3?, {0xfae920?, 0xc0053b6dc0?}, {0xc019f99640?, 0xc000b83df0?})
	src/parse/init.go:60 +0x2e
github.com/thought-machine/please/src/parse.parsePackage(0xc000dc8f00, {{0xc003e503e3, 0x17}, {0xc003e503ec, 0xe}, {0xc0007a3920, 0x25}}, {{0xc00028d7e8, 0x0}, {0xc004b0ce81, ...}, ...}, ...)
	src/parse/parse_step.go:192 +0x4be
github.com/thought-machine/please/src/parse.parse(0xc000462000?, {{0xc003e503e3, 0x17}, {0xc003e503ec, 0xe}, {0xc0007a3920, 0x25}}, {{0xc00028d7e8, 0x0}, {0xc004b0ce81, ...}, ...}, ...)
	src/parse/parse_step.go:82 +0x7f2
github.com/thought-machine/please/src/parse.Parse(...)
	src/parse/parse_step.go:35
github.com/thought-machine/please/src/plz.Run.func1.1({{{0xc003e503e3, 0x17}, {0xc003e503ec, 0xe}, {0xc0007a3920, 0x25}}, {{0xc00028d7e8, 0x0}, {0xc004b0ce81, 0x8}, ...}, ...})
	src/plz/plz.go:54 +0xb7
created by github.com/thought-machine/please/src/plz.Run.func1 in goroutine 66
	src/plz/plz.go:53 +0xb8

@@ -83,7 +83,7 @@ func (p *Parser) ParseFile(pkg *core.Package, label, dependent *core.BuildLabel,
}
_, err = p.interpreter.interpretAll(pkg, label, dependent, mode, statements)
if err != nil {
f, _ := os.Open(filename)
f, _ := p.open(fs, filename)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should check the error. This would have been easier to debug if we were.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense.

Copy link

stale bot commented Apr 22, 2024

This issue has been automatically marked as stale because it has not had any recent activity in the past 90 days. It will be closed if no further activity occurs. If you require additional support, please reply to this message. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 22, 2024
@Tatskaari Tatskaari merged commit 0a9031b into thought-machine:master Apr 24, 2024
12 of 13 checks passed
@goddenrich goddenrich deleted the fix-panic-during-parse-error branch April 25, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants