Re: [PATCH] Prevent binaries in src from colliding with libc++ headers

2024-08-08 Thread Aaron Merey
From: Tristan Ross 

Hi Tristan

On Wed, Aug 7, 2024 at 5:07 PM Tristan ross  wrote:
>
> Gotcha on that ChangeLog thing. With the warning, I think we can just
> use `?=` in `config/eu.am` for `AM_CPPFLAGS`.

I tried this but I still got an error during autoreconf.  I tweaked
your patch below so that the AM_CPPFLAGS definition is set in a
separate file that src/Makefile.am can avoid including.  I also
removed the ChangeLog update from the patch.

Let me know if this updated patch works for you.

Thanks,
Aaron

---

Discovered with Nix and LLVM 17. Headers inside of libc++ can easily
collide with binaries being linked in src. This results in clang trying
to include a binary as a header.

Fix this by removing '-I.' and '-I$(srcdir)' from AM_CPPFLAGS and
DEFAULT_INCLUDES in src/Makefile.am.

To facilitate this config/eu.am has been refactored.  New file
config/eu-common.am contains all of the old eu.am but with the
AM_CPPFLAGS definition removed. eu.am now includes eu-common.am and
contains the old AM_CPPFLAGS definition.

eu.am functionality does not change, but src/Makefile.am can instead
include eu-common.am and define its own AM_CPPFLAGS without causing a
"multiply defined" warning during autoreconf.

Signed-off-by: Tristan Ross 
---
 config/eu-common.am | 148 
 config/eu.am| 120 +--
 src/Makefile.am |   6 +-
 3 files changed, 155 insertions(+), 119 deletions(-)
 create mode 100644 config/eu-common.am

