Subject: 26.3; sigsegv when using nss-docker
From: Hans van den Bogert <[email-masked]>
To: [email-masked]
Date: Tue, 30 Jun 2020 12:13:24 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Dear Bug squashers,

To reproduce, have 'nss-docker'[1] installed. This library can be added to
nsswitch.conf to intercept .docker host requests.
I have not had other problematic programs icw nss-docker.

Since emacs 26, and most likely due to it's premiered use of
multi-threadedness, a simple `m-x list-packages`, with multiple repos
configured (e.g. gnu, melpa), will crash with sigsegv with high
probability.

I am not well-versed enough in debugging multithreaded emacs to conclude
if this is a problem in emacs or nss-docker. But to iterate, since I
have not encountered this at all with other programs, I'll start at
emacs.

Thanks in advance for any effort,

Hans

[1] https://github.com/dex4er/nss-docker

Starting program: /usr/bin/emacs -u /tmp
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffdb75b700 (LWP 26156)]
[New Thread 0x7fffdaa77700 (LWP 26157)]
[New Thread 0x7fffd9fdc700 (LWP 26158)]
[New Thread 0x7fffd8f51b40 (LWP 26232)]
[New Thread 0x7fffd8cffb40 (LWP 26233)]
NSS DEBUG: Called _nss_debug_gethostbyname4_r with args (name: 
elpa.gnu.org)
NSS DEBUG: Called _nss_debug_gethostbyname4_r with args (name: 
stable.melpa.org)
[New Thread 0x7fffd8f39b40 (LWP 26234)]
_nss_docker_gethostbyname2_r(name="elpa.gnu.org", af=10)
_nss_docker_gethostbyname2_r(name="stable.melpa.org", af=10)
_nss_docker_gethostbyname3_r(name="elpa.gnu.org", af=10)
_nss_docker_gethostbyname2_r(name="elpa.gnu.org", af=2)
NSS DEBUG: Called _nss_debug_gethostbyname4_r with args (name: orgmode.org)
_nss_docker_gethostbyname3_r(name="elpa.gnu.org", af=2)

