Bug 1076819

Summary: debugedit: Couldn't update relocation: invalid data (KMP build failure)
Product: [openSUSE] openSUSE Tumbleweed Reporter: Stefan Dirsch <sndirsch>
Component: OtherAssignee: Richard Biener <rguenther>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: Larry.Finger, mls, suse+build
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Stefan Dirsch 2018-01-19 13:58:35 UTC
How to reproduce:

$ alias iosc='osc -A https://api.suse.de'
$ iosc co Proprietary:X11:Drivers/nvidia-gfxG04
$ linux32 bash
$ cd Proprietary:X11:Drivers/nvidia-gfxG04
$ osc build openSUSE_Tumbleweed i586
[...]
[  294s] + /usr/lib/rpm/find-debuginfo.sh -j12 --build-id-seed 384.111-3.4 --unique-debug-suffix -384.111-3.4.i386 --unique-debug-src-base nvidia-gfxG04-384.111-3.4.i386 --run-dwz --dwz-low-mem-die-limit 10000000 --dwz-max-die-limit 50000000 -S debugsourcefiles.list /home/abuild/rpmbuild/BUILD/nvidia-gfxG04-384.111
[  294s] extracting debug info from /home/abuild/rpmbuild/BUILDROOT/nvidia-gfxG04-384.111-3.4.i386/lib/modules/4.14.13-1-default/updates/nvidia-modeset.ko
[  294s] extracting debug info from /home/abuild/rpmbuild/BUILDROOT/nvidia-gfxG04-384.111-3.4.i386/lib/modules/4.14.13-1-default/updates/nvidia-drm.ko
[  294s] extracting debug info from /home/abuild/rpmbuild/BUILDROOT/nvidia-gfxG04-384.111-3.4.i386/lib/modules/4.14.13-1-pae/updates/nvidia-drm.ko
[  294s] extracting debug info from /home/abuild/rpmbuild/BUILDROOT/nvidia-gfxG04-384.111-3.4.i386/lib/modules/4.14.13-1-pae/updates/nvidia-modeset.ko
[  294s] extracting debug info from /home/abuild/rpmbuild/BUILDROOT/nvidia-gfxG04-384.111-3.4.i386/lib/modules/4.14.13-1-default/updates/nvidia.ko
[  294s] extracting debug info from /home/abuild/rpmbuild/BUILDROOT/nvidia-gfxG04-384.111-3.4.i386/lib/modules/4.14.13-1-pae/updates/nvidia.ko
[  294s] /usr/lib/rpm/debugedit: Couldn't update relocation: invalid data
[  294s] /usr/lib/rpm/debugedit: Couldn't update relocation: invalid data
[  294s] /usr/lib/rpm/debugedit: Couldn't update relocation: invalid data
[  294s] /usr/lib/rpm/debugedit: Couldn't update relocation: invalid data
[  294s] /usr/lib/rpm/debugedit: Couldn't update relocation: invalid data
[  294s] /usr/lib/rpm/debugedit: Couldn't update relocation: invalid data
[  294s] /usr/lib/rpm/find-debuginfo.sh: line 511: /tmp/find-debuginfo.fibvwE/res.*: No such file or directory
Comment 1 Stefan Dirsch 2018-01-19 14:05:14 UTC
This was still working on 2018-01-08 in our internal buildservice.
Comment 2 Richard Biener 2018-01-19 14:15:38 UTC
I think mls simply dropped some required fixes for debugediting the dwarf line tables (debugedit-canon-fix.diff, the edit_dwarf2_line hunks).  The relevant
function seems to have been rewritten completely with as much (no) documentation
as before ... :/

I'll see on monday to confirm this and "forward port" the fix I did last year.
Comment 3 Larry Finger 2018-01-19 16:46:36 UTC
I will not try to supply a test case as the VirtualBox build takes about 45 minutes on an i7 with SSD to reach the failure point.

Thanks for checking this problem.
Comment 4 Richard Biener 2018-01-22 09:44:52 UTC
So the specific bug I was pointing out is avoided by the rewrite.  They still seem to copy "garbage" at the end of the file table though.

I'll see to debug this some more.
Comment 5 Richard Biener 2018-01-22 11:19:23 UTC
(gdb) p r_offset
$8 = 4294971687

(gdb) p dso->lines.table[lndx]  
$37 = {old_idx = 0, new_idx = 0, size_diff = -12, replace_dirs = true, 
  replace_files = false, unit_length = 4759, version = 2, 
  header_length = 4390, min_instr_len = 1 '\001', 
  max_op_per_instr = 186 '\272', default_is_stmt = 1 '\001', 
  line_base = -5 '\373', line_range = 14 '\016', opcode_base = 13 '\r'}

size_diff is -12 but as the expression is computed unsigned we end up with
r_offset zero-extended as r_offset is unsinged long long but the difference
we compute is unsigned int (in the 32bit debugedit case).

Thus a debugedit issue.

Fix:

--- tools/debugedit.c.orig      2018-01-22 12:09:07.477955907 +0100
+++ tools/debugedit.c   2018-01-22 12:09:22.210197759 +0100
@@ -2154,9 +2154,9 @@
                      /* Offset (pointing into the line program) moves
                         from old to new index including the header
                         size diff. */
-                     r_offset += ((dso->lines.table[lndx].new_idx
-                                   - dso->lines.table[lndx].old_idx)
-                                  + dso->lines.table[lndx].size_diff);
+                     r_offset += (ssize_t)((dso->lines.table[lndx].new_idx
+                                            - dso->lines.table[lndx].old_idx)
+                                           + dso->lines.table[lndx].size_diff);
 
                      if (rtype == SHT_RELA)
                        {

will commit to Base:System and SR to Factory.
Comment 6 Richard Biener 2018-01-22 11:22:05 UTC
SR#568109
Comment 7 Richard Biener 2018-01-22 11:26:53 UTC
mls, please forward upstream.
Comment 8 Swamp Workflow Management 2018-01-22 12:00:06 UTC
This is an autogenerated message for OBS integration:
This bug (1076819) was mentioned in
https://build.opensuse.org/request/show/568109 Factory / rpm
Comment 9 Michael Schröder 2018-01-22 12:48:06 UTC
Thanks for debugging and fixing this!
Comment 10 Swamp Workflow Management 2018-01-22 12:50:06 UTC
This is an autogenerated message for OBS integration:
This bug (1076819) was mentioned in
https://build.opensuse.org/request/show/568126 Factory / rpm
Comment 11 Richard Biener 2018-02-01 12:34:42 UTC
*** Bug 1076650 has been marked as a duplicate of this bug. ***
Comment 12 Stefan Dirsch 2018-02-05 11:12:36 UTC
Fix is meanwhile in TW/Factory. Closing as such.
Comment 13 Arjen de Korte 2018-02-05 11:19:09 UTC
(In reply to Richard Biener from comment #11)
> *** Bug 1076650 has been marked as a duplicate of this bug. ***

I reopened #1076650, since the issue mentioned in that bug is not fixed by https://build.opensuse.org/request/show/568126