Repository navigation
Fix: case when SPOP with count>MAXINT, setTypeRandomElements() will get ... - #2224
Conversation
…et negative count argument due to signed/unsigned mismatch. setTypeRandomElements() now returns unsigned long, and also uses unsigned long for anything related to count of members. spopWithCountCommand() now uses unsigned long elements_returned instead of int, for values returned from setTypeRandomElements()
Fix: case when SPOP with count>MAXINT, setTypeRandomElements() will get ...
|
Thanks, merged. |
|
The code still needs a lot of cleanup. It's causing memory leaks and has many style problems (end-of-line spaces all over the place, for loops look weird, comments have wrong format, etc). Probably shouldn't have been merged so quickly. 🎄 examples: ==4956== 256 bytes in 16 blocks are definitely lost in loss record 302 of 387
==4956== at 0x48DBA3: je_malloc (jemalloc.c:944)
==4956== by 0x4257BD: zmalloc (zmalloc.c:125)
==4956== by 0x42DD77: createObject (object.c:40)
==4956== by 0x42E165: createIntsetObject (object.c:207)
==4956== by 0x43D533: spopWithCountCommand (t_set.c:542)
==4956== by 0x43D78C: spopCommand (t_set.c:602)
==4956== by 0x4200ED: call (redis.c:2048)
==4956== by 0x422F8E: processCommand (redis.c:2308)
==4956== by 0x42CC7E: processInputBuffer (networking.c:1135)
==4956== by 0x42CDB1: readQueryFromClient (networking.c:1200)
==4956== by 0x41AD92: aeProcessEvents (ae.c:412)
==4956== by 0x41B0AA: aeMain (ae.c:455)==8719== 16 bytes in 1 blocks are definitely lost in loss record 75 of 355
==8719== at 0x48DBA3: je_malloc (jemalloc.c:944)
==8719== by 0x4257BD: zmalloc (zmalloc.c:125)
==8719== by 0x42DD77: createObject (object.c:40)
==8719== by 0x42E165: createIntsetObject (object.c:207)
==8719== by 0x43D533: spopWithCountCommand (t_set.c:542)
==8719== by 0x43D78C: spopCommand (t_set.c:602)
==8719== by 0x44E169: loadAppendOnlyFile (aof.c:685)
==8719== by 0x423D9B: loadDataFromDisk (redis.c:3556)
==8719== by 0x419CCF: main (redis.c:3753)==11174== 64 bytes in 1 blocks are definitely lost in loss record 230 of 353
==11174== at 0x48DBA3: je_malloc (jemalloc.c:944)
==11174== by 0x4257BD: zmalloc (zmalloc.c:125)
==11174== by 0x438739: rdbSaveToSlavesSockets (rdb.c:1472)
==11174== by 0x433DC9: startBgsaveForReplication (replication.c:452)
==11174== by 0x434A3D: replicationCron (replication.c:2083)
==11174== by 0x4208FC: serverCron (redis.c:1235)
==11174== by 0x41AE8D: aeProcessEvents (ae.c:311)
==11174== by 0x41B0AA: aeMain (ae.c:455)
==11174== by 0x419D5E: main (redis.c:3776) |
|
The first two leaks are I believe due to the fact that The final leak is unrelated to this commit, but rather was introduced when diskless replication was merged. This one is due to the fact that 🔬 |
|
Good catch! We do have tests running at http://ci.redis.io/, but it doesn't send out alerts to anybody, so we don't know when things are broken. 💔 Are you sure about the second one? The "redis-unstable-valgrind" section of http://ci.redis.io/ shows all the errors began with 70674ac, but the edit: the Maybe old versions of something on the mysterious CI sever? |
|
Yeah to be honest I'm not 100% on the second one, it just looks like a leak to me from a cursory inspection (zmalloc but no correpsonding free that I can see). |
|
Hi all, Some points:
That being said: a. I created a new Pull Request #2229 with fixes to all of the issues that @mattsta has raised. All tests pass with flying colours, with valgrind enabled. I suggest: (i) The Makefile will be modified to always build with -Wextra. Let me know if anything else requires fixing. Thank you for the comments. |
|
Thanks for the cleanup!
I just mentioned the errors again because I thought this PR had fixed the previous issues already. There was a mention of "Cleaned it up as per the Redis required coding style." pointing to this PR. :) Not a big problem. The feature somehow skipped "review" and went direct to "merge," which seemed odd. I've had every one of your same complaints before too (mysterious hidden CI server, contributors don't have a way of knowing what's good/bad, test suite usage undocumented, etc) but, as we've mentioned, we don't yet have guidelines for any of these things.
Good suggestions! I don't really know why we don't use -Wextra. I compile my travis tests with -Werror too. and, we should have a 'make test-valgrind' target (and accompanying As far as coding style, the simplest fix is to run |
|
@advance512 Thank you for your additional commits! FWIW I took a quick peek and they look good to me. Also you found a second leak! 😺 It's not a small thing getting something into Redis proper, and this is a great addition that will be useful to a lot of people. Cheers! |
|
I made my remarks about "scaring off" potential future contributors after seeing what happened with other projects. A good example is the Parrot VM that just withered away and died with bad developer attitudes. But: no harm, no foul. I understand the need for maintaining style standards (though my personal style is quite different), and obviously to prevent memory leaks! To make this more constructive and useful for future contributors, I will try and change the existing Makefile to compile with -Wextra and add the the test-valgrind target (as suggested by @mattsta). Adding some general guidelines and best practices to the CONTRIBUTING file would also be a good idea. As for clag-format - if it will be used by all contributors prior to every submission, great. Otherwise, as you say, the formatting changes will mask the actual code changes in the commits. How about a bot that clang-formats the entire project automatically every day/week? Once again, I thank you for your constructive feedback. |
I see what you did there.
Those LLVM people are way too smart to let that happen. They have a script called The sad part is, they don't package or release recent versions of After you've checked out and built all of LLVM+Clang and put [clangFormat]
style="{BasedOnStyle: llvm, IndentWidth: 4, AllowShortFunctionsOnASingleLine: None, KeepEmptyLinesAtTheStartOfBlocks: false}"
The other issue is Redis has some files included directly from other sources, so we wouldn't want format those, or else we can't diff from upstream anymore. That just rules out one big
Added to TODO list! (Well, added to the TODO list I keep for prioritizing things to add to the actual TODO list.) |
...negative count argument due to signed/unsigned mismatch.
setTypeRandomElements() now returns unsigned long, and also uses unsigned long for anything related to count of members.
spopWithCountCommand() now uses unsigned long elements_returned instead of int, for values returned from setTypeRandomElements()