Bug 22205

Summary: grub-0.97-45.mga7 reboots when starting stage2
Product: Mageia Reporter: Pascal Terjan <pterjan>
Component: RPM PackagesAssignee: Base system maintainers <basesystem>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: marja11, thierry.vignaud
Version: Cauldron   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: grub CVE:
Status comment:

Description Pascal Terjan 2017-12-15 23:13:59 CET
Easy way to reproduce:

cat /lib/grub/x86_64-mageia/stage[12] > grub_disk
qemu-system-x86_64 -hda grub_disk -nographic -no-reboot

With previous version you get grub prompt and can type reboot to quit.
With broken version it just exists by itself after displaying "GRUB Loading stage2." (successful version prints 2 more dots too).

Changing the spec to use -O0 instead of -Os fixes the problem.
Comment 1 Pascal Terjan 2017-12-15 23:16:16 CET
-O1 also fixes the problem
Comment 2 Pascal Terjan 2017-12-15 23:18:29 CET
Quite a few optimizations to try to disable:

[pterjan@mageia grub]$ gcc-7.2.2 -c -Q -Os --help=optimizers > /tmp/Os-opts
[pterjan@mageia grub]$ gcc-7.2.2 -c -Q -O1 --help=optimizers > /tmp/O1-opts
[pterjan@mageia grub]$ diff /tmp/O1-opts /tmp/Os-opts
9c9
<   -falign-labels              		[disabled]
---
>   -falign-labels              		[enabled]
19,20c19,20
<   -fcaller-saves              		[disabled]
<   -fcode-hoisting             		[disabled]
---
>   -fcaller-saves              		[enabled]
>   -fcode-hoisting             		[enabled]
25,26c25,26
<   -fcrossjumping              		[disabled]
<   -fcse-follow-jumps          		[disabled]
---
>   -fcrossjumping              		[enabled]
>   -fcse-follow-jumps          		[enabled]
34,35c34,35
<   -fdevirtualize              		[disabled]
<   -fdevirtualize-speculatively 		[disabled]
---
>   -fdevirtualize              		[enabled]
>   -fdevirtualize-speculatively 		[enabled]
39c39
<   -fexpensive-optimizations   		[disabled]
---
>   -fexpensive-optimizations   		[enabled]
47c47
<   -fgcse                      		[disabled]
---
>   -fgcse                      		[enabled]
56c56
<   -fhoist-adjacent-loads      		[disabled]
---
>   -fhoist-adjacent-loads      		[enabled]
59c59
<   -findirect-inlining         		[disabled]
---
>   -findirect-inlining         		[enabled]
62c62
<   -finline-functions          		[disabled]
---
>   -finline-functions          		[enabled]
64,66c64,66
<   -finline-small-functions    		[disabled]
<   -fipa-bit-cp                		[disabled]
<   -fipa-cp                    		[disabled]
---
>   -finline-small-functions    		[enabled]
>   -fipa-bit-cp                		[enabled]
>   -fipa-cp                    		[enabled]
68,70c68,70
<   -fipa-icf                   		[disabled]
<   -fipa-icf-functions         		[disabled]
<   -fipa-icf-variables         		[disabled]
---
>   -fipa-icf                   		[enabled]
>   -fipa-icf-functions         		[enabled]
>   -fipa-icf-variables         		[enabled]
74c74
<   -fipa-ra                    		[disabled]
---
>   -fipa-ra                    		[enabled]
76,77c76,77
<   -fipa-sra                   		[disabled]
<   -fipa-vrp                   		[disabled]
---
>   -fipa-sra                   		[enabled]
>   -fipa-vrp                   		[enabled]
85c85
<   -fisolate-erroneous-paths-dereference 	[disabled]
---
>   -fisolate-erroneous-paths-dereference 	[enabled]
95c95
<   -flra-remat                 		[disabled]
---
>   -flra-remat                 		[enabled]
104c104
<   -foptimize-sibling-calls    		[disabled]
---
>   -foptimize-sibling-calls    		[enabled]
108c108
<   -fpartial-inlining          		[disabled]
---
>   -fpartial-inlining          		[enabled]
111c111
<   -fpeephole2                 		[disabled]
---
>   -fpeephole2                 		[enabled]
120,123c120,123
<   -freorder-blocks-algorithm=[simple|stc] 	simple
<   -freorder-blocks-and-partition 	[disabled]
<   -freorder-functions         		[disabled]
<   -frerun-cse-after-loop      		[disabled]
---
>   -freorder-blocks-algorithm=[simple|stc] 	stc
>   -freorder-blocks-and-partition 	[enabled]
>   -freorder-functions         		[enabled]
>   -frerun-cse-after-loop      		[enabled]
145c145
<   -fschedule-insns2           		[disabled]
---
>   -fschedule-insns2           		[enabled]
172,173c172,173
<   -fstore-merging             		[disabled]
<   -fstrict-aliasing           		[disabled]
---
>   -fstore-merging             		[enabled]
>   -fstrict-aliasing           		[enabled]
175c175
<   -fstrict-overflow           		[disabled]
---
>   -fstrict-overflow           		[enabled]
177c177
<   -fthread-jumps              		[disabled]
---
>   -fthread-jumps              		[enabled]
205c205
<   -ftree-pre                  		[disabled]
---
>   -ftree-pre                  		[enabled]
213,214c213,214
<   -ftree-switch-conversion    		[disabled]
<   -ftree-tail-merge           		[disabled]
---
>   -ftree-switch-conversion    		[enabled]
>   -ftree-tail-merge           		[enabled]
217c217
<   -ftree-vrp                  		[disabled]
---
>   -ftree-vrp                  		[enabled]
229c229
<   Specifies the cost model for vectorization. -fvect-cost-model=[unlimited|dynamic|cheap] 	[default]
---
>   Specifies the cost model for vectorization. -fvect-cost-model=[unlimited|dynamic|cheap] 	cheap
Comment 3 Pascal Terjan 2017-12-15 23:33:07 CET
Now this is interesting, it is still broken with disabling them all:

