Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 462740 - sys-boot/grub-2.00-r2 fails to perform grub2-install, while grub2-probe running endlessly
Summary: sys-boot/grub-2.00-r2 fails to perform grub2-install, while grub2-probe runni...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Mike Gilbert
URL: https://github.com/maxximino/grub2/is...
Whiteboard: Regression in nvlist_find_value()
Keywords: Bug, REGRESSION, REVIEWED
Depends on:
Blocks:
 
Reported: 2013-03-23 03:16 UTC by 颜烈彬
Modified: 2013-04-27 20:57 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
log from grub2-probe (2.00-r2) (grub2log,18.87 KB, text/plain)
2013-04-16 21:05 UTC, Jürgen Geuter
Details
Patch to revert unnecessary nvlist_find_value() rewrite (grub-2.00-zfs.patch,2.50 KB, patch)
2013-04-18 01:56 UTC, Richard Yao (RETIRED)
Details | Diff
Tentative patch for fixing the problem with current code. (83aabc190e95860437fdb848461b16202b8cbb79.patch,1.20 KB, patch)
2013-04-25 16:33 UTC, Massimo Maggi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description 颜烈彬 2013-03-23 03:16:32 UTC
Top showed that grub2-probe took up 100%+- cpu usage, when running grub2-install, and they never stopped.
However sys-boot/grub-2.00-r1 is fine to perform grub2-install.
PS. The root partition is of Reiserfs and /boot is not separated.

Reproducible: Always

Steps to Reproduce:
1. install sys-boot/grub-2.00-r2
2. do grub2-install /dev/sda
3.
Actual Results:  
grub2-install keeps running

Expected Results:  
grub2-install should finish execution and ehco "Installation finished. No error reported."
Comment 1 Mike Gilbert gentoo-dev 2013-03-23 03:24:20 UTC
Are you absolutely certain that -r1 works fine, and -r2 does not?
Comment 2 micbal 2013-04-04 12:43:09 UTC
Grub2 installation fails.

