Gentoo Archives: gentoo-user

From: John Covici <covici@××××××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] preparing for make menuconfig
Date: Thu, 08 Oct 2020 22:50:28
Message-Id: m3k0w05o47.wl-covici@ccs.covici.com
In Reply to: Re: [gentoo-user] preparing for make menuconfig by Ashley Dixon
1 On Thu, 08 Oct 2020 16:26:19 -0400,
2 Ashley Dixon wrote:
3 >
4 > [1 <text/plain; us-ascii (quoted-printable)>]
5 > On Thu, Oct 08, 2020 at 01:55:04PM -0400, John Covici wrote:
6 > > modules.alias modules.builtin
7 > > modules.builtin.bin modules.dep.bin modules.order
8 > > modules.symbols
9 > > modules.alias.bin modules.builtin.alias.bin modules.dep
10 > > modules.devname modules.softdep
11 > > modules.symbols.bin
12 >
13 > That's fine.
14 >
15 > > and the error message is
16 > >
17 > > lspci: Unable to load libkmod resources: error -12
18 >
19 > That error message is printed by lspci [1], although it is the result of the
20 > libkmod `kmod_load_resources` function returning less than zero [2]. With a -12
21 > error, this suggests a failing with the `index_mm_open` function [3]. It's quite
22 > a beast of a function; the failure could be due to a multitude of reasons.
23 >
24 > Considering the nature of the error (memory allocation failure), I reckon it
25 > must be either the following call to mmap(2), or the preceding call to open(2):
26 > (paraphrasing for formatting):
27 >
28 >
29 > if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) < 0) {
30 > DBG(ctx, "open(%s, O_RDONLY|O_CLOEXEC): %m\n", filename);
31 > err = -errno;
32 > goto fail_open;
33 > }
34 >
35 > /* [...] */
36 >
37 > if ( ( idx->mm = mmap ( NULL, st.st_size, PROT_READ,
38 > MAP_PRIVATE, fd, 0 ) ) == MAP_FAILED) {
39 > ERR(ctx, "mmap (NULL, %"PRIu64", PROT_READ, %d, " \
40 > "MAP_PRIVATE, 0 ): %m\n", st.st_size, fd);
41 > err = -errno;
42 > goto fail_nommap;
43 > }
44 >
45 > I might you need to debug this on your machine, as I can't reproduce it myself.
46 > You'll need to clone, recompile, and relink libkmod and pciutils with the
47 > maximum debugging settings, to keep all symbols in the executable. I assume
48 > you're using GCC, although I suspect the same should work with Clang.
49 >
50 > git clone both repos: [4] and [5].
51 >
52 > libkmod:
53 > - Save the old symlink, by renaming /lib64/libkmod.<version> to
54 > something temporary, like libkmod.old.
55 > - Execute ./autogen.sh to create a configure script.
56 > - Run the configure script to enable maximum debugging:
57 > ./configure CFLAGS='-ggdb3' --prefix=/usr --sysconfdir=/etc \
58 > --libdir=/usr/lib64 --with-rootprefix= --with-rootlibdir=/lib64
59 > - Compile and install the shared objects (you need to be root):
60 > make && make install
61 > - Ensure the `make install` has recreated the major version symlink in
62 > /lib64 to the new shared object file.
63 >
64 > pciutils:
65 > - Compile; there is no need to install:
66 > make CFLAGS="-ggdb3"
67 >
68 > Now you have an lspci executable which is linked with the new libkmod, just need
69 > to attach a debugger, such as gdb, and break on the troublesome function:
70 >
71 > $ gdb ./lspci
72 > Reading symbols from ./lspci...
73 > (gdb) b index_mm_open
74 > Function "index_mm_open" not defined.
75 > Make breakpoint pending on future shared library load? (y or [n]) y
76 > Breakpoint 1 (index_mm_open) pending.
77 > (gdb) run -k
78 >
79 > ... after a while, you'll encounter the first invocation of the troublemaker:
80 >
81 > Breakpoint 1, index_mm_open (ctx=0x555555583340, filename=0x7fffffffc920
82 > "/lib/modules/5.4.60-gentoo/modules.dep.bin", stamp=0x5555555833a0,
83 > pidx=0x555555583378) at libkmod/libkmod-index.c:744
84 >
85 > Before going any further, I want to confirm that `filename` does point to a
86 > correct file? I doubt the open(2) call would fail with ENOMEM if the file was
87 > invalid, although you never know. Assuming `filename` is valid, we can start
88 > stepping through the function to determine which inner function is failing. My
89 > bets are on mmap.
90 >
91 > Hope to hear from you soon.
92 >
93 > [1] https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git/tree/ls-kernel.c#n42
94 > [2] https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/libkmod/libkmod.c#n842
95 > [3] https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/libkmod/libkmod-index.c#n742
96 > [4] git://git.kernel.org/pub/scm/utils/pciutils/pciutils.git
97 > [5] git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
98 >
99
100
101 Since I compile most packages with split-debug and my default flags
102 contain -gdb, could I use the existing packages?
103
104 --
105 Your life is like a penny. You're going to lose it. The question is:
106 How do
107 you spend it?
108
109 John Covici wb2una
110 covici@××××××××××.com

Replies

Subject Author
Re: [gentoo-user] preparing for make menuconfig Ashley Dixon <ash@××××××××××.uk>