public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/14129] New: gcc/f/lex.c buffer size limitation.
@ 2004-02-12 15:00 vk at mail dot lepp dot cornell dot edu
  2004-02-12 16:39 ` [Bug fortran/14129] [g77] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vk at mail dot lepp dot cornell dot edu @ 2004-02-12 15:00 UTC (permalink / raw)
  To: gcc-bugs

Hi,
fortran code crashed in preprocessor due to string hardcoded limit in gcc/f/lex.c.
When compiled in long path (more then 128 character long) compiler crashed. Here
example:

/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/tradcpp0 -lang-fortran -v
-I/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/ZebraCommonsModule
-I/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/include
-I/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/.
-I/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/include/.
-I/nfs/cleo3/cleo3_install/cleo3/Offline/rel/Jan13_04_P2/include
-I/nfs/cleo3/cleo3_install/cleo3/Offline/rel/Jan13_04_P2/include/.
-I/nfs/cleo3/cleo3_install/cleo3/Common/rel/Jan13_04_P2/include
-I/nfs/cleo3/cleo3_install/cleo3/Common/rel/Jan13_04_P2/include/i686-pc-linux-gnu
-I/nfs/cleo3/cleo3_install/cleo3/Offline/rel/Jan13_04_P2/other_sources
-D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=2 -D__GXX_ABI_VERSION=102
-D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__
-D__linux__ -D__unix -D__linux -Asystem=posix -D__OPTIMIZE__ -D__STDC_HOSTED__=1
-Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ -D__PIC__
-D__pic__ -DLinux -DCLEO_Linux -DDBCORBA -DMICOORB=2 -DMICOORB_MINOR=3
-DMICOORB_VERSION=7 -DHAVE_CONFIG_H
/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/ZebraCommonsModule/Fortran/forceCommonsLoad.F
> 1.tmp

This produce code 1.tmp which has:

# 1 "/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/ZebraCom
monsModule/Fortran/forceCommonsLoad.F"
      Subroutine forceCommonsLoad

# 1 "/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/ZebraCom
monsModule/ZebraCommonsModule/ZebraCommonsDeclarations.h" 1
C...Zebra memory allocation variables
C NWORD_GEANT - Number of words for Geant (separate Zebra bank ?)

Well preprocessor string exceed 128 characters, which are defined in
gcc/f/lex.c, see line 721

Then next step obviously crashed

/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/f771 -quiet -dumpbase
forceCommonsLoad.F -O -version -fno-second-underscore -finit-local-zero
-fno-automatic -fPIC
-I/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/ZebraCommonsModule
-I/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/include
-I/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/.
-I/nfs/cleo3/cleo3_rpm/development_20040204/rpms/test/stand-alone/src/include/.
-I/nfs/cleo3/cleo3_install/cleo3/Offline/rel/Jan13_04_P2/include
-I/nfs/cleo3/cleo3_install/cleo3/Offline/rel/Jan13_04_P2/include/.
-I/nfs/cleo3/cleo3_install/cleo3/Common/rel/Jan13_04_P2/include
-I/nfs/cleo3/cleo3_install/cleo3/Common/rel/Jan13_04_P2/include/i686-pc-linux-gnu
-I/nfs/cleo3/cleo3_install/cleo3/Offline/rel/Jan13_04_P2/other_sources -o - <
1.tmp > 2.tmp

I think you need to follow POSIX rule and use PATH_MAX instead of hardcoded
(small) 128. On Linux PATH_MAX is quite big 4K, so if you don't follow POSIX
just increase buffer size to large value and if you hardcoded give people
compiler option to override it.

Here the patch:
vk@vklaptop(09:50:12)> diff gcc-3.2.2-20030225/gcc/f/lex.c
gcc-3.2.2-20030225/gcc/f/lex.c~
721,722c721
<   /*char buff[129];*/
<   char buff[PATH_MAX+1];
---
>   char buff[129];
976d974
<           /*
979,981d976
<       */
<       directive_buffer = (char *)xmalloc (PATH_MAX+1);
<       buffer_length = PATH_MAX+1;

which fix the problem.
Valentine.

-- 
           Summary: gcc/f/lex.c buffer size limitation.
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vk at mail dot lepp dot cornell dot edu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14129


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-02-15 17:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-12 15:00 [Bug fortran/14129] New: gcc/f/lex.c buffer size limitation vk at mail dot lepp dot cornell dot edu
2004-02-12 16:39 ` [Bug fortran/14129] [g77] " pinskia at gcc dot gnu dot org
2004-02-15 14:27 ` cvs-commit at gcc dot gnu dot org
2004-02-15 17:16 ` cvs-commit at gcc dot gnu dot org
2004-02-15 17:43 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).