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

fix: SIGSEGV when an env var is empty #1271

Merged
merged 2 commits into from
Dec 20, 2024
Merged

fix: SIGSEGV when an env var is empty #1271

merged 2 commits into from
Dec 20, 2024

Conversation

dunglas
Copy link
Owner

@dunglas dunglas commented Dec 20, 2024

Should fix #1269.

The behavior of unsafe.StringData() is undefined when the string is empty.

@AlliBalliBaba
Copy link
Collaborator

You are right, the documentation states that it can return nil. I think we were also pinning empty strings before #1137, maybe this is due to a newer go version? I'll see if I can reproduce it somehow

@dunglas dunglas merged commit 8cf6616 into main Dec 20, 2024
51 of 52 checks passed
@dunglas dunglas deleted the fix/1269 branch December 20, 2024 14:37
@AlliBalliBaba
Copy link
Collaborator

go_getfullenv was refactored in #1185 to use the method from phpthread.go, but the underlying logic didn't really change.

I am only able to recreate the segfault by explicitly pinning a constant string like this:
thread.pinString("")

@AlliBalliBaba
Copy link
Collaborator

Or wait, not even then am I seeing the segmentation violation. Maybe we should add fuzzing tests for the environment as well

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

Successfully merging this pull request may close these issues.

SIGSEGV: segmentation violation. Invalid memory address or nil pointer dereference
2 participants