Skip to content

Commit c57cc7e

Browse files
Dengguangxingavagin
Dengguangxing
authored andcommitted
fix segmentation fault caused by uninitialized mutex
Segmentation fault was raised while trying to restore a process with tty. Coredump file says this is caused by uninitialized tty_mutex: (gdb) where #0 0x00000000004d7270 in atomic_add_return (i=1, v=0x0) at include/common/asm/atomic.h:34 #1 0x00000000004d7398 in mutex_lock (m=0x0) at include/common/lock.h:151 #2 0x00000000004d840c in __pty_open_ptmx_index (index=3, flags=2, cb=0x4dce50 <open_pty>, arg=0x11, path=0x5562e0 "ptmx") at criu/tty.c:603 #3 0x00000000004dced8 in pty_create_ptmx_index (dfd=17, index=3, flags=2) at criu/tty.c:2384 since init_tty_mutex() is reentrantable, just calling it before mutex_lock() Signed-off-by: Deng Guangxing <[email protected]> Reviewed-by: Cyrill Gorcunov <[email protected]> Signed-off-by: Andrei Vagin <[email protected]>
1 parent 8ff73c8 commit c57cc7e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

criu/tty.c

+3
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@ static int __pty_open_ptmx_index(int index, int flags,
600600

601601
memset(fds, 0xff, sizeof(fds));
602602

603+
if (init_tty_mutex())
604+
return -1;
605+
603606
mutex_lock(tty_mutex);
604607

605608
for (i = 0; i < ARRAY_SIZE(fds); i++) {

0 commit comments

Comments
 (0)