pupnp avoid select() for sockets
select()
uses FD_SET() that can lead to random crashes unrelated to the number of files authorized per process.
This is used by pupnp
, this may result in some backtraces like:
*** buffer overflow detected ***: terminated
Thread 242 "jami" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffe6cf81640 (LWP 246791)]
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140730726618688) at ./nptl/pthread_kill.c:44
44 ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140730726618688)
at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=140730726618688) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=140730726618688, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007ffff2442476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007ffff24287f3 in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007ffff24896f6 in __libc_message
(action=action@entry=do_abort, fmt=fmt@entry=0x7ffff25db943 "*** %s ***: terminated\n")
at ../sysdeps/posix/libc_fatal.c:155
#6 0x00007ffff253676a in __GI___fortify_fail
(msg=msg@entry=0x7ffff25db8e9 "buffer overflow detected") at ./debug/fortify_fail.c:26
#7 0x00007ffff25350c6 in __GI___chk_fail () at ./debug/chk_fail.c:28
#8 0x00007ffff25366ab in __fdelt_chk (d=<optimized out>) at ./debug/fdelt_chk.c:25
#9 0x00007ffff3961625 in sock_read_write
(info=info@entry=0x7ffe6cf7aa00, buffer=0x7fff854dc120 "GET /dyndev/uuid:2d27b940-da93-441d-b519-acf1fbd1d460 HTTP/1.1\r\nHOST: 192.168.1.1:5431\r\nDATE: Tue, 11 Jul 2023 16:38:42 GMT\r\nCONNECTION: close\r\nUSER-AGENT: Linux/5.19.0-46-generic, UPnP/1.0, Portable "..., bufsize=bufsize@entry=232, timeoutSecs=timeoutSecs@entry=0x7ffe6cf7a9ec, bRead=bRead@entry=0) at src/genlib/net/sock.c:187
#10 0x00007ffff396183c in sock_write
(info=info@entry=0x7ffe6cf7aa00, buffer=<optimized out>, bufsize=bufsize@entry=232, timeoutSecs=timeoutSecs@entry=0x7ffe6cf7a9ec) at src/genlib/net/sock.c:292
#11 0x00007ffff396480c in http_SendMessage
(info=info@entry=0x7ffe6cf7aa00, TimeOut=TimeOut@entry=0x7ffe6cf7a9ec, fmt=0x7ffff44dda77 "",
fmt@entry=0x7ffff44dda76 "b") at src/genlib/net/http/httpreadwrite.c:698
#12 0x00007ffff3964913 in http_RequestAndResponse
(destination=destination@entry=0x7ffe6cf7ab10, request=0x7fff854dc120 "GET /dyndev/uuid:2d27b940-da93-441d-b519-acf1fbd1d460 HTTP/1.1\r\nHOST: 192.168.1.1:5431\r\nDATE: Tue, 11 Jul 2023 16:38:42 GMT\r\nCONNECTION: close\r\nUSER-AGENT: Linux/5.19.0-46-generic, UPnP/1.0, Portable "..., request_length=232, req_method=req_method@entry=HTTPMETHOD_GET, timeout_secs=<optimized out>,
timeout_secs@entry=30, response=response@entry=0x7ffe6cf7abe0)
at src/genlib/net/http/httpreadwrite.c:788
#13 0x00007ffff3965eb0 in http_Download
(url_str=<optimized out>, timeout_secs=timeout_secs@entry=30, document=document@entry=0x7ffe6cf7ae48, doc_length=doc_length@entry=0x7ffe6cf7ae20, content_type=content_type@entry=0x7ffe6cf7ae50 "\006") at src/genlib/net/http/httpreadwrite.c:897
#14 0x00007ffff39574d0 in UpnpDownloadUrlItem
(url=<optimized out>, outBuf=outBuf@entry=0x7ffe6cf7ae48, contentType=contentType@entry=0x7ffe6cf7ae50 "\006") at src/api/upnpapi.c:3500
#15 0x00007ffff3957545 in UpnpDownloadXmlDoc (url=<optimized out>, xmlDoc=0x7ffe6cf7af48)
at src/api/upnpapi.c:3519
#16 0x00007ffff327342e in jami::upnp::PUPnP::downLoadIgdDescription(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
(this=0x7fff9c001f00, locationUrl="http://192.168.1.1:5431/dyndev/uuid:2d27b940-da93-441d-b519-acf1fbd1d460") at connectivity/upnp/protocol/pupnp/pupnp.cpp:840
#17 0x00007ffff3272ce3 in operator()() const (__closure=0x7fff9c015f50)
at connectivity/upnp/protocol/pupnp/pupnp.cpp:831
#18 0x00007ffff327cf16 in std::__invoke_impl<void, jami::upnp::PUPnP::processDiscoverySearchResult(const string&, const string&, const jami::IpAddr&)::<lambda()>&>(std::__invoke_other, struct {...} &)
(__f=...) at /usr/include/c++/11/bits/invoke.h:61
#19 0x00007ffff327b883 in std::__invoke_r<void, jami::upnp::PUPnP::processDiscoverySearchResult(const string&, const string&, const jami::IpAddr&)::<lambda()>&>(struct {...} &) (__fn=...)
at /usr/include/c++/11/bits/invoke.h:111
--Type <RET> for more, q to quit, c to continue without paging--
#20 0x00007ffff327a739 in std::_Function_handler<void(), jami::upnp::PUPnP::processDiscoverySearchResult(const string&, const string&, const jami::IpAddr&)::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/11/bits/std_function.h:290
#21 0x00007ffff38118a7 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<dht::ThreadPool::run(std::function<void ()>&&)::{lambda()#1}> > >::_M_run() ()
at /home/sblin/Projects/jami-project/client-qt/daemon/src/.libs/libjami.so.0
#22 0x00007ffff28dc2b3 in () at /lib/x86_64-linux-gnu/libstdc++.so.6
#23 0x00007ffff2494b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#24 0x00007ffff2526a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb)
Instead of this, it should use poll()
to avoid this kind of limitation.