Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 892872 - app-emulation/xen-tools-4.15.4-r1[ovmf]: fails to compile with gcc-12 (GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free])
Summary: app-emulation/xen-tools-4.15.4-r1[ovmf]: fails to compile with gcc-12 (GenFfs...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Tomáš Mózes
URL: https://github.com/tianocore/edk2/com...
Whiteboard:
Keywords: PATCH, PullRequest
Depends on:
Blocks: gcc-12
  Show dependency tree
 
Reported: 2023-02-02 00:23 UTC by Konstantin
Modified: 2023-04-19 06:07 UTC (History)
5 users (show)

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


Attachments
emerge --info (emerge-info-app-emulation_xen-tools-4.15.4-r1.txt,6.34 KB, text/plain)
2023-02-02 00:24 UTC, Konstantin
Details
environment (environment.txt,124.72 KB, text/plain)
2023-02-02 00:29 UTC, Konstantin
Details
duplicate emerge-info file attached (emerge-info-app-emulation_xen-tools-4.15.4-r1.txt,6.34 KB, text/plain)
2023-02-02 00:30 UTC, Konstantin
Details
app-emulation_xen-tools-4.15.4-r1 build.log file (app-emulation_xen-tools-4.15.4-r1_build.log.zip,42.33 KB, application/zip)
2023-02-02 00:35 UTC, Konstantin
Details
Build Log for 4.16.3 (build_4.16.3.log.gz,38.11 KB, application/gzip)
2023-02-12 01:25 UTC, John L. Poole
Details
environment for 4.16.3 attempt to build xen-tools (environment_4.16.3.txt.gz,30.63 KB, application/gzip)
2023-02-12 01:26 UTC, John L. Poole
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin 2023-02-02 00:23:39 UTC
After an upgrade to the current stable version of sys-devel/gcc-12.2.1_p20230121-r1 I couldn't rebuild current stable version of app-emulation/xen-tools-4.15.4-r1 ebuild with USE="ovmf" flag.

Reproducible: Always

Steps to Reproduce:
1. Install the latest sys-devel/gcc-12.2.1_p20230121-r1 ebuild and update profile accordingly using "gcc-config 2 && . /etc/profile" commands;
2. Run xen-tools package compilation with "USE="ovmf" emerge =app-emulation/xen-tools-4.15.4-r1";

Actual Results:  
app-emulation/xen-tools-4.15.4-r1 ebuild compilations fails at compile phase:

...
make[9]: Entering directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware/ovmf-dir-remote/BaseTools/Source/C/GenFfs'
gcc  -c  -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/ -MD -fshort-wchar -fno-strict-aliasing -fwrapv -fno-delete-null-pointer-checks -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict
 -Wno-unused-result -nostdlib -g -O2  GenFfs.c -o GenFfs.o
In function ‘GetAlignmentFromFile’,
    inlined from ‘main’ at GenFfs.c:816:20:
GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free]
  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GenFfs.c:544:5: note: call to ‘fclose’ here
  544 |     fclose (InFileHandle);                                                                                                                                                                                                                                                                  |     ^~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[9]: *** [../Makefiles/footer.makefile:21: GenFfs.o] Error 1
make[9]: Leaving directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware/ovmf-dir-remote/BaseTools/Source/C/GenFfs'
make[8]: *** [GNUmakefile:76: GenFfs] Error 2
make[8]: Leaving directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware/ovmf-dir-remote/BaseTools/Source/C'
make[7]: *** [GNUmakefile:19: Source/C] Error 2
make[7]: Leaving directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware/ovmf-dir-remote/BaseTools'
make[6]: *** [Makefile:20: build] Error 2                                                                                                                                                                                                                                                     make[6]: Leaving directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware/ovmf-dir-remote'
make[5]: *** [/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware/../../tools/Rules.mk:161: subdir-all-ovmf-dir] Error 2
make[5]: Leaving directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware'
make[4]: *** [/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware/../../tools/Rules.mk:156: subdirs-all] Error 2
make[4]: Leaving directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware'
make[3]: *** [Makefile:37: all] Error 2
make[3]: Leaving directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware'
make[2]: *** [/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/../tools/Rules.mk:161: subdir-all-firmware] Error 2
make[2]: Leaving directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools'
make[1]: *** [/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/../tools/Rules.mk:156: subdirs-all] Error 2
make[1]: Leaving directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools'
make: *** [Makefile:63: build-tools] Error 2
 * ERROR: app-emulation/xen-tools-4.15.4-r1::gentoo failed (compile phase):
 *   emake failed
...

Expected Results:  
"USE="ovmf" emerge =app-emulation/xen-tools-4.15.4-r1" command completes successfully.