Thread 6 "emacs" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd8cffb40 (LWP 26233)]
0x00007fffd8aafcd5 in _nss_docker_gethostbyname3_r 
(name=0x2e6f732e312e302d ,
af=2002936162, result=0x6e672d78756e696c, buffer=0x2d34365f3638782f ,
buflen=7091318039310988591, errnop=0x312e6f732e312e, 
herrnop=0x302d77626162696c, ttlp=0x302e6f732e6563, 
canonp=0x697672657373746e)
at libnss_docker.c:72
72 ) {
(gdb) bt full
#0 0x00007fffd8aafcd5 in _nss_docker_gethostbyname3_r 
(name=0x2e6f732e312e302d , af=2002936162, result=0x6e672d78756e696c, 
buffer=0x2d34365f3638782f , buflen=7091318039310988591, 
errnop=0x312e6f732e312e, herrnop=0x302d77626162696c, 
ttlp=0x302e6f732e6563, canonp=0x697672657373746e)
at libnss_docker.c:72
name_len = 3414407380873671541
hostname = 
"86_64-linux-gnu/libX11-xcb.so\000libXxf86vm.so.1\000/usr/lib/x86_64-linux-gnu/libXxf86vm.so.1\000libXxf86vm.so.1\000/usr/lib/i386-linux-gnu/libXxf86vm.so.1\000libXxf86vm.so\000/usr/lib/x86_64-linux-gnu/libXxf86vm.so\000li"...
hostname_suffix_ptr = 0x312e6f732e616162
docker_api_addr =
{sun_family = 12593, sun_path = 
".so.6\000libX11.so.6\000/usr/lib/i386-linux-gnu/libX11.so.6\000libX11.so\000/usr/lib/x86_64-linux-gnu/libX11.so\000libX11-x"}
docker_api_addr_len = 1869819507
buffer_size = 3346019690390575202
buffer_offset = 7795575320214437942
sockfd = 788541486
req_message_buffer = 
"86_64-linux-gnu/libX11-xcb.so.1\000libX11-xcb.so.1\000/usr/lib/i386-linux-gnu/libX11-xcb.so.1\000libX11-xcb.so\000/usr/lib"
req_message_len = 7596498840077020928
res_message_buffer = Python Exception value requires 102400 bytes, which 
is more than max-value-size:
#1 0x00007fffd8ab0518 in _nss_docker_gethostbyname2_r (name=0x3ba8368 
"stable.melpa.org", af=10, result=0x7fffd8cfe7d0, buffer=0x7fffd8cfea40 
"\377\002", buflen=1024, errnop=0x7fffd8cff948, herrnop=0x7fffd8cff9ac) 
at libnss_docker.c:340
#2 0x00007fffebf70f9f in gaih_inet (name=name@entry=0x3ba8368 
"stable.melpa.org", service=, req=req@entry=0x3ba8338, 
pai=pai@entry=0x7fffd8cfe9c8, naddrs=naddrs@entry=0x7fffd8cfe9c4, 
tmpbuf=tmpbuf@entry=0x7fffd8cfea30) at ../sysdeps/posix/getaddrinfo.c:873
th = {h_name = 0x0, h_aliases = 0x0, h_addrtype = 0, h_length = 0, 
h_addr_list = 0x0}
localcanon = 0x0
fct = 0x7fffd8ab04a4 <_nss_docker_gethostbyname2_r>
fct4 =
pat = 0x7fffd8cfe7b8
no_inet6_data = 0
nip = 0x2c5eb30
status =
no_more = 0
no_data = 0
inet6_status = NSS_STATUS_UNAVAIL
res_ctx = 0x7fffc8000b20
res_enable_inet6 =
tp =
st = 0x7fffd8cfe6f0
at = 0x7fffd8cfe6b0
got_ipv6 = false
canon = 0x0
orig_name = 0x3ba8368 "stable.melpa.org"
alloca_used =
port =
malloc_name = false
addrmem = 0x0
canonbuf = 0x0
result = 0
#3 0x00007fffebf72ce4 in __GI_getaddrinfo (name=, service=, 
hints=0x3ba8338, pai=pai@entry=0x3ba8318)
at ../sysdeps/posix/getaddrinfo.c:2300
tmpbuf =
{data = 0x7fffd8cfea40, length = 1024, __space = {__align = 
{__max_align_ll = 767, __max_align_ld = 5.1301383008835767187e-4937}, 
__c = "\377\002", '\000' , 
"\002@\352\317\330\377\177\000\000\000\000\000\000\000\000\000\000ff02::2\000ip6-allrouters", 
'\000' , 
"v\352\317\330\377\177\000\000\000\000\000\000\000\000\000\000ts\n", 
'\000' ...}}
i = 0
last_i = 0
nresults = 0
p = 0x0
gaih_service = {name = 0x3ba8379 "443", num = 443}
pservice =
local_hints =
{ai_flags = 0, ai_family = 0, ai_socktype = 0, ai_protocol = 0, 
ai_addrlen = 0, ai_addr = 0x0, ai_canonname = 0x0, ai_next = 0x0}
in6ai = 0x0
in6ailen = 0
seen_ipv4 = false
seen_ipv6 = false
check_pf_called = false
end = 0x7fffd8cfe9c8
naddrs = 0
__PRETTY_FUNCTION__ = "getaddrinfo"
#4 0x00007fffecb5a058 in handle_requests (arg=) at gai_misc.c:317
req = 0x3ba8300
srchp =
lastp =
runp = 0x3d84690
---Type to continue, or q to quit---xbackq
__PRETTY_FUNCTION__ = "handle_requests"
#5 0x00007fffecd646db in start_thread (arg=0x7fffd8cffb40) at 
pthread_create.c:463
pd = 0x7fffd8cffb40
now =
unwind_buf =
{cancel_jmp_buf = {{jmp_buf = {140736830896960, -2868501273485909582, 
140736830894080, 0, 64505488, 140737488329792, 2868433241719562674, 
2868459701649662386}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 
0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call =
#6 0x00007fffebf8c88f in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) xbacktrace
Undefined command: "xbacktrace". Try "help".

In GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
of 2019-09-16 built on lcy01-amd64-030
Windowing system distributor 'The X.Org Foundation