-Os -g -fno-strict-aliasing -fno-stack-protector -fno-reorder-functions -fno-inline-functions -fno-reorder-blocks-and-partition -fno-schedule-insns2 -freorder-blocks-algorithm=simple
 -fno-tree-tail-merge -fno-tree-switch-conversion -fno-tree-vrp -fno-tree-pre -fno-thread-jumps -fno-strict-overflow -fno-store-merging -fno-rerun-cse-after-loop -fno-peephole2 -fno-partial-
inlining -fno-optimize-sibling-calls -fno-lra-remat -fno-isolate-erroneous-paths-dereference -fno-ipa-vrp -fno-ipa-sra -fno-ipa-ra -fno-ipa-icf-variables -fno-ipa-icf-functions -fno-ipa-icf 
-fno-ipa-cp -fno-ipa-bit-cp -fno-inline-small-functions -fno-indirect-inlining -fno-hoist-adjacent-loads -fno-align-labels -fno-caller-saves -fno-code-hoisting -fno-crossjumping -fno-cse-fol
low-jumps -fno-devirtualize -fno-devirtualize-speculatively -fno-expensive-optimizations -fno-gcse
Comment 4 Marja Van Waes 2017-12-16 09:01:51 CET
Assigning to all packagers collectively, since there is no registered maintainer for grub.

Assignee: bugsquad => pkg-bugs
CC: (none) => marja11

Comment 5 Marja Van Waes 2017-12-16 09:03:44 CET
Although it would probably make more sense to assign it to the basesystem maintainers... reassigning.

It would really be great if http://pkgsubmit.mageia.org/data/maintdb.txt would show the maintainer groups of the packages that belong to such a group!

Assignee: pkg-bugs => basesystem

Comment 6 Pascal Terjan 2017-12-16 16:10:33 CET
More interestingly, -O2 works fine too and:

But -O2 works while -Os -fno-inline-functions -foptimize-strlen doesn't and I don't know how to find other differences

I updated the package to use -O2 for now so that users don't end up with a non bootable machine
Comment 7 Pascal Terjan 2017-12-17 15:35:50 CET
I did a bit more exeprimenting and only stage2/common.c breaks with -Os
Comment 8 Thierry Vignaud 2018-11-26 15:53:45 CET
Fixed in 0.97-47.mga7 one year ago

Status: NEW => RESOLVED
CC: (none) => thierry.vignaud
Resolution: (none) => FIXED