Skip to content

small memleak on RedisAI_ReplicateTensorSet #280

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
filipecosta90 opened this issue Feb 20, 2020 · 2 comments · Fixed by #296
Closed

small memleak on RedisAI_ReplicateTensorSet #280

filipecosta90 opened this issue Feb 20, 2020 · 2 comments · Fixed by #296

Comments

@filipecosta90
Copy link
Collaborator

23935:signal-handler (1582162549) Received SIGTERM scheduling shutdown...
23935:M 20 Feb 2020 01:35:49.688 # User requested shutdown...
23935:M 20 Feb 2020 01:35:49.690 # Redis is now ready to exit, bye bye...
==23935== 
==23935== HEAP SUMMARY:
==23935==     in use at exit: 10,913,506 bytes in 212,812 blocks
==23935==   total heap usage: 1,262,259 allocs, 1,049,447 frees, 972,008,416 bytes allocated
==23935== 
==23935== 4 bytes in 1 blocks are definitely lost in loss record 42 of 125,246
==23935==    at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23935==    by 0x144D38: zmalloc (zmalloc.c:99)
==23935==    by 0x144F83: zstrdup (zmalloc.c:210)
==23935==    by 0x1C7006: RM_Strdup (module.c:352)
==23935==    by 0x16EF2140: RAI_ModelCreateTF (tensorflow.c:312)
==23935==    by 0x67E69A7: RAI_ModelCreate (model.c:195)
==23935==    by 0x67D784B: RedisAI_ModelSet_RedisCommand (redisai.c:620)
==23935==    by 0x1C76BE: RedisModuleCommandDispatcher (module.c:575)
==23935==    by 0x13D315: call (server.c:2468)
==23935==    by 0x13DFCA: processCommand (server.c:2763)
==23935==    by 0x14F086: processInputBuffer (networking.c:1470)
==23935==    by 0x14F1DB: processInputBufferAndReplicate (networking.c:1505)
==23935== 
==23935== 45 bytes in 2 blocks are definitely lost in loss record 84,708 of 125,246
==23935==    at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23935==    by 0x144D38: zmalloc (zmalloc.c:99)
==23935==    by 0x1531CF: createEmbeddedStringObject (object.c:85)
==23935==    by 0x15332B: createStringObject (object.c:121)
==23935==    by 0x1C81ED: RM_CreateString (module.c:904)
==23935==    by 0x1C838F: RM_CreateStringFromLongLong (module.c:943)
==23935==    by 0x67D8B57: RedisAI_ReplicateTensorSet (redisai.c:814)
==23935==    by 0x67D9395: RedisAI_Run_Reply (redisai.c:900)
==23935==    by 0x1CE072: moduleHandleBlockedClients (module.c:3895)
==23935==    by 0x13A84E: beforeSleep (server.c:1412)
==23935==    by 0x1344EB: aeMain (ae.c:500)
==23935==    by 0x141FD3: main (server.c:4234)
==23935== 
==23935== LEAK SUMMARY:
==23935==    definitely lost: 49 bytes in 3 blocks
==23935==    indirectly lost: 0 bytes in 0 blocks
==23935==      possibly lost: 59,069 bytes in 1,455 blocks
==23935==    still reachable: 2,801,134 bytes in 65,299 blocks
==23935==                       of which reachable via heuristic:
==23935==                         stdstring          : 2,230,900 bytes in 56,726 blocks
==23935==                         newarray           : 4,480 bytes in 10 blocks
==23935==         suppressed: 8,053,254 bytes in 146,055 blocks
==23935== Reachable blocks (those to which a pointer was found) are not shown.
==23935== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23935== 
==23935== For counts of detected and suppressed errors, rerun with: -v
==23935== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 1 from 1)
	bad exit code for serverId 1
	Redis did not exit cleanly
basic_tests:test_run_mobilenet_multiproc
@filipecosta90 filipecosta90 self-assigned this Feb 20, 2020
@lantiga
Copy link
Contributor

lantiga commented Feb 20, 2020

The first leak is fixed in #289.

The second leak is trickier. The fix would be

e7649d1#diff-0690077a8c4bfac39c6905d86c79df47R820

if AutoMemory wasn't set. In fact, including this code causes Redis to crash for attempting to deallocate twice.

This is called from the callback of a blocking command. I'm wondering if this is something related to the Redis module infrastructure itself.

@filipecosta90
Copy link
Collaborator Author

@lantiga this will be solved on #296 .
we we're missing RedisModule_FreeString.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants