On Sun, Jan 26, 2025 at 10:28:01PM +0100, Chris Hofstaedtler wrote:
> > This being inside a quite default sbuild+unshare setup.
> 
> >From what I can tell libfolio crashes in its static initializer
> because getaddrinfo fails, and then it tries to deallocate the
> results of getaddrinfo, but there were no results, so it frees an
> invalid pointer.
> 
> 
> #0  0x0000ffffa12fcae4 in __GI_freeaddrinfo (ai=0xffff00000001) at 
> ./nss/getaddrinfo.c:2626
> #1  0x0000ffffa1ac9758 [PAC] in folia::get_fqdn[abi:cxx11]() () at 
> ./src/folia_utils.cxx:709
>         result = "unknown"
>         hints = {ai_flags = 2, ai_family = 0, ai_socktype = 1, ai_protocol = 
> 0, ai_addrlen = 0, ai_addr = 0x0, ai_canonname = 0x0, ai_next = 0x0}
>         info = 0xffff00000001
>         gai_result = <optimized out>
>         hostname = "sbuild\000\000\020", '\000' <repeats 15 times>, 
> "*\001:\001%\000\000\000\220\205<\241\377\377\000\000\001", '\000' <repeats 
> 15 times>, "\001", '\000' <repeats 15 times>, 
> "\001\000\000\000\377\377\000\000\220\027\370\241\377\377\000\000\360A\205\310\377\377\000\000\\e\365\241\377\377w\000PA\205\310\377\377\000\000\370\v\365\241\377\377e\000:\242c\241\377\377\000\000\000\200\370\241\377\377\000\000\214Ia\241\377\377\000\0000Za\241\377\377\000\0000\022\370\241\377\377\000\000ȝ\263\241\377\377\000\0000\022\370\241\377\377\000\000(B\205\310\377\377\000\000$B\205\310\377\377\000\000\260A\205\310\377\377\000\000P"...
>         p = <optimized out>

I spoke too soon. Installing gdb hides the problem.

> 
> So what gets called is:
> 
> 1) Static initializer in folia_properties.cxx: static initializer i;
> 2) Constructor of that calls get_fqdn()
> 3) get_fqdn in folia_utils.cxx calls gethostname, which probably fails, and 
> falls back to hostname "unknown"
This succeeds. "unknown" is visible in the backtrace because the
variable "result" is always initialized to this name, but it
doesn't get used.

> 4) get_fqdn calls getaddrinfo for the hostname "unknown" and service "http"

It uses the hostname "sbuild"; this is correct.

> 4) This getaddrinfo call predictably fails

This is where it gets tricky. The real problem is resolving the
service name "http" to port 80. This works once you have gdb
installed, because gdb (indirectly?) Depends: netbase, which
installs /etc/services. This file is necessary for getaddrinfo to
make the lookup "http" -> 80.

Reproducing should be easy even if you have gdb installed by
deleting /etc/services. I can confirm that having /etc/services (as
installed by netbase) makes the crash go away.

> 5) Line 709 calls freeaddrinfo on res, but I highly doubt res can be valid 
> here
> 6) you get a crash inside glibc
> 
> Don't know why it built on x86-conova-02 for i386.

Still unclear to me.

Might be a good idea to zero-initialize the "info" pointer.

Chris

-- 
debian-science-maintainers mailing list
debian-science-maintainers@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/debian-science-maintainers

Reply via email to