grub2-install --no-floppy /dev/sda
Path `/boot/grub2' is not readable by GRUB on boot. Installation is impossible. Aborting.

Gpt and mdadm soft raid, metadata 0.90.

lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda       8:0    0 931.5G  0 disk  
├─sda1    8:1    0   256M  0 part  
├─sda2    8:2    0   256M  0 part  
│ └─md1   9:1    0   256M  0 raid1 /boot
├─sda3    8:3    0   100G  0 part  
│ └─md2   9:2    0   100G  0 raid1 /
├─sda4    8:4    0     8G  0 part  
│ └─md3   9:3    0     8G  0 raid1 [SWAP]
└─sda5    8:5    0   823G  0 part  
  └─md4   9:4    0   823G  0 raid1 
sr0      11:0    1 389.8M  0 rom   
loop0     7:0    0 294.9M  1 loop

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          526335   256.0 MiB   EF02  BIOS boot partition
   2          526336         1050623   256.0 MiB   FD00  Linux RAID
   3         1050624       210765823   100.0 GiB   FD00  Linux RAID
   4       210765824       227543039   8.0 GiB     FD00  Linux RAID
   5       227543040      1953525134   823.0 GiB   FD00  Linux RAID
Comment 3 micbal 2013-04-04 12:46:06 UTC
grub2-probe -t fs /boot/grub2
grub2-probe: error: unknown filesystem.
Comment 4 Mike Gilbert gentoo-dev 2013-04-04 14:30:49 UTC
(In reply to comment #2)

Your issue seems to be unrelated.

I suggest you ask for help in #grub on Freenode or on the help-grub mailing list.

http://www.gnu.org/software/grub/grub-mailinglist.html
Comment 5 Jürgen Geuter 2013-04-16 21:05:55 UTC
Created attachment 345732 [details]
log from grub2-probe (2.00-r2)

Same bug here as the original poster.

I can confirm that grub-2.00-r1 works flawlessly and grub-2.00-r1 hangs infinitely. 

"grub2-probe -d /dev/sda1 -vvv" from the grub-2.00-r2 version gives the attached output

Basically it ends with:

grub-core/kern/emu/hostdisk.c:886: reusing open device `/dev/sda1'
grub-core/kern/emu/hostdisk.c:886: reusing open device `/dev/sda1'
grub-core/fs/zfs/zfs.c:953: check 2 passed

here it hangs, so it might be connected to some zfs detection code?
Comment 6 Mike Gilbert gentoo-dev 2013-04-16 21:44:36 UTC
ryao: I believe I said I would be sending any bugs relating to this patch in your direction. :)
Comment 7 Richard Yao (RETIRED) gentoo-dev 2013-04-18 00:36:24 UTC
Would someone affected by this post the output of `emerge --info grub:2`?
Comment 8 Richard Yao (RETIRED) gentoo-dev 2013-04-18 01:15:14 UTC
Actually, could we also get a backtrace?

# Rebuild grub:2 with debug information:
USE=custom-cflags FEATURES='-buildpkg -ccache installsources nostrip splitdebug' CFLAGS='-O0 -ggdb3' emerge -1va grub:2

# Start gdb
gdb grub2-probe

# Run grub2-probe
run -d /dev/sda1 -vvv

# Type Ctrl+C to get a prompt back.
bt

Please post what the `bt` command to gdb prints.
Comment 9 Richard Yao (RETIRED) gentoo-dev 2013-04-18 01:56:55 UTC
Created attachment 345844 [details, diff]
Patch to revert unnecessary nvlist_find_value() rewrite

After analyzing the log, it looks like we have an infinite loop in nvlist_find_value(). That was rewritten to better match the Illumos GRUB code in the following patch from the patch set that was squashed to create the feature flags patch:

https://github.com/maxximino/grub2/commit/58344034e40218b20500fa2936eb4d7d019e1e88

Unfortunately, I have spotted some subtle issues with the rewrite of this function, which might or might not explain this issue. Without the backtrace, it is difficult to tell for certain. However, this change was unnecessary, so it is safe to revert. I have attached a patch that does this. Please drop it into /etc/portage/patches/sys-boot/grub-2.00-r2/grub-2.00-zfs.patch, rebuild grub:2 and let me know what happens.
Comment 10 Jürgen Geuter 2013-04-20 11:16:25 UTC
With the patch applied grub2-probe works fine. 

Do you need some debug output?
Comment 11 Richard Yao (RETIRED) gentoo-dev 2013-04-24 19:36:36 UTC
(In reply to comment #10)
> With the patch applied grub2-probe works fine. 
> 
> Do you need some debug output?

That is everything that we needed to know. Thanks.

I am CCing Massimo Maggi. He is the person who ported the feature flags support from Illumos. I have also opened an issue on the maxximino/grub2 bug tracker for this.

As I said on the upstream bug tracker:

The nvlist_find_value() rewrite caused a regression in grub2-probe on non-ZFS systems. It seems that systems that happen to have a correct magic number in the right place will be handled as if they had proper nvlists, even when the data is nonsense. This can cause an infinite loop.

With that said, I would have reverted the nvlist handling changes to avoid affecting grub2-probe had it occurred to me that it relied upon it. I will talk to floppym about how we will correct this issue. It will most likely involve an ebuild revision with a new version of the feature flags patch applied.
Comment 12 Richard Yao (RETIRED) gentoo-dev 2013-04-24 22:41:27 UTC
I have committed files/grub-2.00-zfs-feature-flag-support-r1.patch to the main tree in preparation for sys-boot/grub-2.00-r3. I am reassigning the bug to Mike Gilbert for resolution.
Comment 13 Massimo Maggi 2013-04-25 16:33:25 UTC
Created attachment 346592 [details, diff]
Tentative patch for fixing the problem with current code.

I'm not able to reproduce the problem, however I've found a possibile root cause of this problem.
There is someone affected by this problem that wants to help me in testing the attached patch? The problem *might* also affect upstream code.
Also, a debug log (grub2-probe -d /dev/sda1 -vvv) of a WORKING grub on the affected partition is appreciated.
Thanks.
Comment 14 Mike Gilbert gentoo-dev 2013-04-27 20:57:00 UTC
+*grub-2.00-r3 (27 Apr 2013)
+
+  27 Apr 2013; Mike Gilbert <floppym@gentoo.org> +files/grub-2.00-dmraid.patch,
+  +files/grub-2.00-texinfo.patch, +grub-2.00-r3.ebuild:
+  Resolve infinte-loop in grub-probe #462740 and fix dmraid support #430748.
+  Also fix issue with texinfo-5.1.
+