diff --git a/config/eu-common.am b/config/eu-common.am
new file mode 100644
index ..9cc7f696
--- /dev/null
+++ b/config/eu-common.am
@@ -0,0 +1,148 @@
+## Common automake fragments for elfutils subdirectory makefiles.
+##
+## Copyright (C) 2010, 2014, 2016 Red Hat, Inc.
+## Copyright (C) 2023, Mark J. Wielaard 
+##
+## This file is part of elfutils.
+##
+## This file is free software; you can redistribute it and/or modify
+## it under the terms of either
+##
+##   * the GNU Lesser General Public License as published by the Free
+## Software Foundation; either version 3 of the License, or (at
+## your option) any later version
+##
+## or
+##
+##   * the GNU General Public License as published by the Free
+## Software Foundation; either version 2 of the License, or (at
+## your option) any later version
+##
+## or both in parallel, as here.
+##
+## elfutils is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received copies of the GNU General Public License and
+## the GNU Lesser General Public License along with this program.  If
+## not, see .
+##
+
+DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"'
+
+# Drop the 'u' flag that automake adds by default. It is incompatible
+# with deterministic archives.
+ARFLAGS = cr
+
+# Warn about stack usage of more than 256K = 262144 bytes.
+if ADD_STACK_USAGE_WARNING
+STACK_USAGE_WARNING=-Wstack-usage=262144
+STACK_USAGE_NO_ERROR=-Wno-error=stack-usage=
+else
+STACK_USAGE_WARNING=
+STACK_USAGE_NO_ERROR=
+endif
+
+if SANE_LOGICAL_OP_WARNING
+LOGICAL_OP_WARNING=-Wlogical-op
+else
+LOGICAL_OP_WARNING=
+endif
+
+if HAVE_DUPLICATED_COND_WARNING
+DUPLICATED_COND_WARNING=-Wduplicated-cond
+else
+DUPLICATED_COND_WARNING=
+endif
+
+if HAVE_NULL_DEREFERENCE_WARNING
+NULL_DEREFERENCE_WARNING=-Wnull-dereference
+else
+NULL_DEREFERENCE_WARNING=
+endif
+
+if HAVE_IMPLICIT_FALLTHROUGH_WARNING
+# Use strict fallthrough. Only __attribute__((fallthrough)) will prevent the
+# warning
+if HAVE_IMPLICIT_FALLTHROUGH_5_WARNING
+IMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough=5
+else
+IMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough
+endif
+else
+IMPLICIT_FALLTHROUGH_WARNING=
+endif
+
+if HAVE_TRAMPOLINES_WARNING
+TRAMPOLINES_WARNING=-Wtrampolines
+else
+TRAMPOLINES_WARNING=
+endif
+
+if HAVE_NO_PACKED_NOT_ALIGNED_WARNING
+NO_PACKED_NOT_ALIGNED_WARNING=-Wno-packed-not-aligned
+else
+NO_PACKED_NOT_ALIGNED_WARNING=
+endif
+
+if HAVE_USE_AFTER_FREE3_WARNING
+USE_AFTER_FREE3_WARNING=-Wuse-after-free=3
+else
+USE_AFTER_FREE3_WARNING=
+endif
+
+AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
+   -Wold-style-definition -Wstrict-prototypes $(TRAMPOLINES_WARNING) \
+   $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
+   $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
+   $(USE_AFTER_FREE3_WARNING) \
+   $(if $($(*F)_no_Werror),,-Werror) \
+   $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
+   $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
+   $(if 
$($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \
+   $($(*F)_CFLAGS)
+
+AM_CXXFLAGS = -std=c++11 -Wall -Wshadow \
+  $(TRAMPOLINES_WARNING) \
+  $(LOGICAL_OP_WA

Re: [PATCH] Prevent binaries in src from colliding with libc++ headers

2024-08-08 Thread Aaron Merey
Hi Tristan,

On Thu, Aug 8, 2024 at 2:19 PM Aaron Merey  wrote:
> On Wed, Aug 7, 2024 at 5:07 PM Tristan ross  wrote:
> >
> > Gotcha on that ChangeLog thing. With the warning, I think we can just
> > use `?=` in `config/eu.am` for `AM_CPPFLAGS`.
>
> I tried this but I still got an error during autoreconf.  I tweaked
> your patch below so that the AM_CPPFLAGS definition is set in a
> separate file that src/Makefile.am can avoid including.  I also
> removed the ChangeLog update from the patch.
>
> Let me know if this updated patch works for you.

Can you also provide a reproducer for the error you are seeing?

Thanks,
Aaron



[Bug tools/32062] New: analyze eu-stacktrace w.r.t. debuginfod

2024-08-08 Thread fche at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32062

Bug ID: 32062
   Summary: analyze eu-stacktrace w.r.t. debuginfod
   Product: elfutils
   Version: unspecified
Status: NEW
  Severity: normal
  Priority: P2
 Component: tools
  Assignee: unassigned at sourceware dot org
  Reporter: fche at redhat dot com
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

May need debuginfod help in case of:
- lack of buildid-matching executable (for .eh_frame)
- lack of buildid-matching debuginfo (if .eh_frame is absent, so need
.debug_frame)

So for those cases, consider some mixture of:
- diagnostics: enumerate newly encountered buildids for reporting
- invoke debuginfod-find {executable,debuginfo} (which?) $buildid in background
- have eu-stacktrace NOT disable debuginfod fallback hooks
- check how much latency (downloading time) might be tolerable to
sysprof/consumers
- check how much RAM could be consumed by copying incoming stack-dump ring
buffer frames while waiting for debuginfo /etc. download
- check whether $DEBUGINFOD_MAXTIME is sufficient knob of control

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug debuginfod/32063] New: let debuginfod-find locate pre-installed (/usr/lib/.debug or similar) exec / .debug files

2024-08-08 Thread fche at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32063

Bug ID: 32063
   Summary: let debuginfod-find locate pre-installed
(/usr/lib/.debug or similar) exec / .debug files
   Product: elfutils
   Version: unspecified
Status: NEW
  Severity: normal
  Priority: P2
 Component: debuginfod
  Assignee: unassigned at sourceware dot org
  Reporter: fche at redhat dot com
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Sometimes a user will go to the trouble of dnf-installing some debuginfo, or
some executable may still be the live one in /usr/bin/* (rather than expired
due to a dnf-update, with an old copy still running).  If so, debuginfod-find
might want to return paths to system location files rather than the debuginfod
cache.

This might not be necessary or appropriate in the client side C code, as it is
usually invoked as a *fallback* to system paths not being found.  ...  But some
applications might directly call debuginfod_find_* APIs, rather than the
searching elfutils paths, in which case looking in system paths might be
appropriate.

-- 
You are receiving this mail because:
You are on the CC list for the bug.