<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic segfault reading from piped stdin on centos7.2 in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065762#M118416</link>
    <description>&lt;P&gt;I'm getting a buffer overflow detected segfault when reading from stdin via a pipe on centos7.2.&amp;nbsp; Works on ubuntu 14.04.&amp;nbsp; Works on both when compiled with gfortran. The ubuntu machines has the compiler installed.&amp;nbsp; SELinux is enforcing but same result when permissive.&lt;/P&gt;

&lt;P&gt;ifort (IFORT) 16.0.2 20160204&lt;/P&gt;

&lt;P&gt;test program&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program a
 implicit none
 integer :: b

 read(*,*) b
 print *,b

 stop
end
&lt;/PRE&gt;

&lt;P&gt;Compiled with (also tried -assume old_unit_star with no difference)&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;ifort -O0 -debug -static a.f90&lt;/PRE&gt;

&lt;P&gt;when run with&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;echo 1 | ./a.out&lt;/PRE&gt;

&lt;P&gt;produces segfault&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;*** buffer overflow detected ***: ./a.out terminated
======= Backtrace: =========
[0x4a368b]
[0x4d7552]
[0x4d74ee]
[0x4d6f09]
[0x4a958c]
[0x4e6628]
[0x4d6f8c]
[0x4d6eed]
[0x44dbdf]
[0x44daac]
[0x44ec19]
[0x43b8bd]
[0x4059ea]
[0x401128]
[0x4010ae]
[0x49844c]
[0x400f97]
======= Memory map: ========
00400000-0057e000 r-xp 00000000 00:2d 110493698                          /m/work/kgore4/a.a/a.out
0077d000-00783000 rw-p 0017d000 00:2d 110493698                          /m/work/kgore4/a.a/a.out
00783000-007a7000 rw-p 00000000 00:00 0
021ec000-0220f000 rw-p 00000000 00:00 0                                  [heap]
7f28195fe000-7f28195ff000 rw-p 00000000 00:00 0
7ffe6e79d000-7ffe6e7be000 rw-p 00000000 00:00 0                          [stack]
7ffe6e7d1000-7ffe6e7d3000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source
a.out              000000000047CE95  Unknown               Unknown  Unknown
a.out              000000000047AAB7  Unknown               Unknown  Unknown
a.out              000000000044C2F4  Unknown               Unknown  Unknown
a.out              000000000044C106  Unknown               Unknown  Unknown
a.out              000000000042AD76  Unknown               Unknown  Unknown
a.out              00000000004012F0  Unknown               Unknown  Unknown
a.out              0000000000497DA0  Unknown               Unknown  Unknown
a.out              000000000049EE77  Unknown               Unknown  Unknown
a.out              00000000004A3690  Unknown               Unknown  Unknown
a.out              00000000004D7552  Unknown               Unknown  Unknown
a.out              00000000004D74EE  Unknown               Unknown  Unknown
a.out              00000000004D6F09  Unknown               Unknown  Unknown
a.out              00000000004A958C  Unknown               Unknown  Unknown
a.out              00000000004E6628  Unknown               Unknown  Unknown
a.out              00000000004D6F8C  Unknown               Unknown  Unknown
a.out              00000000004D6EED  Unknown               Unknown  Unknown
a.out              000000000044DBDF  Unknown               Unknown  Unknown
a.out              000000000044DAAC  Unknown               Unknown  Unknown
a.out              000000000044EC19  Unknown               Unknown  Unknown
a.out              000000000043B8BD  Unknown               Unknown  Unknown
a.out              00000000004059EA  Unknown               Unknown  Unknown
a.out              0000000000401128  Unknown               Unknown  Unknown
a.out              00000000004010AE  Unknown               Unknown  Unknown
a.out              000000000049844C  Unknown               Unknown  Unknown
a.out              0000000000400F97  Unknown               Unknown  Unknown
&lt;/PRE&gt;

&lt;P&gt;strace seems to be the same until getpid is called where ubuntu returned 8283 and went on to read the 1 and \n.&amp;nbsp; centos returned 1997017 and went straight into the error above.&amp;nbsp; I wonder if that pid tried to go into a 16bit int?&amp;nbsp; /proc/sys/kernel/pid_max is 4194303 on centos7 and 32768 on ubuntu.&lt;/P&gt;

