xrdp-sesman deadlock on fork
Status: Beta
Brought to you by:
jsorg71
Hi,
i've encountered some problems with the xrdp-sesman process having a deadlock when forking (when creating a new xrdp-sessvc process).
The problem is related to the localtime function which is called in the log_message function.
The backtrace looks like this:
#0 0x0000003e14aefd2b in __lll_lock_wait_private () from /lib64/libc.so.6^M
#1 0x0000003e14a9c62c in _L_lock_2194 () from /lib64/libc.so.6^M
#2 0x0000003e14a9c467 in __tz_convert () from /lib64/libc.so.6^M
#3 0x00007fd835f0641c in log_message (l_cfg=0x2489bb0, lvl=3, ^M
msg=0x408c40 "starting xrdp-sessvc - xpid=%s - wmpid=%s") at log.c:127^M
#4 0x00000000004051de in session_start_sessvc (width=1904, height=1002, ^M
bpp=16, username=0x7fd8280dd7b0 "xyz", ^M
password=0x7fd8280de060 "", data=140566361669088, type=2 '\002', ^M
program=0x7fd8280ddf20 "/home/xyz/.xsession", directory=0x0, ^M
client_ip=0x7fd8280de5c0 "10.146.21.51:49176 - socket: 9", ^M
domain=<value optimized out>) at session.c:235^M
#5 session_start_fork (width=1904, height=1002, bpp=16, ^M
username=0x7fd8280dd7b0 "xyz", password=0x7fd8280de060 "", ^M
data=140566361669088, type=2 '\002', ^M
program=0x7fd8280ddf20 "/home/xyz/.xsession , directory=0x0, ^M
This is because of the fork and __tz_convert not beeing thread safe / reentrant (google for __tz_convert + lock). So probably, there should be as few function calls as possible between fork and exec and none to functions that are not thread safe/ reentrant.
I made a hack/patch to the program so there will be no calls to localtime during the fork. Do you have any better idea to do this?
Steven