Avoid performing IO on coverage when child exits due to signal handler#14072
Merged
ShooterIT merged 8 commits intoredis:unstablefrom May 28, 2025
Merged
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
2 tasks
ShooterIT
reviewed
May 26, 2025
ShooterIT
reviewed
May 26, 2025
Co-authored-by: Yuan Wang <[email protected]>
ShooterIT
approved these changes
May 27, 2025
Member
|
Since this bug happens only when compiling with |
Contributor
@ShooterIT In order to have code coverage for the child fork process, we also need this PR backported to 8.0. |
YaacovHazan
pushed a commit
to YaacovHazan/redis
that referenced
this pull request
Jul 6, 2025
redis#14072) Compiled Redis with COVERAGE_TEST, while using the fork API encountered the following issue: - Forked process calls `RedisModule_ExitFromChild` - child process starts to report its COW while performing IO operations - Parent process terminates child process with `RedisModule_KillForkChild` - Child process signal handler gets called while an IO operation is called - exit() is called because COVERAGE_TEST was on during compilation. - exit() tries to perform more IO operations in its exit handlers. - process gets deadlocked Backtrace snippet: ``` #0 futex_wait (private=0, expected=2, futex_word=0x7e1220000c50) at ../sysdeps/nptl/futex-internal.h:146 #1 __GI___lll_lock_wait_private (futex=0x7e1220000c50) at ./nptl/lowlevellock.c:34 #2 0x00007e1234696429 in __GI__IO_flush_all () at ./libio/genops.c:698 #3 0x00007e123469680d in _IO_cleanup () at ./libio/genops.c:843 #4 0x00007e1234647b74 in __run_exit_handlers (status=status@entry=255, listp=<optimized out>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at ./stdlib/exit.c:129 #5 0x00007e1234647bbe in __GI_exit (status=status@entry=255) at ./stdlib/exit.c:138 #6 0x00005ef753264e13 in exitFromChild (retcode=255) at /home/jonathan/CLionProjects/redis/src/server.c:263 #7 sigKillChildHandler (sig=<optimized out>) at /home/jonathan/CLionProjects/redis/src/server.c:6794 #8 <signal handler called> #9 0x00007e1234685b94 in _IO_fgets (buf=buf@entry=0x7e122dafdd90 "KSM:", ' ' <repeats 19 times>, "0 kB\n", n=n@entry=1024, fp=fp@entry=0x7e1220000b70) at ./libio/iofgets.c:47 #10 0x00005ef75326c5e0 in fgets (__stream=<optimized out>, __n=<optimized out>, __s=<optimized out>, __s=<optimized out>, __n=<optimized out>, __stream=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:200 #11 zmalloc_get_smap_bytes_by_field (field=0x5ef7534c42fd "Private_Dirty:", pid=<optimized out>) at /home/jonathan/CLionProjects/redis/src/zmalloc.c:928 #12 0x00005ef75338ab1f in zmalloc_get_private_dirty (pid=-1) at /home/jonathan/CLionProjects/redis/src/zmalloc.c:978 #13 sendChildInfoGeneric (info_type=CHILD_INFO_TYPE_MODULE_COW_SIZE, keys=0, progress=-1, pname=0x5ef7534c95b2 "Module fork") at /home/jonathan/CLionProjects/redis/src/childinfo.c:71 #14 0x00005ef75337962c in sendChildCowInfo (pname=0x5ef7534c95b2 "Module fork", info_type=CHILD_INFO_TYPE_MODULE_COW_SIZE) at /home/jonathan/CLionProjects/redis/src/server.c:6895 #15 RM_ExitFromChild (retcode=0) at /home/jonathan/CLionProjects/redis/src/module.c:11468 ``` Change is to make the exit() _exit() calls conditional based on a parameter to exitFromChild function. The signal handler should exit without io operations since it doesn't know its history.(If we were in the middle of IO operations before it was called) --------- Co-authored-by: Yuan Wang <[email protected]>
YaacovHazan
pushed a commit
that referenced
this pull request
Jul 6, 2025
#14072) Compiled Redis with COVERAGE_TEST, while using the fork API encountered the following issue: - Forked process calls `RedisModule_ExitFromChild` - child process starts to report its COW while performing IO operations - Parent process terminates child process with `RedisModule_KillForkChild` - Child process signal handler gets called while an IO operation is called - exit() is called because COVERAGE_TEST was on during compilation. - exit() tries to perform more IO operations in its exit handlers. - process gets deadlocked Backtrace snippet: ``` #0 futex_wait (private=0, expected=2, futex_word=0x7e1220000c50) at ../sysdeps/nptl/futex-internal.h:146 #1 __GI___lll_lock_wait_private (futex=0x7e1220000c50) at ./nptl/lowlevellock.c:34 #2 0x00007e1234696429 in __GI__IO_flush_all () at ./libio/genops.c:698 #3 0x00007e123469680d in _IO_cleanup () at ./libio/genops.c:843 #4 0x00007e1234647b74 in __run_exit_handlers (status=status@entry=255, listp=<optimized out>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at ./stdlib/exit.c:129 #5 0x00007e1234647bbe in __GI_exit (status=status@entry=255) at ./stdlib/exit.c:138 #6 0x00005ef753264e13 in exitFromChild (retcode=255) at /home/jonathan/CLionProjects/redis/src/server.c:263 #7 sigKillChildHandler (sig=<optimized out>) at /home/jonathan/CLionProjects/redis/src/server.c:6794 #8 <signal handler called> #9 0x00007e1234685b94 in _IO_fgets (buf=buf@entry=0x7e122dafdd90 "KSM:", ' ' <repeats 19 times>, "0 kB\n", n=n@entry=1024, fp=fp@entry=0x7e1220000b70) at ./libio/iofgets.c:47 #10 0x00005ef75326c5e0 in fgets (__stream=<optimized out>, __n=<optimized out>, __s=<optimized out>, __s=<optimized out>, __n=<optimized out>, __stream=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:200 #11 zmalloc_get_smap_bytes_by_field (field=0x5ef7534c42fd "Private_Dirty:", pid=<optimized out>) at /home/jonathan/CLionProjects/redis/src/zmalloc.c:928 #12 0x00005ef75338ab1f in zmalloc_get_private_dirty (pid=-1) at /home/jonathan/CLionProjects/redis/src/zmalloc.c:978 #13 sendChildInfoGeneric (info_type=CHILD_INFO_TYPE_MODULE_COW_SIZE, keys=0, progress=-1, pname=0x5ef7534c95b2 "Module fork") at /home/jonathan/CLionProjects/redis/src/childinfo.c:71 #14 0x00005ef75337962c in sendChildCowInfo (pname=0x5ef7534c95b2 "Module fork", info_type=CHILD_INFO_TYPE_MODULE_COW_SIZE) at /home/jonathan/CLionProjects/redis/src/server.c:6895 #15 RM_ExitFromChild (retcode=0) at /home/jonathan/CLionProjects/redis/src/module.c:11468 ``` Change is to make the exit() _exit() calls conditional based on a parameter to exitFromChild function. The signal handler should exit without io operations since it doesn't know its history.(If we were in the middle of IO operations before it was called) --------- Co-authored-by: Yuan Wang <[email protected]>
funny-dog
pushed a commit
to funny-dog/redis
that referenced
this pull request
Sep 17, 2025
redis#14072) Compiled Redis with COVERAGE_TEST, while using the fork API encountered the following issue: - Forked process calls `RedisModule_ExitFromChild` - child process starts to report its COW while performing IO operations - Parent process terminates child process with `RedisModule_KillForkChild` - Child process signal handler gets called while an IO operation is called - exit() is called because COVERAGE_TEST was on during compilation. - exit() tries to perform more IO operations in its exit handlers. - process gets deadlocked Backtrace snippet: ``` #0 futex_wait (private=0, expected=2, futex_word=0x7e1220000c50) at ../sysdeps/nptl/futex-internal.h:146 redis#1 __GI___lll_lock_wait_private (futex=0x7e1220000c50) at ./nptl/lowlevellock.c:34 redis#2 0x00007e1234696429 in __GI__IO_flush_all () at ./libio/genops.c:698 redis#3 0x00007e123469680d in _IO_cleanup () at ./libio/genops.c:843 redis#4 0x00007e1234647b74 in __run_exit_handlers (status=status@entry=255, listp=<optimized out>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at ./stdlib/exit.c:129 redis#5 0x00007e1234647bbe in __GI_exit (status=status@entry=255) at ./stdlib/exit.c:138 redis#6 0x00005ef753264e13 in exitFromChild (retcode=255) at /home/jonathan/CLionProjects/redis/src/server.c:263 redis#7 sigKillChildHandler (sig=<optimized out>) at /home/jonathan/CLionProjects/redis/src/server.c:6794 redis#8 <signal handler called> redis#9 0x00007e1234685b94 in _IO_fgets (buf=buf@entry=0x7e122dafdd90 "KSM:", ' ' <repeats 19 times>, "0 kB\n", n=n@entry=1024, fp=fp@entry=0x7e1220000b70) at ./libio/iofgets.c:47 redis#10 0x00005ef75326c5e0 in fgets (__stream=<optimized out>, __n=<optimized out>, __s=<optimized out>, __s=<optimized out>, __n=<optimized out>, __stream=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:200 redis#11 zmalloc_get_smap_bytes_by_field (field=0x5ef7534c42fd "Private_Dirty:", pid=<optimized out>) at /home/jonathan/CLionProjects/redis/src/zmalloc.c:928 redis#12 0x00005ef75338ab1f in zmalloc_get_private_dirty (pid=-1) at /home/jonathan/CLionProjects/redis/src/zmalloc.c:978 redis#13 sendChildInfoGeneric (info_type=CHILD_INFO_TYPE_MODULE_COW_SIZE, keys=0, progress=-1, pname=0x5ef7534c95b2 "Module fork") at /home/jonathan/CLionProjects/redis/src/childinfo.c:71 redis#14 0x00005ef75337962c in sendChildCowInfo (pname=0x5ef7534c95b2 "Module fork", info_type=CHILD_INFO_TYPE_MODULE_COW_SIZE) at /home/jonathan/CLionProjects/redis/src/server.c:6895 redis#15 RM_ExitFromChild (retcode=0) at /home/jonathan/CLionProjects/redis/src/module.c:11468 ``` Change is to make the exit() _exit() calls conditional based on a parameter to exitFromChild function. The signal handler should exit without io operations since it doesn't know its history.(If we were in the middle of IO operations before it was called) --------- Co-authored-by: Yuan Wang <[email protected]>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compiled Redis with COVERAGE_TEST, while using the fork API encountered the following issue:
RedisModule_ExitFromChild- child process starts to report its COW while performing IO operationsRedisModule_KillForkChildBacktrace snippet:
Change is to make the exit() _exit() calls conditional based on a parameter to exitFromChild function.
The signal handler should exit without io operations since it doesn't know its history.(If we were in the middle of IO operations before it was called)