&lt;P&gt;EDIT: On further testing, it may not the pid.&amp;nbsp; Adding an explicit call to getpid() and a print above the read lets it get past the getpid.&lt;/P&gt;

&lt;P&gt;The difference in strace between running it with the pipe and without is&lt;/P&gt;

&lt;P&gt;ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffc321491e0) = -1 ENOTTY (Inappropriate ioctl for device)&lt;/P&gt;

&lt;P&gt;If I put the 1 into a real file and do "cat testinput | ./a.out" it still crashes.&amp;nbsp; also with "./a.out &amp;lt;testinput".&lt;/P&gt;

&lt;P&gt;EDIT2: add gdb backtrace after the segfault&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;(gdb) bt
#0  0x000000000049ee77 in abort ()
#1  0x00000000004a3690 in __libc_message ()
#2  0x00000000004d7552 in __fortify_fail ()
#3  0x00000000004d74ee in __chk_fail ()
#4  0x00000000004d6f09 in _IO_str_chk_overflow ()
#5  0x00000000004a958c in _IO_default_xsputn ()
#6  0x00000000004e6628 in vfprintf ()
#7  0x00000000004d6f8c in __vsprintf_chk ()
#8  0x00000000004d6eed in __sprintf_chk ()
#9  0x000000000044d089 in for__compute_filename ()
#10 0x000000000044ec19 in for__open_proc ()
#11 0x000000000043b8bd in for__open_default ()
#12 0x00000000004059ea in for_read_seq_lis ()
#13 0x0000000000401128 in a () at a.f90:5
#14 0x00000000004010ae in main ()
#15 0x000000000049844c in __libc_start_main ()
#16 0x0000000000400f97 in _start ()
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2016 04:44:48 GMT</pubDate>
    <dc:creator>kgore4</dc:creator>
    <dc:date>2016-03-30T04:44:48Z</dc:date>
    <item>
      <title>segfault reading from piped stdin on centos7.2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065762#M118416</link>
      <description>&lt;P&gt;I'm getting a buffer overflow detected segfault when reading from stdin via a pipe on centos7.2.&amp;nbsp; Works on ubuntu 14.04.&amp;nbsp; Works on both when compiled with gfortran. The ubuntu machines has the compiler installed.&amp;nbsp; SELinux is enforcing but same result when permissive.&lt;/P&gt;

&lt;P&gt;ifort (IFORT) 16.0.2 20160204&lt;/P&gt;

&lt;P&gt;test program&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program a
 implicit none
 integer :: b

 read(*,*) b
 print *,b

 stop
end
&lt;/PRE&gt;

&lt;P&gt;Compiled with (also tried -assume old_unit_star with no difference)&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;ifort -O0 -debug -static a.f90&lt;/PRE&gt;

&lt;P&gt;when run with&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;echo 1 | ./a.out&lt;/PRE&gt;

