summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* C API interfacensanci/pr28284-webapiFrank Ch. Eigler2021-09-223-23/+109
|
* simplify webapi sideFrank Ch. Eigler2021-09-211-24/+11
|
* 28284 first onlyNoah Sanci2021-09-211-17/+49
|
* debuginfod: Remove checking for unsafe headersNoah Sanci2021-09-172-4/+5
| | | | | | | | | | | | | | 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 ) Signed-off-by: Noah Sanci <nsanci@redhat.com>
* debuginfod: Query debuginfod servers before printing responseNoah Sanci2021-09-172-1/+6
| | | | | | | | | | | | 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. Signed-off-by: Noah Sanci <nsanci@redhat.com>
* debuginfod: PR27277 - Describe retrieved files when verboseNoah Sanci2021-09-169-3/+208
| | | | | | | | | | | | | | | | | | | | | | | | 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. E.g output: HTTP/1.1 200 OK Connection: Keep-Alive Content-Length: 4095072 Cache-Control: public Last-Modified: Thu, 09 Sep 2021 19:06:40 GMT X-FILE: debuginfod X-FILE-SIZE: 4095072 Content-Type: application/octet-stream Date: Fri, 10 Sep 2021 16:38:06 GMT https://sourceware.org/bugzilla/show_bug.cgi?id=27277 Signed-off-by: Noah Sanci <nsanci@redhat.com>
* debuginfod: PR28034 - No longer escape '/', and loop efficiencyNoah Sanci2021-09-165-13/+100
| | | | | | | | | | | | | | | 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. https://sourceware.org/bugzilla/show_bug.cgi?id=28034 Signed-off-by: Noah Sanci <nsanci@redhat.com>
* PR28339: debuginfod: fix groom/scan race condition on just-emptied queueFrank Ch. Eigler2021-09-142-6/+28
| | | | | | | | | | | | | | | | | | | | 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. Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* debuginfod: Add endl after "fdcache emergency flush for filling tmpdir" logMark Wielaard2021-09-132-1/+6
| | | | | | Without the endl the next log message will not start on its own line. Signed-off-by: Mark Wielaard <mark@klomp.org>
* lib: Make error.c more like error(3)Colin Cross2021-09-122-3/+34
| | | | | | | | | | | | | | | | | | | 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. Signed-off-by: Colin Cross <ccross@google.com>
* libdw: set address size, offset size and version on fake CUsMark Wielaard2021-09-1213-8/+149
| | | | | | | | | | | | | | | | | | 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. https://sourceware.org/bugzilla/show_bug.cgi?id=28220 Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Don't fail run-debuginfod-fd-prefetch-caches.sh if grep -c failsMark Wielaard2021-09-093-4/+22
| | | | | | | | | | | | | | 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. Signed-off-by: Mark Wielaard <mark@klomp.org>
* findtextrel: do not use unbound allocaDmitry V. Levin2021-09-093-30/+30
| | | | | | | | This fixes the following compilation warning: findtextrel.c:184:1: warning: stack usage might be unbounded [-Wstack-usage=] Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* tests: Cleanup error handling and don't share cache between servers/clientMark Wielaard2021-09-095-31/+42
| | | | | | | | | | | | | 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 Signed-off-by: Mark Wielaard <mark@klomp.org>
* Use xasprintf instead of asprintf followed by error(EXIT_FAILURE)Dmitry V. Levin2021-09-096-27/+26
| | | | Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* Introduce xasprintfDmitry V. Levin2021-09-094-1/+59
| | | | | | | Similar to other x* functions, xasprintf is like asprintf except that it dies in case of an error. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* Remove redundant casts of memory allocating functions returning void *Dmitry V. Levin2021-09-0944-75/+141
| | | | | | | Return values of functions returning "void *", e.g. calloc, malloc, realloc, xcalloc, xmalloc, and xrealloc, do not need explicit casts. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* src: add -Wno-error=stack-usage= to AM_LDFLAGSDmitry V. Levin2021-09-094-1/+11
| | | | | | | | | | 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>
* tests: Make sure to wait for initial scan and groom cycle earlierMark Wielaard2021-09-077-19/+42
| | | | | | | | | 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. Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Make sure to wait for initial scan and groom cycleMark Wielaard2021-09-0714-26/+83
| | | | | | | | At startup the debuginfod server does a scan and groom cycle. Make sure to wait for that before triggering a new one with SIGUSR1 or SIGURST2. Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Only export DEBUGINFOD_URLS when necessaryMark Wielaard2021-09-076-5/+15
| | | | | | | | | | 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. Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Print metrics for both ports on error and fix port selectionMark Wielaard2021-09-062-4/+11
| | | | | | | 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.
* tests: Set DEBUGINFOD_CACHE_PATH for run-debuginfod-{file,query-retry}.shMark Wielaard2021-09-063-4/+11
|
* tests: Make sure all debuginfod tests use a clean database and cache.Mark Wielaard2021-09-0412-10/+57
| | | | | | | | Always set DEBUGINFOD_CACHE_PATH to an unique (new) directory and make sure that each debuginfod invocation uses a new sqlite database. Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Add debuginfod-subr.sh to EXTRA_DISTMark Wielaard2021-09-032-1/+5
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: Fracture tests/run-debuginfod-find.sh into specific testsNoah Sanci2021-09-0325-854/+2305
| | | | | | | | | | | | | | | | | | 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. Signed-off-by: Noah Sanci <nsanci@redhat.com>
* configure.ac: rework gnu99 ext check to allow clangAdrian Ratiu2021-08-312-34/+5
| | | | | | | | | | | | | | | | | | | | | 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>
* debuginfod: Turn -d ":memory:" into -d "file::memory:?cache=shared"Mark Wielaard2021-08-286-8/+28
| | | | | | | | | | | | | 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: Signed-off-by: Mark Wielaard <mark@klomp.org>
* tests: Use fresh separate databases for debuginfd forwarded-ttl-limitMark Wielaard2021-08-282-2/+10
| | | | | | | | 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. Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: PR27917 - protect against federation loopsDi Chen2021-08-276-1/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. https://sourceware.org/bugzilla/show_bug.cgi?id=27917 Signed-off-by: Di Chen <dichen@redhat.com>
* Add lib/error.cMark Wielaard2021-08-271-0/+49
| | | | | | | This new file was supposed to be part of 4d6dd0e5a "lib: avoid potential problems with `-fno-common`". Signed-off-by: Mark Wielaard <mark@klomp.org>
* lib: avoid potential problems with `-fno-common`Saleem Abdulrasool2021-08-273-16/+12
| | | | | | | | | | 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.
* lib: remove unused `STROF` definition (NFC)Saleem Abdulrasool2021-08-272-1/+4
| | | | | | | | 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. Signed-off-by: Saleem Abdulrasool <abdulras@google.com>
* handle libc implementations which do not provide `error.h`Saleem Abdulrasool2021-08-274-1/+37
| | | | | | | | | | | | | 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. This resolves bug #21008. Signed-off-by: Saleem Abdulrasool <abdulras@google.com>
* debuginfod, elfclassify: remove unnecessary header inclusionSaleem Abdulrasool2021-08-274-2/+8
| | | | | | | | | `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. Signed-off-by: Saleem Abdulrasool <abdulras@google.com>
* lib: remove usage of `sys/cdefs.h`Saleem Abdulrasool2021-08-272-5/+5
| | | | | | | | | | 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. Signed-off-by: Saleem Abdulrasool <abdulras@google.com>
* PR27950 - package new debuginfod-client-config.7 man page in rpmFrank Ch. Eigler2021-08-201-0/+3
| | | | | | | The template rpm spec file needs to include the new .7 page in all the subrpms whose man pages may .so it. Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* PR28249: correct debuginfod after-you lockingFrank Ch. Eigler2021-08-192-1/+7
| | | | | | | | | | 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. Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* debuginfod-doc: PR27950: make distcheck happyFrank Ch. Eigler2021-08-111-0/+2
| | | | | | | The debuginfod-client-config.7 shouldn't be included twice in notrans_dist_man7_MANS. Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
* debuginfod-doc: PR27950 - Remove redanduncies in man page.Alice Zhang2021-08-118-152/+161
| | | | | | | | | | | | 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>
* tests: Allow an extra pthread_kill frame in backtrace testsMark Wielaard2021-08-052-7/+60
| | | | | | | | | | | | 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. https://sourceware.org/bugzilla/show_bug.cgi?id=28190 Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: PR27982 - added DEBUGINFOD_MAXSIZE and DEBUGINFOD_MAXTIMENoah Sanci2021-08-048-3/+177
| | | | | | | | | | | | | | | | | | 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. https://sourceware.org/bugzilla/show_bug.cgi?id=27982 Signed-off-by: Noah Sanci <nsanci@redhat.com>
* update Japanese translationHayatsu Shunsuke2021-07-292-609/+512
| | | | Signed-off-by: Hayatsu Shunsuke <hayatsu.shunsuke@gmail.com>
* debuginfod: PR27983 - ignore duplicate urlsNoah Sanci2021-07-294-29/+97
| | | | | | | | | | | | | | | | 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. https://sourceware.org/bugzilla/show_bug.cgi?id=27983 Signed-off-by: Noah Sanci <nsanci@redhat.com>
* lib: Add static inline reallocarray fallback functionMark Wielaard2021-07-294-0/+25
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* debuginfod: PR28034 - client-side %-escape url charactersNoah Sanci2021-07-225-18/+48
| | | | | | | | | | | | | | | | | | | 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. https://sourceware.org/bugzilla/show_bug.cgi?id=28034 Signed-off-by: Noah Sanci <nsanci@redhat.com>
* debuginfod: Minor run-debuginfod-find.sh test fixesNoah Sanci2021-07-222-1/+8
| | | | | | | | | $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. Signed-off-by: Noah Sanci <nsanci@redhat.com>
* libelf: Optimize elf_strptr.c validate_str by checking last char firstMark Wielaard2021-07-192-1/+8
| | | | | | | | | | | 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. https://sourceware.org/bugzilla/show_bug.cgi?id=28101 Signed-off-by: Mark Wielaard <mark@klomp.org>
* readelf: Pull advance_pc() in file scopeTimm Bäder2021-07-152-7/+26
| | | | | | | | | 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. Signed-off-by: Timm Bäder <tbaeder@redhat.com>
* debuginfod: PR25978 - Created the prefetch fdcacheNoah2021-07-145-27/+175
| | | | | | | | | | | | | | | 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. https://sourceware.org/bugzilla/show_bug.cgi?id=25978 Signed-off-by: Noah Sanci <nsanci@redhat.com>