[Bug c/87525] New: infinite loop generated for fread() if enabling -flto

2018-10-04 Thread taz.007 at zoho dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87525

Bug ID: 87525
   Summary: infinite loop generated for fread() if enabling -flto
   Product: gcc
   Version: 7.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: taz.007 at zoho dot com
  Target Milestone: ---

Created attachment 44792
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44792&action=edit
screenshot of gdb with asm

When trying to compile flac with -flto enabled, it seems to generate an
infinite loop when the source code is calling fread();
If i remove the -flto flag, the generated code is no longer an infinite loop.
You can find in attachment a screenshot of the gdb screen with the faulty code.
Notice the loop at address 0xb7d16980
Also attached output of gcc -v -save-temps

[Bug c/87525] infinite loop generated for fread() if enabling -flto

2018-10-04 Thread taz.007 at zoho dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87525

--- Comment #1 from taz.007 at zoho dot com ---
Created attachment 44793
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44793&action=edit
text output of gcc -v -save-temps

[Bug c/87525] infinite loop generated for fread() if enabling -flto

2018-10-04 Thread taz.007 at zoho dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87525

--- Comment #2 from taz.007 at zoho dot com ---
Created attachment 44794
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44794&action=edit
preprocessed source

[Bug lto/87525] infinite loop generated for fread() if enabling -flto and -D_FORTIFY_SOURCE=2

2018-10-08 Thread taz.007 at zoho dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87525

--- Comment #6 from taz.007 at zoho dot com ---
Created attachment 44805
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44805&action=edit
script to build the shared lib

[Bug lto/87525] infinite loop generated for fread() if enabling -flto and -D_FORTIFY_SOURCE=2

2018-10-08 Thread taz.007 at zoho dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87525

taz.007 at zoho dot com changed:

   What|Removed |Added

  Attachment #44794|0   |1
is obsolete||

--- Comment #7 from taz.007 at zoho dot com ---
Created attachment 44806
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44806&action=edit
preprocessed file that triggers the issue

[Bug lto/87525] infinite loop generated for fread() if enabling -flto and -D_FORTIFY_SOURCE=2

2018-10-08 Thread taz.007 at zoho dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87525

--- Comment #8 from taz.007 at zoho dot com ---
I've been able to create a test case with just one file (not the same as the
first  one attached).
you can lookup the build.sh to know how i've build the shared library.
Once built, you can objdump -D libFLAC.so.8.3.0 | less and search for the
symbol fread.constprop.5 that is compiled as an infinite loop : 
25a0 :
25a0:   eb fe   jmp25a0 
25a2:   8d b4 26 00 00 00 00lea0x0(%esi,%eiz,1),%esi
25a9:   8d b4 26 00 00 00 00lea0x0(%esi,%eiz,1),%esi

Let me know if you need more information.