&lt;P&gt;produces segfault&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;*** buffer overflow detected ***: ./a.out terminated
======= Backtrace: =========
[0x4a368b]
[0x4d7552]
[0x4d74ee]
[0x4d6f09]
[0x4a958c]
[0x4e6628]
[0x4d6f8c]
[0x4d6eed]
[0x44dbdf]
[0x44daac]
[0x44ec19]
[0x43b8bd]
[0x4059ea]
[0x401128]
[0x4010ae]
[0x49844c]
[0x400f97]
======= Memory map: ========
00400000-0057e000 r-xp 00000000 00:2d 110493698                          /m/work/kgore4/a.a/a.out
0077d000-00783000 rw-p 0017d000 00:2d 110493698                          /m/work/kgore4/a.a/a.out
00783000-007a7000 rw-p 00000000 00:00 0
021ec000-0220f000 rw-p 00000000 00:00 0                                  [heap]
7f28195fe000-7f28195ff000 rw-p 00000000 00:00 0
7ffe6e79d000-7ffe6e7be000 rw-p 00000000 00:00 0                          [stack]
7ffe6e7d1000-7ffe6e7d3000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source
a.out              000000000047CE95  Unknown               Unknown  Unknown
a.out              000000000047AAB7  Unknown               Unknown  Unknown
a.out              000000000044C2F4  Unknown               Unknown  Unknown
a.out              000000000044C106  Unknown               Unknown  Unknown
a.out              000000000042AD76  Unknown               Unknown  Unknown
a.out              00000000004012F0  Unknown               Unknown  Unknown
a.out              0000000000497DA0  Unknown               Unknown  Unknown
a.out              000000000049EE77  Unknown               Unknown  Unknown
a.out              00000000004A3690  Unknown               Unknown  Unknown
a.out              00000000004D7552  Unknown               Unknown  Unknown
a.out              00000000004D74EE  Unknown               Unknown  Unknown
a.out              00000000004D6F09  Unknown               Unknown  Unknown
a.out              00000000004A958C  Unknown               Unknown  Unknown
a.out              00000000004E6628  Unknown               Unknown  Unknown
a.out              00000000004D6F8C  Unknown               Unknown  Unknown
a.out              00000000004D6EED  Unknown               Unknown  Unknown
a.out              000000000044DBDF  Unknown               Unknown  Unknown
a.out              000000000044DAAC  Unknown               Unknown  Unknown
a.out              000000000044EC19  Unknown               Unknown  Unknown
a.out              000000000043B8BD  Unknown               Unknown  Unknown
a.out              00000000004059EA  Unknown               Unknown  Unknown
a.out              0000000000401128  Unknown               Unknown  Unknown
a.out              00000000004010AE  Unknown               Unknown  Unknown
a.out              000000000049844C  Unknown               Unknown  Unknown
a.out              0000000000400F97  Unknown               Unknown  Unknown
&lt;/PRE&gt;

&lt;P&gt;strace seems to be the same until getpid is called where ubuntu returned 8283 and went on to read the 1 and \n.&amp;nbsp; centos returned 1997017 and went straight into the error above.&amp;nbsp; I wonder if that pid tried to go into a 16bit int?&amp;nbsp; /proc/sys/kernel/pid_max is 4194303 on centos7 and 32768 on ubuntu.&lt;/P&gt;

&lt;P&gt;EDIT: On further testing, it may not the pid.&amp;nbsp; Adding an explicit call to getpid() and a print above the read lets it get past the getpid.&lt;/P&gt;

&lt;P&gt;The difference in strace between running it with the pipe and without is&lt;/P&gt;

&lt;P&gt;ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7ffc321491e0) = -1 ENOTTY (Inappropriate ioctl for device)&lt;/P&gt;

&lt;P&gt;If I put the 1 into a real file and do "cat testinput | ./a.out" it still crashes.&amp;nbsp; also with "./a.out &amp;lt;testinput".&lt;/P&gt;

&lt;P&gt;EDIT2: add gdb backtrace after the segfault&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;(gdb) bt
#0  0x000000000049ee77 in abort ()
#1  0x00000000004a3690 in __libc_message ()
#2  0x00000000004d7552 in __fortify_fail ()
#3  0x00000000004d74ee in __chk_fail ()
#4  0x00000000004d6f09 in _IO_str_chk_overflow ()
#5  0x00000000004a958c in _IO_default_xsputn ()
#6  0x00000000004e6628 in vfprintf ()
#7  0x00000000004d6f8c in __vsprintf_chk ()
#8  0x00000000004d6eed in __sprintf_chk ()
#9  0x000000000044d089 in for__compute_filename ()
#10 0x000000000044ec19 in for__open_proc ()
#11 0x000000000043b8bd in for__open_default ()
#12 0x00000000004059ea in for_read_seq_lis ()
#13 0x0000000000401128 in a () at a.f90:5
#14 0x00000000004010ae in main ()
#15 0x000000000049844c in __libc_start_main ()
#16 0x0000000000400f97 in _start ()
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 04:44:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065762#M118416</guid>
      <dc:creator>kgore4</dc:creator>
      <dc:date>2016-03-30T04:44:48Z</dc:date>
    </item>
    <item>
      <title>If I do "echo 32768 &gt;/proc</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065763#M118417</link>
      <description>&lt;P&gt;If I do "echo 32768 &amp;gt;/proc/sys/kernel/pid_max", it runs.&lt;/P&gt;

