Mark Wielaard [Mon, 8 Nov 2021 08:27:51 +0000 (09:27 +0100)]
libdw: dwarf_elf_begin should use either plain, dwo or lto DWARF sections.
When opening an ELF file that contained a mix of plain, dwo or lto .debug
sections the result could be confusing. Add a check to pick just the plain
.debug sections, or the .dwo sections or the .gnu.debuglto_.debug sections
(in that order of preference). That way there is always a consistent set.
Alexander Miller [Thu, 18 Feb 2021 02:38:56 +0000 (03:38 +0100)]
Improve building with LTO
Use symver attribute for symbol versioning instead of .symver
assembler directive when available. Convert to use double @ syntax
for default version in all cases (required when using the attribute).
Add the attributes externally_visible, no_reorder if available when
using assembler directives to improve the situation for < gcc-10.
This is not 100% reliable, though; -flto-partition=none may still be
needed in some cases.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24498 Signed-off-by: Alexander Miller <alex.miller@gmx.de>
For large databases and many stale files, it was possible to starve
rescan operations by numerous groom "nuke" (database delete ops).
Under the theory that including new data is at least as important as
aging old, we now impose a rough deadline on groom queries.
In the process, we discovered that we were commiting some
undefined-behaviour sqlite ops (deleting rows while iterating), which
may explain some previous heisenbug occurrences. So the groom nuke
operations are split into decision & action phases, with associated
progress-tracking metrics.
Testing the timeout facility requires hand-testing beyond the
testsuite (since it requires LARGE databases to show measurable query
times). So confirmed this part by hand.
Negative cache (000-permission) files were incorrectly treated as
valid cached files for the root user, because root can open even
000-perm files without -EACCES. Corrected this checking sequence.
Fixed the debuginfod testsuite to run to completion as root or
as an ordinary user, correcting corresponding permission checks:
stat -c %A $FILE
is right and
[ -w $FILE] [ -r $FILE ]
were wrong.
Mark Wielaard [Mon, 18 Oct 2021 12:35:20 +0000 (14:35 +0200)]
libdw: Don't pass NULL to dwarf_peel_type
commit c3a6a9dfc "libdw: Use signedness of subrange type to
determine array bounds" introduced a type check on a DIE which
exposed a latent bug in the get_type function. Even if the type
of a DIE couldn't be determined it would call dwarf_peel_type
on it. The gcc undefined sanitizer would flag this as being
undefined behaviour because the second argument of the function
is marked as non-NULL. Fix this by checking we actually have
a non-NULL type DIE.
Mark Wielaard [Wed, 6 Oct 2021 20:41:29 +0000 (22:41 +0200)]
libdw: Use signedness of subrange type to determine array bounds
When calculating the array size check if the subrange has an associate
type, if it does then check the type to determine whether the upper
and lower values need to be interpreted as signed of unsigned
values. We default to signed because that is what the testcase
run-aggregate-size.sh testfile-size4 expects (this is an hardwritten
testcase, we could have chosen a different default).
Mark Wielaard [Fri, 15 Oct 2021 13:16:54 +0000 (15:16 +0200)]
debuginfod-client: Stick to http:// + https:// + file:// protocols
Make sure we don't use any of the more experimental protocols
libcurl might support. URLs can be redirected and we might want
to follow http -> https, but not e.g. gopher or pop3.
Suggested-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> Signed-off-by: Mark Wielaard <mark@klomp.org>
PR27783: switch default debuginfod-urls to drop-in style files
Rewrote and commented the /etc/profile.d csh and sh script fragments
to take the default $DEBUGINFOD_URLS from the union of drop-in files:
/etc/debuginfod/*.urls. Hand-tested with csh and bash, with
conditions including no prior $DEBUGINFOD_URLS, nonexistent .urls
files, multiple entries in .urls files.
William Cohen [Wed, 29 Sep 2021 18:56:15 +0000 (14:56 -0400)]
RISC-V: PR27925 Add support for LP64 and LP64F ABIs return values
The RISC-V Linux kernel is compiled without floating point (the LP64
ABI) and elfutils could not obtain return value locations for
functions in the kernel. This issue was noticed when Systemtap
generated RISC-V kernel modules for scripts that used $return target
variables in function return probes. This patch adds the needed
support to provide return value information for the LP64 and LP64F
ABIs.
Some http response header checks were removed such as checking for
Connection and Cache-Control. These headers are not guarenteed to be
received and depend on proxy and libmicrohttpd versions. Checking for
the existance of Content-Length and DEBUGINFOD-* headers is sufficient
since Content-Length is added upon creation of an MHD_Response object
and DEBUGINFOD-* are added manually.
(source on Content-Length being added:
https://www.gnu.org/software/libmicrohttpd/manual/libmicrohttpd.html#
microhttpd_002dresponse-headers )
debuginfod: Query debuginfod servers before printing response
While checking PR27277 on some buildbots, greping would fail in
run-debuginfod-response-headers.sh. This was because querying the
debuginfod server occurs after checking if the responseh headers had
arrived, leaving the possibility to leave the querying loop before
outputting the headers which caused the grep failure. Querying now
occurs before checking if response headers have arrived, so that they
will certainly be printed and grep will find them.
Noah Sanci [Tue, 10 Aug 2021 15:21:35 +0000 (11:21 -0400)]
debuginfod: PR27277 - Describe retrieved files when verbose
Allow users, with enough verbosity, to print the HTTP response headers
upon retrieving a file. These files may include several custome http
response headers such as X-DEBUGINFOD-FILE, X-DEBUGINFOD-SIZE, and
X-DEBUGINFOD-ARCHIVE. These headers are added from the daemon, in
debuginfod.cxx.
debuginfod: PR28034 - No longer escape '/', and loop efficiency
Previously, urls containing '/', so most urls, would escape '/' to %2F,
which is undesirable for use in other libraries which may escape
differently. This patch escapes the '/' and replaces all of them
ensuring there are no %2Fs sent.
Some inefficiencies within the code were fixed, such as changing constant
operations of a while loop within a for loop to a while loop outside of
a for loop. Also strlen is no longer used within the loop, simplifying
the interior operations to mere arithmetic.
PR28339: debuginfod: fix groom/scan race condition on just-emptied queue
debuginfod's scan and groom operations (thread_main_scanner,
thread_main_fts_source_paths) are intended to be mutually exclusive,
as a substitute for more complicated sql transaction batching. (This
is because scanning / grooming involves inserting or deleting data
from multiple related tables.)
The workq class that governs this in debuginfod.cxx has a problem: if
the workq just becomes empty, its sole entry pulled by a scanner
thread in response to a wait_front(), an 'idler' groomer thread is
ALSO permitted to run, because there is no indication as to when the
scanner thread operation finishes, only when it starts.
Extending the workq with a counter ("fronters") to track any active
scanning activity (even if the workq is empty) lets us block idlers
groomers a little longer.
Colin Cross [Fri, 10 Sep 2021 18:07:16 +0000 (11:07 -0700)]
lib: Make error.c more like error(3)
Fix some issues with the error reimplementation to make it match
the specification for error(3).
Flush stdout before printing to stderr. Also flush stderr afterwards,
which is not specified in the man page for error(3), but is what
bionic does.
error(3) prints strerror(errnum) if and only if errnum is nonzero,
but verr prints strerror(errno) unconditionaly. When errnum is nonzero
copy it to errno and use verr, and when it is not set use verrx that
doesn't print errno.
error(3) only exits if status is nonzero, but verr exits uncondtionally.
Use vwarn/vwarnx when status is zero, which don't exit.
Mark Wielaard [Thu, 26 Aug 2021 17:05:45 +0000 (19:05 +0200)]
libdw: set address size, offset size and version on fake CUs
There are three "fake CUs" that are associated with .debug_loc,
.debug_loclist and .debug_addr. These fake CUs are used for "fake
attributes" to provide values that are stored in these sections
instead of in the .debug_info section. These fake CUs didn't have the
address size, offset size and DWARF version set. This meant that
values that depended on those properties might not be interpreted
correctly. One example was the value associated with a DW_OP_addrx
(which comes from the .debug_addr section).
Add a testcase using varlocs to test that addresses can correctly be
retrieved for gcc/clang, DWARF4/5 and 32/64 bits objects.
Mark Wielaard [Thu, 9 Sep 2021 19:51:51 +0000 (21:51 +0200)]
tests: Don't fail run-debuginfod-fd-prefetch-caches.sh if grep -c fails
The set -o errtrace made run-debuginfod-fd-prefetch-caches.sh
fail. On some systems. Add set -o functrace to make it fail consistently.
The failure is because the grep -c for in the log file fails (it
returns zero). Fix this by using || true. But this is only a
workaround. It makes the test pass, but only because all values are
always zero. The test doesn't currently test anything.
Also make sure that err and cleanup are only executed once.
Mark Wielaard [Thu, 9 Sep 2021 16:50:54 +0000 (18:50 +0200)]
tests: Cleanup error handling and don't share cache between servers/client
There were still three tests that shared a cache between the servers
and client that queried those servers. Give them all separate caches.
Also the error handler for debuginfod tests wasn't called when a
command inside a function failed. Since testrun is a function, there
would be no metrics or error log files listed if the testrun command
failed. Making it hard to see what went wrong. Fix this by using
set -o errtrace
While -Wstack-usage= is already excluded from AM_CFLAGS for various
tools in src using *_no_Wstack_usage variables, this obviously does not
help when LTO is enabled, so add -Wno-error=stack-usage= to AM_LDFLAGS
for linking tools in src.
References: https://sourceware.org/bugzilla/show_bug.cgi?id=24498 Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Mark Wielaard [Tue, 7 Sep 2021 21:56:42 +0000 (23:56 +0200)]
tests: Make sure to wait for initial scan and groom cycle earlier
At startup the debuginfod server does a scan and groom cycle. Make
sure to wait for that before making any changes to the scan dirs. And
not just right before triggering a new one with SIGUSR1 for scan or
SIGURS2 for groom.
Mark Wielaard [Mon, 6 Sep 2021 22:31:00 +0000 (00:31 +0200)]
tests: Only export DEBUGINFOD_URLS when necessary
A couple of test set DEBUGINFOD_URLS before starting a debuginfd
server causing the server to query itself or a nonexisting debuginfod
server as delegate. In most cases it should be set after, except for
the testcase that explicitly checks for errors when using an invalid
URL.
Mark Wielaard [Mon, 6 Sep 2021 21:04:06 +0000 (23:04 +0200)]
tests: Print metrics for both ports on error and fix port selection
On error we would only print the metrics of one port (twice) because
of a typo. Also PORT1 and PORT2 could be equal because of a logic
error. Fix the typo and simplify the port selection by using
non-overlapping ranges to select PORT1 and PORT2.
Noah Sanci [Tue, 10 Aug 2021 15:21:35 +0000 (11:21 -0400)]
debuginfod: Fracture tests/run-debuginfod-find.sh into specific tests
tests/run-debuginfod-find.sh was a massive test script with many broadly
varying tests. This caused the test script to fail when any number of
things went wrong and because of its intertwined nature, detecting the
source of a failure could be difficult. The size of the test script
also meant many unrelated tests were run making the testing process
unnecessarily lengthy.
This patch fractures tests/run-debuginfod-find.sh into smaller, more
manageable individual test script files. This ensures that when failure
occurs, a programmer can easily determine where their patch went
wrong. It also allows programmers to specify exactly which tests to
run, making testing more efficient. Redundancies are also reduced by
placing code in tests/debuginfod-subr.sh.
Adrian Ratiu [Mon, 30 Aug 2021 15:43:13 +0000 (18:43 +0300)]
configure.ac: rework gnu99 ext check to allow clang
It is true that Clang does not support all gnu99 extensions [1],
but not all of them are used in the codebase and over time there
have been code cleanup efforts to improve Clang support.
For example after commit 779c57ea ("readelf: Pull advance_pc()
in file scope") there are no more nested function declarations
and elfutils now builds fine with Clang.
So in the interest of enabling Clang builds we remove the only
remaining blocker: the configure checks for nested functions and
variable length arrays which are also unused.
Considering mixed decls and code is also part of c99 standard,
the entire check becomes redundant and we can just replace
AC_PROG_CC -> AC_PROG_CC_C99.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=24964 Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Mark Wielaard [Sat, 28 Aug 2021 18:25:56 +0000 (20:25 +0200)]
debuginfod: Turn -d ":memory:" into -d "file::memory:?cache=shared"
debuginfod opens the database twice, once in read/wrote and once in
read-only mode. This means the magic ":memory:" in-memory database
cannot be used as is because the two connections don't really share
the underlying database. Fix this by turning ":memory:" into
":file::memory:?cache=shared" which makes the in-memory database
shared. See https://sqlite.org/inmemorydb.html
Document this in debuginfod.8 and make some tests use -d :memory:
Mark Wielaard [Sat, 28 Aug 2021 13:54:18 +0000 (15:54 +0200)]
tests: Use fresh separate databases for debuginfd forwarded-ttl-limit
Sharing the database between the two debuginfod instances that forward
queries to each other causes issues. Make both debuginfod instances
use a new fresh database.
Di Chen [Fri, 20 Aug 2021 05:03:21 +0000 (13:03 +0800)]
debuginfod: PR27917 - protect against federation loops
If someone misconfigures a debuginfod federation to have loops, and
a nonexistent buildid lookup is attempted, bad things will happen,
as is documented.
This patch aims to reduce the risk by adding an option to debuginfod
that functions kind of like an IP packet's TTL: a limit on the length of
XFF: header that debuginfod is willing to process. If X-Forwarded-For:
exceeds N hops, it will not delegate a local lookup miss to upstream
debuginfods.
Commit ab38d167c40c99 causes federation loops for non-existent resources
to result in multiple temporary deadlocks, each lasting for
$DEBUGINFOD_TIMEOUT seconds. Since concurrent requests for each unique
resource are now serialized, federation loops can result in one server
thread waiting to acquire a lock while the server thread holding the
lock waits for the first thread to respond to an http request.
This PR can help protect against the above multiple temporary deadlocks
behaviour. Ex. if --forwarded-ttl-limit=0 then the timeout behaviour of
local loops should be avoided.
This properly homes the fallback function into a translation unit rather
than trying to define an inline common definition for the fallback path.
The intent of the original approach was to actually simply avoid adding
a new source file that is used for the fallback path. However, that may
cause trouble with multiple definitions if the symbol does not get vague
linkage (which itself is not particularly great). This simplifies the
behaviour at the cost of an extra inode.
This definition was in the fallback path, where `sys/cdefs.h` is not
available. Now that we have a single path through here, this macro gets
defined, though is unused. Remove the unused macro definition.
handle libc implementations which do not provide `error.h`
Introduce a configure time check for the presence of `error.h`. In the
case that `error.h` is not available, we can fall back to `err.h`.
Although `err.h` is not a C standard header (it is a BSD extension),
many libc implementations provide. If there are targets which do not
provide an implementation of `err.h`, it would be possible to further
extend the implementation to be more portable.
`error.h`'s inclusion was centralised into the `system.h` header. As
the implementation currently includes `system.h` already, the inclusion
of `error.h` is unnecessary. This prepares for a future portability
change to allow elfutil to build with alternate libc implementations.
This header is a BSD header that is also available in glibc. However,
this is a not a standard C header and was used for `__CONCAT`. Because
this is not a standard header, not all libc implementations provide the
header. Remove the usage of the header and always use the previously
fallback path. This is needed in order to build with musl.
Frank Ch. Eigler [Thu, 19 Aug 2021 17:11:11 +0000 (13:11 -0400)]
PR28249: correct debuginfod after-you locking
The initial code for bug #27673 accidentally nuked all buildid service
concurrency, not just identical concurrent requests. Correct this
with one-liner patch. Observing the effect in the automated testsuite
is difficult, so hand-tested against large requests and short ones,
run in an interleaved way.
Alice Zhang [Wed, 4 Aug 2021 20:50:44 +0000 (16:50 -0400)]
debuginfod-doc: PR27950 - Remove redanduncies in man page.
Create a new file, debuginfod-client-config.7, that holds all
environment variables and cache control files related info. Get rid of
repetitive definitions in three other files, instead, those files will
include the content of new file. Any future modification related to
environment variables and cache files will only require changes in one
file.
Signed-off-by: Alice Zhang <alizhang@redhat.com> Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
Mark Wielaard [Wed, 4 Aug 2021 19:01:27 +0000 (21:01 +0200)]
tests: Allow an extra pthread_kill frame in backtrace tests
glibc 2.34 calls pthread_kill from the raise function. Before raise
directly called the (tg)kill syscall. So allow pthread_kill to be the
first frame in a backtrace where raise is expected. Also change some
asserts to fprintf plus abort to make it more clear why the testcase
fails.
debuginfod: PR27982 - added DEBUGINFOD_MAXSIZE and DEBUGINFOD_MAXTIME
DEBUGINFOD_TIMEOUT is a good way to catch servers that are too slow to
*start* transmitting a file. But we have no way of limiting total
download time or space. A user might prefer to have his debugger fetch
only quick & small files, and make do without the bigger ones. Some
transitive dependencies of e.g. gnome programs are huge: 3GB of LLVM
debuginfo, 1GB of webkitgtk, etc. etc.
DEBUGINFOD_MAXSIZE and DEBUGINFOD_MAXTIME were added to dictate the
max download size and time of a debuginfod client. DEBUGINFOD_MAXSIZE
is handled server-side and is sent using the http header:
X-DEBUGINFOD-MAXSIZE. The client side then checks to ensure this maxsize
has been respected.
Gazing at server logs, one sees a minority of clients who appear to have
duplicate query traffic coming in: the same URL, milliseconds apart.
Chances are the user accidentally doubled her $DEBUGINFOD_URLS somehow,
and the client library is dutifully asking the servers TWICE. Bug #27863
reduces the pain on the servers' CPU, but dupe network traffic is still
being paid. We should reject sending outright duplicate concurrent
traffic.
The urls are now simply removed upon finding a duplicate after url
construction.
When requesting some source files, some URL-inconvenient chars
sometimes pop up. Example from f33 libstdc++:
/buildid/44d8485cb75512c2ca5c8f70afbd475cae30af4f/source/usr/src/debug/
gcc-10.3.1-1.fc33.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/
libstdc++-v3/src/c++11/../../../../../libstdc++-v3/src/c++11/
condition_variable.cc
As this URL is passed into debuginfod's handler_cb, it appears that the
+ signs are helpfully unescaped to spaces by libmicrohttpd, which
'course breaks everything.
In order to ensure the server properly parses urls such as this one,
%-escape characters on the client side so that the correct url
is preserved and properly processed on the server side.
debuginfod: Minor run-debuginfod-find.sh test fixes
$PORT3's metrics are not reported on error and $PID4 was not properly
killed. This patch addresses both of those issues by reporting the
metrics of $PORT3 as $PORT1 and $PORT2 were in err() and waiting for
$PID4 to terminate before continuing with the test.
Mark Wielaard [Mon, 19 Jul 2021 13:52:51 +0000 (15:52 +0200)]
libelf: Optimize elf_strptr.c validate_str by checking last char first
In most cases the last char of the sectio will be zero. Check that
first before calling memrchr. This is a minor optimization in normal
cases. But it helps asan a lot by removing the memrchr call in most
cases.
Timm Bäder [Thu, 18 Mar 2021 09:25:24 +0000 (10:25 +0100)]
readelf: Pull advance_pc() in file scope
Make advance_pc() a static function so we can get rid of another nested
function. Rename it to run_advance_pc() and use a local advance_pc()
macro to pass all the local variables. This is similar to what the
equivalent code in libdw/dwarf_getsrclines.c is doing.
Noah [Thu, 10 Jun 2021 14:29:45 +0000 (10:29 -0400)]
debuginfod: PR25978 - Created the prefetch fdcache
The debuginfod fdcache-prefetch logic has been observed to show some
degeneracies in operation. Since fdcache evictions are done
frequently, and freshly prefetched archive elements are put at the
back of lru[], each eviction round can summarily nuke things that
were just prefetched .... and are just going to be prefetched again.
It would be better to have two lru lists, or being able to insert
newly prefetched entries somewhere in the middle of the list rather
than at the very very end.
Alice Zhang [Tue, 6 Jul 2021 20:12:43 +0000 (16:12 -0400)]
PR27531: retry within default retry_limit will be supported.
In debuginfod-client.c (debuginfod_query_server),insert a
goto statement for jumping back to the beginning of curl
handles set up if query fails and a non ENOENT error is returned.
Also introduced DEBUGINFOD_RETRY_LIMIT_ENV_VAR and default
DEBUGINFOD_RETRY_LIMIT(which is 2).
Correponding test has been added to tests/run-debuginfod-find.sh
debuginfod: PR27711 - Use -I/-X regexes during groom phase
The debuginfod -I/-X regexes operate during traversal to identify
those files in need of scanning. The regexes are not used during
grooming. This means that if from run to run, the regex changes so
that formerly indexed files are excluded from traversal, the data is
still retained in the index.
This is both good and bad. On one hand, if the underlying data is
still available, grooming will preserve the data, and let clients ask
for it. On the other hand, if the growing index size is a problem,
and one wishes to age no-longer-regex-matching index data out, there
is no way.
Let's add a debuginfod flag to use regexes during grooming.
Specifically, in groom(), where the stat() test exists, also check
for regex matching as in scan_source_paths(). Treat failure of the
regex the same way as though the file didn't exist.
Andrei Homescu [Tue, 29 Jun 2021 01:26:53 +0000 (18:26 -0700)]
libelf: Fix unaligned d_off offsets for input sections with large alignments
The mkl_memory_patched.o object inside the libmkl_core.a library from
the Intel Math Kernel Library version 2018.2.199 has this section
with an alignment of 4096 and offset of 0xb68:
[ 2] .data PROGBITS 0000000000000000 000b68 011000 00 WA 0 0 4096
Reading this file with libelf and trying to write it back to disk triggers
the following sequence of events:
1) code in elf_getdata.c clamps d_align for this section's data buffer
to the section's offset
2) code in elf32_updatenull.c checks if the alignment is a power of two
and incorrectly returns an error
This commit fixes this corner case by increasing the alignment to the
next power of two after the clamping, so the check passes.
A test that reproduces this bug using strip is also included.
Frank Ch. Eigler [Wed, 16 Jun 2021 22:49:10 +0000 (18:49 -0400)]
debuginfod test: fix groom/stale race condition
Additional tracing, and use of "% make check VERBOSE=1" in a .spec
file allowed tracking down of this intermittent problem. The race was
between a SIGUSR1 or two to a debuginfod server (triggering two
traverse/scan phases), followed shortly by a SIGUSR2 (triggering a
groom). If those signals were received too close together, the groom
phase could be stopped early, and the rm'd files not noticed.
New testsuite code adds metric polls after SIGUSR1 & SIGUSR2 to ensure
the respective processing phases are complete. It also turns on "set -x"
tracing, so as to avoid pulling out quite as much hair next time.
"make check VERBOSE=1" is also important for spec files.
Frank Ch. Eigler [Wed, 16 Jun 2021 14:49:49 +0000 (10:49 -0400)]
debuginfod tests: tolerate 000-perm files in cache-copy test
It appears possible for 000-permission files to sneak into the
test debuginfod-cache, which cp (or find|cpio) refuse to copy.
These files are OK not to copy, so ignore the error and proceed.
Omar Sandoval [Thu, 10 Jun 2021 00:45:57 +0000 (17:45 -0700)]
libdwfl: fix potential NULL pointer dereference when reading link map
When read_addrs() was moved into file scope, there was a mistake in
converting "buffer" from a closure variable to a parameter: we are
checking whether the pointer argument is NULL, not whether the buffer
itself is NULL. This causes a NULL pointer dereference when we try
to use the NULL buffer later.
Fixes: 3bf41d458fb6 ("link_map: Pull read_addrs() into file scope") Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
PR27863: debuginfod optimization for concurrent requests
Sometimes, due to configuration error, mishap, or DoS misadventure, a
debuginfod server may receive near-concurrent requests for the exact
same data from multiple clients. In practically all cases, it is
beneficial to the clients, as well as the server, to serialize these
requests. This way, debuginfod does not waste CPU in repeatedly &
concurrently decompressing large archives or querying upstream
servers. Second and later requesters can benefit from the fdcache /
client-cache and get their results, probably earlier!
This patch adds an "after-you" queueing phase to servicing
http-buildid requests, whereby thereads serialize themselves on each
query URL being serviced at the moment. Prometheus metrics are added,
and the http GET trace line is modified to print the queue+service
times separately.
Hand-tested on large kernel-debuginfo's, and shows host CPU refusing
to multiply in the face of concurrent identical queries. The
automated test tries a hundred concurrent curls, at least some of
which are slow enough to trigger the "after-you" wait here.
CCLD elflint
ld: elflint.o: in function `check_attributes':
elflint.c:(.text+0xdcff): undefined reference to `buffer_left'
ld: elflint.c:(.text+0xe557): undefined reference to `buffer_left'
```
It happens due to possible external linkage of `buffer_left()`.
The change forces local linkage to always use local definition
(either inline or out-of-line).
Reported-by: Toralf Förster
Bug: https://bugs.gentoo.org/794601 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Fixes: e95d1fbb ("elflint: Pull left() in file scope") Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Frank Ch. Eigler [Fri, 14 May 2021 22:37:30 +0000 (18:37 -0400)]
PR27859: correct 404-latch bug in debuginfod client reuse
PR27701 implemented curl handle reuse in debuginfod_client objects,
but with an unexpected bug. Server responses returning an error
"latched" because the curl_easy handles for error cases weren't all
systematically removed from the curl multi handle. This prevented
their proper re-addition the next time.
This version of the code simplfies matters by making only the curl
curl_multi handle long-lived. This turns out to be enough, because it
can maintain a pool of long-lived http/https connections and related
data, and lend them out to short-lived curl_easy handles. This mode
handles errors or hung downloads even better, because the easy handles
don't undergo complex state transitions between reuse.
A new test case confirms this correction via the federating debuginfod
instance (cleaning caches between subtests to make sure http* is being
used and reused).
Dmitry V. Levin [Wed, 12 May 2021 15:00:00 +0000 (15:00 +0000)]
elfcompress: fix exit status regression in case of "Nothing to do"
When elfcompress decides that no section data needs to be updated and
therefore the file does not have to be rewritten, it still has to exit
with a zero status indicating success.
Resolves: https://sourceware.org/bugzilla/show_bug.cgi?id=27856 Fixes: c497478390de ("elfcompress: Replace cleanup() with label")
Mark Wielaard [Sat, 1 May 2021 16:00:49 +0000 (18:00 +0200)]
libdw: Document and handle DW_FORM_indirect in __libdw_form_val_compute_len
Update the documentation in __libdw_form_val_compute_len for handling
DW_FORM_indirect and make sure the indirect form isn't DW_FORM_indirect
itself or DW_FORM_implicit_const.
debuginfod: debuginfod client should cache negative results.
Add debuginfod_config_cache for reading and writing to cache
configuration files, make use of the function within
debuginfod_clean_cache and debuginfod_query_server.
In debuginfod_query_server, create 000-permission file on failed
queries. Before querying each BUILDID, if corresponding 000 file
detected, compare its stat mtime with parameter from
.cache/cache_miss_s. If mtime is fresher, then return ENOENT and
exit; otherwise unlink the 000 file and proceed to a new query.
tests: add test in run-debuginfod-find.sh
test if the 000 file is created on failed query; if querying the
same failed BUILDID, whether the query should proceed without
going through server; set the cache_miss_s to 0 and query the same
buildid, and this time should go through the server.
With PR25365, we accidentally lost the ability to rmdir client-cache
directories corresponding to buildids. Bring this back, with some
attention to a possible race between a client doing cleanup and
another client doing lookups at the same time.
libdw: handle DW_FORM_indirect when reading attributes
Whenever we encounter an attribute with DW_FORM_indirect, we need to
read its true form from the DIE data. Then, we can continue normally.
This adds support to the most obvious places: __libdw_find_attr() and
dwarf_getattrs(). There may be more places that need to be updated.
I encountered this when inspecting a file that was processed by our BOLT
tool: https://github.com/facebookincubator/BOLT. This also adds a couple
of test cases using a file generated by that tool.
Client objects now carry long-lived curl handles for outgoing
connections. This makes it more efficient for multiple sequential
queries, because the TCP connections and/or TLS state info are kept
around awhile, avoiding O(100ms) setup latencies. debuginfod is
adjusted to take advantage of this for federation. Other clients
should gradually do this too, perhaps including elfutils itself (in
the libdwfl->debuginfod_client hooks).
A large gdb session with 117 debuginfo downloads was observed to run
twice as fast (45s vs. 1m30s wall-clock time), just in nuking this
extra setup latency. This was tested via a debuginfod intermediary:
it should be even faster once gdb reuses its own debuginfod_client.
Dmitry V. Levin [Sun, 21 Mar 2021 08:00:00 +0000 (08:00 +0000)]
po: update XGETTEXT_OPTIONS
Recognize sgettext as a macro which is used for translations.
Flag _, N_, and sgettext with pass-c-format. The effect of this
specification is that xgettext will propagate format string
requirements for _, N_, and sgettext calls to their first arguments,
and thus mark them as format strings.
debuginfod: only update database stats once per groom
On very large servers, each database-stat counting pass can take tens
of minutes (!), and doing it twice per groom pass does not seriously
improve data quality. Just do it once, after stale data removal &
basic sqlite vacuum.
Mark Wielaard [Sat, 3 Apr 2021 17:36:12 +0000 (19:36 +0200)]
unstrip: Fix small leak in handle_output_dir_module.
eu-unstrip might leak a string for each module found when using the -d
option. Make sure to free the output_file name when we are done with the
module.
Mark Wielaard [Sat, 3 Apr 2021 17:20:32 +0000 (19:20 +0200)]
ar: Always close newfd in do_oper_insert.
newfd is normally created by mkstemp given the original fd exists.
Otherwise it will created by open from arfname. In the second case
newfd might not get closed. Preventd this by always trying to close
it after errout.
Frank Ch. Eigler [Tue, 30 Mar 2021 17:22:43 +0000 (13:22 -0400)]
debuginfod: Set child thread names via pthread_setname_np()
In order to assist problem diagnosis / monitoring, use this
gnu-flavoured pthread function to set purpose names to the various
child threads debuginfod starts. libmicrohttpd already sets this for
its threads.
Timm Bäder [Sun, 7 Mar 2021 18:02:29 +0000 (13:02 -0500)]
debuginfod-client: Don't compare a double to a long
Clang warns about this:
../../debuginfod/debuginfod-client.c:899:28: error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
pa = (dl > LONG_MAX ? LONG_MAX : (long)dl);
~ ^~~~~~~~
/usr/lib64/clang/10.0.1/include/limits.h:47:19: note: expanded from macro 'LONG_MAX'
^~~~~~~~~~~~
<built-in>:38:22: note: expanded from here
^~~~~~~~~~~~~~~~~~~~
Modified for jakub's observation about LONG_MAX overflow.