If I omit "ovmf" USE-flag or rollback to gcc:11 "sys-devel/gcc-11.3.1_p20221209" then compilation succeeds.
Comment 1 Konstantin 2023-02-02 00:24:42 UTC
Created attachment 849656 [details]
emerge --info
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-02 00:27:00 UTC
Can you include the full build.log too please? Thanks.
Comment 3 Konstantin 2023-02-02 00:29:03 UTC
Created attachment 849658 [details]
environment
Comment 4 Konstantin 2023-02-02 00:30:57 UTC
Created attachment 849660 [details]
duplicate emerge-info file attached
Comment 5 Konstantin 2023-02-02 00:32:10 UTC
Comment on attachment 849660 [details]
duplicate emerge-info file attached

build.log exceeded file size limit. This is the wrong file.
Comment 6 Konstantin 2023-02-02 00:35:02 UTC
Created attachment 849662 [details]
app-emulation_xen-tools-4.15.4-r1 build.log file

full build log file
Comment 7 Konstantin 2023-02-02 00:37:29 UTC
(In reply to Sam James from comment #2)
> Can you include the full build.log too please? Thanks.

Absolutely. Full build.log file was attached. Thank you.
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-04 22:03:50 UTC
See https://edk2.groups.io/g/devel/message/87983.
Comment 9 John L. Poole 2023-02-11 23:40:03 UTC
I ran into this problem, too.

...
make[9]: Entering directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware/ovmf-dir-remote/BaseTools/Source/C/GenFfs'
gcc  -c  -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/ -MD -fshort-wchar -fno-strict-aliasing -fwrapv -fno-delete-null-pointer-checks -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -g -O2  GenFfs.c -o GenFfs.o
In function ‘GetAlignmentFromFile’,
    inlined from ‘main’ at GenFfs.c:816:20:
GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free]
  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GenFfs.c:544:5: note: call to ‘fclose’ here
  544 |     fclose (InFileHandle);
      |     ^~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[9]: *** [../Makefiles/footer.makefile:21: GenFfs.o] Error 1
make[9]: Leaving directory '/var/tmp/portage/app-emulation/xen-tools-4.15.4-r1/work/xen-4.15.4/tools/firmware/ovmf-dir-remote/BaseTools/Source/C/GenFfs'
Comment 10 John L. Poole 2023-02-12 01:22:17 UTC
I tried to finesse this by trying the currently unstable branch of xen and xen-tools:

ACCEPT_KEYWORDS="~amd64" emerge =app-emulation/xen-4.16.3

And the result was the same: xen-tools failed as the same spot.  

I'll try making a patch based upon the lead of Sam James in his Comment #8 and report.
Comment 11 John L. Poole 2023-02-12 01:25:49 UTC
Created attachment 850408 [details]
Build Log for 4.16.3

Same failure as in 4.15.4.
Comment 12 John L. Poole 2023-02-12 01:26:28 UTC
Created attachment 850410 [details]
environment for 4.16.3 attempt to build xen-tools
Comment 13 John L. Poole 2023-02-12 01:28:06 UTC
hmmm... should I open a separate bug for 4.16.3 and place my files there?  I'm not sure on the protocol when the same bug affects two different versions.
Comment 14 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-04-18 13:35:35 UTC
(In reply to John L. Poole from comment #13)
> hmmm... should I open a separate bug for 4.16.3 and place my files there? 
> I'm not sure on the protocol when the same bug affects two different
> versions.

No, it's ok as-is. 

tomáš, can you take a look? I can handle it if not, but I'll be doing it blind (just checking the patch applies & looks sensible).
Comment 15 Tomáš Mózes 2023-04-18 15:12:02 UTC
Seems like it compiles with latest ovmf snapshot, can you please test https://github.com/gentoo/gentoo/pull/30642?

Thanks!
Comment 16 Larry the Git Cow gentoo-dev 2023-04-19 06:07:42 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3ac65c3cafe4259c50ec0c05a7ce755af950dc1d

commit 3ac65c3cafe4259c50ec0c05a7ce755af950dc1d
Author:     Tomáš Mózes <hydrapolic@gmail.com>
AuthorDate: 2023-04-18 15:07:03 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-04-19 06:06:47 +0000

    app-emulation/xen-tools: use latest ovmf snapshot
    
    Closes: https://github.com/gentoo/gentoo/pull/30642
    Closes: https://bugs.gentoo.org/892872
    Signed-off-by: Tomáš Mózes <hydrapolic@gmail.com>
    Signed-off-by: Sam James <sam@gentoo.org>

 app-emulation/xen-tools/Manifest                   |  3 +++
 .../xen-tools/xen-tools-4.16.4_pre1.ebuild         | 25 +++++++---------------
 .../xen-tools/xen-tools-4.17.1_pre1.ebuild         | 15 +++----------
 3 files changed, 14 insertions(+), 29 deletions(-)