&lt;P&gt;Here's where it gets weird.&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;cat /proc/sys/kernel/pid_max
4194303  # fails

echo 32768 &amp;gt;/proc/sys/kernel/pid_max    # works
echo 32769 &amp;gt;/proc/sys/kernel/pid_max    # works
echo 4194303 &amp;gt;/proc/sys/kernel/pid_max  # fails
echo 65536 &amp;gt;/proc/sys/kernel/pid_max    # works
echo 65537 &amp;gt;/proc/sys/kernel/pid_max    # works
echo 65538 &amp;gt;/proc/sys/kernel/pid_max    # works
echo 165538 &amp;gt;/proc/sys/kernel/pid_max   # works
echo 1655380 &amp;gt;/proc/sys/kernel/pid_max  # works
echo 2655380 &amp;gt;/proc/sys/kernel/pid_max  # works
echo 4194303 &amp;gt;/proc/sys/kernel/pid_max  # works!  ??HUH??
&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2016 03:35:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065763#M118417</guid>
      <dc:creator>kgore4</dc:creator>
      <dc:date>2016-04-01T03:35:35Z</dc:date>
    </item>
    <item>
      <title>Hi, </title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065764#M118418</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thank you for reporting the issue and providing the investigation results.&lt;/P&gt;

&lt;P&gt;This is indeed related to a high PID which is over 7 digits long, eg. &lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;1387017.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color: rgb(0, 0, 0); font-family: verdana, arial, helvetica, sans-serif; font-size: 10.6667px; line-height: normal;"&gt;We have reproduced your issue and entered it in our problem tracking system. We will try to resolve this issue as soon as we can. However, please be advised that this issue may have to be targeted to for the next major release. I will let you know when I have an update on this issue.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 10:18:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065764#M118418</guid>
      <dc:creator>Yuan_C_Intel</dc:creator>
      <dc:date>2016-07-07T10:18:13Z</dc:date>
    </item>
    <item>
      <title>Related issue: https:/</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065765#M118419</link>
      <description>&lt;P&gt;Related issue: &lt;A href="https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/607517"&gt;https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/607517&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 14:15:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065765#M118419</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2016-07-12T14:15:03Z</dc:date>
    </item>
    <item>
      <title>I am getting this exact</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065766#M118420</link>
      <description>&lt;P&gt;I am getting this exact problem using&amp;nbsp;ifort (IFORT) 17.0.0 20160721&lt;/P&gt;

&lt;P&gt;setting sysctl -w kernel.max_fid=&lt;SPAN style="font-size: 12px;"&gt;32768 seems to fix the problem..&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;however, &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px;"&gt;following instructions for installation a program (ceph file system) recommends using a value of kernel.max_fid=4194303&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2017 10:15:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065766#M118420</guid>
      <dc:creator>Simon_C_</dc:creator>
      <dc:date>2017-02-20T10:15:02Z</dc:date>
    </item>
    <item>
      <title>Yes, the fix isn't in 17.0.0.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065767#M118421</link>
      <description>&lt;P&gt;Yes, the fix isn't in 17.0.0.&amp;nbsp; It should be in 17.0.1 (according to the related issue link in Kevin's post) which has been out for a little while.&amp;nbsp; I haven't had time to test it though.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 02:59:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065767#M118421</guid>
      <dc:creator>kgore4</dc:creator>
      <dc:date>2017-02-21T02:59:15Z</dc:date>
    </item>
    <item>
      <title>Hi, all</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065768#M118422</link>
      <description>&lt;P&gt;Hi, all&lt;/P&gt;

&lt;P&gt;Yes, this has been fixed in Intel® Fortran Linux*&amp;nbsp;2017 Update 1&amp;nbsp;or&amp;nbsp;2016 Update 4.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 03:30:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/segfault-reading-from-piped-stdin-on-centos7-2/m-p/1065768#M118422</guid>
      <dc:creator>Yuan_C_Intel</dc:creator>
      <dc:date>2017-02-21T03:30:11Z</dc:date>
    </item>
  </channel>
</rss>

