about summary refs log tree commit homepage
DateCommit message (Collapse)
2022-12-27rproxy: support FreeBSD addr2line unresolved (??) output
FreeBSD addr2line uses `?? at ??:0' for unresolved addresses, so relax the regexp we use for handling unresolved output.
2022-12-27rproxy: have addr2line show inlines and function names
They're useful, IMHO. The ADDR2LINE environment can override it, of course.
2022-12-27rproxy: strip '+' for addr2line on bare addresses
addr2line doesn't understand `+$ADDRESS' always, but `$ADDRESS' is fine.
2022-12-27rproxy: support GNU addr2line via pipe
We can filter the HTML and CSV and run it through addr2line to decode addresses from rproxy. We can't safely run another process inside the embedded mwrap-httpd since that could break `waitpid(-1, ...)' in the code we're being injected into.
2022-12-22tests: quiet down various tests
We can check stderr in more places, avoid unused variable warnings, and drop some debug code. We'll allow the V=1 environment to make curl and rproxy verbose, but verbosity tends to hide problems.
2022-12-21httpd: do not waste TSD space
mwrap-httpd is inherently single-threaded, and the TSD pointer needs to be alotted to every thread. So tie the request pointer to the daemon itself instead of per-thread space. If this were a dedicated multi-threaded httpd, I would be using TSD for this. But this is only a single-threaded embedded httpd with many threads doing completely unrelated things.
2022-12-21httpd: drop persistent connection support
It's not worth the extra complexity, binary size, and icache bloat for a AF_UNIX-only server.
2022-12-21httpd: drop connection if 404 on POST bodies
Persistent connections and undrained input don't mix; so the simplest thing is to drop the persistent connection when we short-circuit out on /$PID/ prefix mismatches. In retrospect, it's probably not worth supporting persistent connections at all for a AF_UNIX-only server...
2022-12-21mymalloc: relicense to LGPL-2.1+
These non-mwrap-specific pieces are candidates for glibc integration. So pick the same license as glibc for these parts.
2022-12-19README: add some caveats (signalfd usage w/ current URCU)
Fortunately, there aren't a lot of signalfd users right now (except me :x). In any case, this problem should sort itself out in a few years when new URCU releases replace old ones. Also, only the EXTREMELY EXPENSIVE ENTERPRISE EDITION will be able to support Perl files with over 16.7M lines in them :P
2022-12-19core: simplify callers of alloc_insert_rcu
We can actually handle all RCU locking/unlocking inside alloc_insert_rcu to simplify callers.
2022-12-19*alloc: limit scope of RCU lock
We can delay taking the RCU lock until the real_malloc() call succeeds. This gives us accurate stats in case of ENOMEM failures and reduces our LoC a bit, too.
2022-12-19calloc: consolidate ENOMEM handling
We can simplify the error paths in calloc and call memset() outside of the RCU critical section.
2022-12-19core: drop FreeBSD-specific mutex initialization
It's no longer needed with our embedded malloc and our non-glibc ensure_initialization() mutex avoidance hack.
2022-12-19core: shrink src_loc by another 8 bytes on x86-64
lineno shouldn't need more than 24-bits (or >= 16.7 million). Our bt_len is capped at 32, and nobody should ever need to care about tracking allocations if call stack depths exceed 256.
2022-12-19core: shrink src_loc 8 bytes on x86-64
We can rely on the stable value of ->loc_hash to assign the mutex at when it requires locking rather than relying on a monotonically increasing counter.
2022-12-16rproxy: more thorough connectivity check
Sometimes, stale sockets can stick around and the PID gets recycled by a different process, so ensure we can actually connect to it before listing it.
2022-12-16httpd: more thorough unlinking of stale sockets
Lets try not to leave stale sockets lying around since they can eat away at inode space.
2022-12-16rproxy: manpage updates
Fix the comment regarding --no-deflate and describe PLACK_ENV, too.
2022-12-16various documentation updates
mwrap_httpd will have online help :>
2022-12-16support symlink install
This is useful for users w/o root permissions.
2022-12-16support changing bt_req_depth dynamically
This is a valuable tuning knob and allows users to forgo restarting an app to change backtrace depth. A /reset is recommended.
2022-12-16make Plack optional
Let's not increase requirements for running this project, since some users will be perfectly fine with curl and CSV output. Furthermore, Plack::Middleware::Deflater is not included in the main Plack distribution, so that requirement should be further separated since it's not required.
2022-12-16avoid -Warray-bounds warning, avoid stack overallocation
Compilers don't like seeing `sl.bt[-1]', so we give backtrace(3) the same address by another means. We'll also save allocating one pointer off the stack by capping the union padding.
2022-12-16httpd: drop TODO item for pipelining
It's not worth it. Arguably, supporting persistent connections for a AF_LOCAL-only daemon is overkill.
2022-12-16httpd: describe simple and naive buffering scheme
Better to have one implementation which works for all clients, since curl may not be as readily available as socat or a naive Perl socket implementation.
2022-12-16rename mwrap_httpd.h to httpd.h
No need to prefix our project name into every individual source file, especially since it's an auxilliary component.
2022-12-16httpd: pause forking thread on resource limitations
We shouldn't abort the program due to resource limitations. Instead, the least intrusive course of action is probably to sleep and wait for other threads in the process to do cleanup work.
2022-12-16mwrap_httpd: do not abort on fork if out-of-resources
Instead, we'll leak memory if the pthread_atfork handlers can't stop httpd at fork due to resource limitations.
2022-12-16rproxy: enable deflater by default
Ideally I want this in the main mwrap_httpd itself, but linking zlib may conflict with whatever an application uses. This will be useful for exposing the demo endpoint for public use.
2022-12-16httpd: support CSV output
CSV is well-supported by SQLite (and many other tools) so it can be useful for offline analysis.
2022-12-16httpd: shrink `mean_life' field to `double'
`long double' is excessive, not necessary, and a waste of RAM and locality.
2022-12-16rproxy: link to mwrap_httpd /$PID/ root without each, too
We'll keep each/2000 linked, but the /$PID/ root may provide a better jumping point.
2022-12-16mymalloc: add notes on the malloc implementation
2022-12-16httpd: drop unnecessary AND ops from base-64
We only use unsigned chars, so we can let truncation do its thing and not overflow.
2022-12-16use uatomic_inc where appropriate
It's slightly more readable IMHO, and perhaps it generates better code on x86 (since URCU has x86-specific paths for it).
2022-12-16mwrap_httpd: add info about src_file and src_loc stats
This can give users some quick info about their application. We'll also show the MWRAP=bt: parameter to hint users about the backtrace depth they expect.
2022-12-16mwrap_httpd: flesh out /$PID/ and /$PID/trim endpoints
I won't be developing Devel::Mwrap::PSGI further since mwrap_httpd is less intrusive and faster.
2022-12-16httpd: avoid newline if not using bt: >= 1
No need to hog up screen space if we're not doing multi-level traces.
2022-12-16httpd: rework httpd to use auto-free for memstream
This helps us avoid memory leaks after OOM.
2022-12-16introduce AUTO_FREE macro to simplify cleanup
Both gcc and clang have had __attribute__((__cleanup__)) for a decade or more. This helps us avoid memory leaks and simplifies our code.
2022-12-16mwrap_httpd: show current bytes consistently
We actually want to read total_bytes_dec before total_bytes_inc to ensure a greater likelyhood of the resulting total being positive (or not underflowed into SIZE_MAX territory)
2022-12-15support MWRAP=bt:$NUM for deeper backtraces
It can be enlightening to see the machine backtrace (not the Perl one) leading up to a particular malloc calls from a Perl function. "/$PID/at/$LOCATION" URLs now use the URL-safe Base 64 location URLs to simplify parsing and reduce URL length for multi-level backtraces. Warning: increasing $NUM leads to large increases in memory usage of mwrap itself. This is due to common malloc wrapper functions (e.g. "Perl_safesysmalloc", "xmalloc") taking up the first stack level while a diverse array of callers occupy higher up ones.
2022-12-12mwrap_httpd: report ftello error
ftello(3) may fail if out-of-memory.
2022-12-12httpd: mw_h1req comment fixes
2022-12-12use `%m' for *printf rather than strerror(errno)
FreeBSD, glibc both support it, as do minimalist libcs such as uClibc and musl.
2022-12-12httpd: consolidate open_memstream error checking
This adds error reporting to a few places where I forgot to print errno on open_memstream failures.
2022-12-12httpd: hoist out err_close from ferror|fclose
A small tweak to simplify error reporting if we have any problems due to OOM or bugs.
2022-12-11use backtrace_symbols_fmt on FreeBSD to emulate glibc output
"'Tis better to emit than to parse" Since FreeBSD has backtrace_symbols_fmt(3) and glibc does not, we'll use the hard-coded glibc backtrace_symbols(3) format. This saves us the trouble of maintaining separate parsers. I consider the default glibc format superior, anyways, since the important piece (%f - filename) is up front, since the %a (address) is process-specific and not useful when viewed from a different process.
2022-12-11t/mwrap-httpd: avoid busy waits for bind+listen
Using a FIFO in Perl means our mwrap_ctor constructor has already run and bound the listen socket. So using it as a synchronization barrier means we can rely on it to ensure the socket is connect-able.