Fix a memory allocation error on FreeBSD 10.3R#710
Fix a memory allocation error on FreeBSD 10.3R#710mguegan wants to merge 1 commit intoprometheus:masterfrom
Conversation
On some condition, it is possible to hit a memory allocation failure when retrieving the `buffer_bytes` via `sysctl()`. Adding the `dataType` seems to fix this issue.
|
I don't really have any systems to verify that this is compatible with other versions / architectures. But I guess I can take your word for it. :-) |
|
Well.. I've only tested this patch in production on |
|
So the issue is of course in the type conversion. I can confirm it is defined as a long data-type. I put together this patch: However, the Can you please confirm the value of your Do you hit the error check on these systems? I hit it when |
|
Sure @derekmarcotte here is the error msg : Collected EDIT: just saw you meant you want me to test your patch, is that correct ? |
|
Great - thanks, I'll put together another patch, and hopefully a unit test. Are you interesting in testing it when it's ready? Forcing it to 64-bit is going to cause you grief on systems with values lower than 2^31, so I wouldn't suggest it: https://github.com/golang/sys/blob/master/unix/syscall_bsd.go#L518 |
|
Sure I'm ok for testing another patch 👍 Just tested with your previous one : the bufspace value when this error occurs :
|
|
BTW, just reverted to uint64 and this is working with |
|
Sorry if I wasn't clear, this is expected. The next patch I post will support both. This works okay on your machines with value greater than 2^31 though? |
|
Unfortunately, I've to wait tomorrow pm for additional tests. |
|
Yup, here's the culprit: https://github.com/freebsd/freebsd/blob/releng/10.3/sys/kern/vfs_bio.c#L338 So it'll return a long, if the data is greater than long. Forcing bsdSysctlTypeUint64 is valid on amd64, but not on i386. Patch forthcoming. ;) |
|
This should do it: |
|
Thanks @derekmarcotte ! I'll test that patch a couple of hours and tell you if anything goes wrong. Anyway, great work on that issue. |
|
@derekmarcotte this working as expected. How do you want to proceed next ? closing this PR and using yours instead ? |
|
Works for me, if it works for you? |
|
Closing this PR. See a better approach on #712 |
Under some condition[1], it is possible to hit a memory allocation failure when retrieving the
buffer_bytesviasysctl().Adding the
dataTypeseems to fix this issue.[1] happened on a heavy memory loaded FreeBSD 10.3R