Skip to content

Conversation

@enjoy-binbin
Copy link
Contributor

@enjoy-binbin enjoy-binbin commented Jun 10, 2022

When /proc/sys/vm/overcommit_memory is inaccessible, fp is NULL.
checkOvercommit will return -1 without setting err_msg, and then
the err_msg is used to print the log, crash the server.
Set the err_msg variables to Null when declaring it, seems safer.

And the overcommit_memory error log will print two "WARNING",
like WARNING WARNING overcommit_memory is set to 0!, this PR
also removes the second WARNING in checkOvercommit.

Reported in #10846. Fixes #10846. Introduced in #10636 (7.0.1)

When `/proc/sys/vm/overcommit_memory` is inaccessible, fp is NULL.
`checkOvercommit` will return -1 without setting err_msg, and then
the err_msg is used to print the log, crash the server.

And the overcommit_memory error log will print two "WARNING",
like `WARNING WARNING overcommit_memory is set to 0!`, this PR
also removes the second WARNING in `checkOvercommit`.

Reported in redis#10846. Fixes redis#10846
@enjoy-binbin
Copy link
Contributor Author

enjoy-binbin commented Jun 10, 2022

btw, should we add a ":" after WARNING?

- serverLog(LL_WARNING,"WARNING %s", err_msg);
+ serverLog(LL_WARNING,"WARNING: %s", err_msg);

the log will look like (in this PR, after patch #10841):

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

@oranagra
Copy link
Member

I a suggest to also set the error message variable to null when declaring it, seems safer.

@oranagra oranagra added release-notes indication that this issue needs to be mentioned in the release notes 7.0-must-have labels Jun 11, 2022
@oranagra oranagra merged commit 62ac1ab into redis:unstable Jun 11, 2022
@enjoy-binbin enjoy-binbin deleted the fix_crash_when_overcommit_memory_is_inaccessible branch June 12, 2022 02:40
@oranagra oranagra mentioned this pull request Jun 12, 2022
@jtru
Copy link
Contributor

jtru commented Jun 12, 2022

Afaict, this fix (for another problem altogether) does not address the bug my PR #10841 fixes. It should have been/should be in 7.0.2, too.

enjoy-binbin added a commit to enjoy-binbin/redis that referenced this pull request Jul 31, 2023
When `/proc/sys/vm/overcommit_memory` is inaccessible, fp is NULL.
`checkOvercommit` will return -1 without setting err_msg, and then
the err_msg is used to print the log, crash the server.
Set the err_msg variables to Null when declaring it, seems safer.

And the overcommit_memory error log will print two "WARNING",
like `WARNING WARNING overcommit_memory is set to 0!`, this PR
also removes the second WARNING in `checkOvercommit`.

Reported in redis#10846. Fixes redis#10846. Introduced in redis#10636 (7.0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[CRASH] redis 7.0.1 crashes on start after upgrading from 7.0.0

3 participants