managarm / mlibc

Portable C standard library
Other
851 stars 130 forks source link

Crash inside libc.so when running wget #360

Open 48cf opened 2 years ago

48cf commented 2 years ago

Running inside managarm on managarm/managarm@d1d5afe509ce401d34d79be413b3ba64d22cd765 and on mlibc on managarm/mlibc@afd11daf4565943f8265b2c1ed2a9116e7a4ba4f, sadly I didn't get to test it on any newer commits because managarm refuses to boot on managarm/managarm@b7541786d2e52a94dd19d2108d5639760e0e8b43 :^) I hope it still reproduces though!

(gdb) bt
#0  0x000000004166798b in frg::slab_pool<VirtualAllocator, FutexLock>::free (this=0x1, p=0x7fff61731268) at ../../../src/mlibc/subprojects/frigg/include/frg/slab.hpp:570
#1  0x00000000416945c5 in frg::slab_allocator<VirtualAllocator, FutexLock>::free (pointer=<optimized out>, this=<optimized out>) at ../../../src/mlibc/subprojects/frigg/include/frg/slab.hpp:798
#2  frg::basic_string<char, frg::slab_allocator<VirtualAllocator, FutexLock> >::~basic_string (this=<optimized out>, __in_chrg=<optimized out>) at ../../../src/mlibc/subprojects/frigg/include/frg/string.hpp:160
#3  mlibc::dns_addr_buf::~dns_addr_buf (this=<optimized out>, __in_chrg=<optimized out>) at ../../../src/mlibc/options/posix/include/mlibc/lookup.hpp:15
#4  frg::vector<mlibc::dns_addr_buf, frg::slab_allocator<VirtualAllocator, FutexLock> >::~vector (this=<optimized out>, __in_chrg=<optimized out>) at ../../../src/mlibc/subprojects/frigg/include/frg/vector.hpp:149
#5  mlibc::lookup_result::~lookup_result (this=<optimized out>, __in_chrg=<optimized out>) at ../../../src/mlibc/options/posix/include/mlibc/lookup.hpp:23
#6  getaddrinfo(const char * __restrict__, const char * __restrict__, const addrinfo * __restrict__, addrinfo ** __restrict__) (node=<optimized out>, service=<optimized out>, hints=<optimized out>, res=0x7fffffffeb98)
    at ../../../src/mlibc/options/posix/generic/netdb-stubs.cpp:145
#7  0x0000000000416198 in getaddrinfo_with_timeout_callback (arg=arg@entry=0x7fffffffeba0) at /builder/worker.src/ports/wget/src/host.c:391
#8  0x00000000004337ca in run_with_timeout (timeout=timeout@entry=0, fun=fun@entry=0x416180 <getaddrinfo_with_timeout_callback>, arg=arg@entry=0x7fffffffeba0) at /builder/worker.src/ports/wget/src/utils.c:2160
#9  0x0000000000416664 in getaddrinfo_with_timeout (timeout=0, res=0x7fffffffeb98, hints=0x7fffffffebd0, service=0x0, node=0x7fffff93fff0 "icanhazip.com") at /builder/worker.src/ports/wget/src/host.c:409
#10 lookup_host (host=host@entry=0x7fffff93fff0 "icanhazip.com", flags=flags@entry=0) at /builder/worker.src/ports/wget/src/host.c:910
#11 0x0000000000408e77 in connect_to_host (host=0x7fffff93fff0 "icanhazip.com", port=80) at /builder/worker.src/ports/wget/src/connect.c:394
#12 0x000000000041b2b5 in establish_connection (u=u@entry=0x7fffff8bff00, conn_ref=conn_ref@entry=0x7fffffffee28, hs=hs@entry=0x7fffffffef50, proxy=proxy@entry=0x0, proxyauth=proxyauth@entry=0x7fffffffee20, req_ref=req_ref@entry=0x7fffffffee08, 
    using_ssl=0x7fffffffee02, inhibit_keep_alive=false, sock_ref=0x7fffffffee04) at /builder/worker.src/ports/wget/src/http.c:2123
#13 0x000000000041ddc2 in gethttp (original_url=0x43b2f3 <rpl_free+35>, iri=<optimized out>, count=<optimized out>, proxy=<optimized out>, dt=<optimized out>, hs=0x7fffffffef50, u=<optimized out>) at /builder/worker.src/ports/wget/src/http.c:3329
#14 http_loop (u=u@entry=0x7fffff8bff00, original_url=original_url@entry=0x7fffff8bff00, newloc=newloc@entry=0x7ffffffff6b0, local_file=local_file@entry=0x7ffffffff6b8, referer=referer@entry=0x0, dt=dt@entry=0x7ffffffff760, proxy=<optimized out>, 
    iri=<optimized out>) at /builder/worker.src/ports/wget/src/http.c:4423
#15 0x000000000042b2ba in retrieve_url (orig_parsed=orig_parsed@entry=0x7fffff8bff00, origurl=origurl@entry=0x7fffff6bffa0 "http://icanhazip.com", file=file@entry=0x7ffffffff768, newloc=newloc@entry=0x7ffffffff770, refurl=refurl@entry=0x0, 
    dt=dt@entry=0x7ffffffff760, recursive=false, iri=0x681540 <dummy_iri>, register_status=true) at /builder/worker.src/ports/wget/src/retr.c:983
#16 0x0000000000407221 in main (argc=4, argv=0x7ffffffff838) at /builder/worker.src/ports/wget/src/main.c:2167
no92 commented 2 years ago

As for managarm refusing to boot currently, you'd need to temporarily apply managarm/managarm#406.

48cf commented 2 years ago

After some changes in managarm to get it booting I got this to reproduce on managarm/managarm@86c6cb7b9adbc4e58415468303250d1420edd111 and mlibc on managarm/mlibc@99fc58521c46553f107cdb75121e698466957a4f.

Geertiebear commented 2 years ago

frg::slab_pool<VirtualAllocator, FutexLock>::free (this=0x1, p=0x7fff61731268) looks very concerning..