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

Can now specify a safe encoding which prevents segfaults in containers. Fixes #1 #3

Merged
merged 1 commit into from
Mar 29, 2019
Merged

Can now specify a safe encoding which prevents segfaults in containers. Fixes #1 #3

merged 1 commit into from
Mar 29, 2019

Conversation

mikegleasonjr
Copy link
Contributor

@mikegleasonjr mikegleasonjr commented Mar 29, 2019

The feature is opt-in. The default behaviour is the current behaviour.

Here are the benchmarks:

BenchmarkSafeEncoding-4      	      20	  90524720 ns/op	 2990679 B/op	     325 allocs/op
BenchmarkRegularEncoding-4   	      20	  86883378 ns/op	  427743 B/op	     318 allocs/op

Fixes #1

@jdeng
Copy link
Owner

jdeng commented Mar 29, 2019

thanks!

@jdeng jdeng merged commit 78ce073 into jdeng:master Mar 29, 2019
@mikegleasonjr mikegleasonjr deleted the safe-encoding branch March 29, 2019 14:17
@snowlock650
Copy link

@mikegleasonjr I have encountered the same error as in [https://github.com//issues/15]( issue 15 ). It is resolved with Safe encoding fix; I have read your patch but don't understand why it prevents the crash?

I understand that C.GoBytes allocates the memory and copies the content of byte pointer to ycc.Y (for example)
and (*[1 << 30]byte)(unsafe.Pointer(y))[:int(height)*int(ystride)] simply assign the pointer to the slice struct.

But I don't see why would the second statement causes SIGSEGV? If the memory to the said pointer is invalid, then both operation should fail?

@rajendraventurit
Copy link

rajendraventurit commented Aug 1, 2021

@mikegleasonjr I am still facing the segfault in containers. Any help would be appreciable.

@mikegleasonjr
Copy link
Contributor Author

The code was provided for me by the original author. In fact, I think there was 2 code blocks, one commented out and one active, and we put them behind a flag if my memory serves me correctly to be able to switch between the two at runtime and prevent segfaults in containers.

Sorry I can't be of any more help...

@rajendraventurit
Copy link

The code was provided for me by the original author. In fact, I think there was 2 code blocks, one commented out and one active, and we put them behind a flag if my memory serves me correctly to be able to switch between the two at runtime and prevent segfaults in containers.

Sorry I can't be of any more help...

Added the flag and it worked. Thanks!

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.

segfaults in Docker
4 participants