<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>41451</bug_id>
          
          <creation_ts>2021-11-27 20:00:12 +0300</creation_ts>
          <short_desc>Регрессия g++-11: некорректно генерируемый код с -fprofile-use --coverage</short_desc>
          <delta_ts>2021-11-28 15:59:30 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>gcc11-c++</component>
          <version>unstable</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andrew Savchenko">bircoph</reporter>
          <assigned_to name="Nobody&apos;s working on this, feel free to take it">nobody</assigned_to>
          <cc>iv</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>205387</commentid>
    <comment_count>0</comment_count>
    <who name="Andrew Savchenko">bircoph</who>
    <bug_when>2021-11-27 20:00:12 +0300</bug_when>
    <thetext>Следующая проблема наблюдается на g++-11, но отсутствует в g++-10:

$ cat test.cpp
include &lt;iostream&gt;

using namespace std;

int main() {
    cout &lt;&lt; &quot;42&quot; &lt;&lt; endl;

    return 0;
}

$ g++-11 -g -O1 -fprofile-generate --coverage test.cpp -o test
[builder@localhost simpletest-11]$ ./test
42
$ ./test
42
$ g++-11 -g -O1 -fprofile-use --coverage test.cpp -o test
$ rm test.gcda
$ ./test
42
Aborted
$ echo $?
134

Отладка в gdb:
Program received signal SIGABRT, Aborted.
0x00007ffff7ba542c in ?? ()
(gdb) bt
#0  0x00007ffff7ba542c in ?? ()
Backtrace stopped: Cannot access memory at address 0x7fffffffe0f0
(gdb) x/i 0x7fffffffe0f0
   0x7fffffffe0f0:      Cannot access memory at address 0x7fffffffe0f0
(gdb) x/i 0x00007ffff7ba542c
=&gt; 0x7ffff7ba542c:      Cannot access memory at address 0x7ffff7ba542c
(gdb)

Опция -g включалась для отладки и её наличие или отсутствие не влияет на проблему.

Минимальный уровень оптимизации для проявления бага -O1, проявляется также на -O2 и -O3.

Опции -fprofile-use и --coverage обязательны для воспроизведения проблемы.

На аналогичной последовательности действий g++-10 генерирует корректно работающий код:

$ ./test
42
$ echo $?
0

$ g++-11 --version
g++-11 (GCC) 11.2.1 20210911 (ALT Sisyphus 11.2.1-alt1)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++-10 --version
g++-10 (GCC) 10.3.1 20210703 (ALT Sisyphus 10.3.1-alt6)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

В общем, этот баг и словил simpletest, который не пересобирается сейчас в Сизифе. Мне придётся временно отключить эту проверку, но gcc нужно чинить.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>205388</commentid>
    <comment_count>1</comment_count>
    <who name="Andrew Savchenko">bircoph</who>
    <bug_when>2021-11-27 20:01:26 +0300</bug_when>
    <thetext>Проявляется как минимум на на i586 и x86_64. На остальных архитектурах не проверялось.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>