Author: dcoakley Date: 2011-06-29 16:37:57 -0400 (Wed, 29 Jun 2011) New Revision: 3665
Modified: trunk/osprey/crayf90/sgi/cwh_stmt.cxx Log: Fix bug 584: overallocation of temp space (Fortran). Consider the following test case: 1 program test 2 character (len=3233) :: lin 3 character (len=1024) :: path, nam 4 integer :: pos 5 pos=3 6 nam=path(1:(pos-1)) // lin 7 end program In order to store the result of the concatenation expression on line 7, the Fortran front-end generates code to allocate a temporary buffer on the stack. In this case the size of the buffer should be calculated as an addition of the two buffer sizes. The bug was that instead of allocating N bytes, N * N bytes were reserved. This error would either be undetected, if there was sufficent stack space, or fatal. The test case shows an example that exceeds the 8192 kbytes user stack limit common on modern Linux systems. The fix is to pass the size of the element as the second parameter to cwh_expr_temp in the Fortran front end, as documented in the function definition. We know it is the constant 1 because we have just created a character array type. Approved by: Michael Lai Modified: trunk/osprey/crayf90/sgi/cwh_stmt.cxx =================================================================== --- trunk/osprey/crayf90/sgi/cwh_stmt.cxx 2011-06-28 14:09:38 UTC (rev 3664) +++ trunk/osprey/crayf90/sgi/cwh_stmt.cxx 2011-06-29 20:37:57 UTC (rev 3665) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Advanced Micro Devices, Inc. All Rights Reserved. + * Copyright (C) 2009, 2011 Advanced Micro Devices, Inc. All Rights Reserved. */ /* @@ -3046,7 +3046,9 @@ wr = WN_COPY_Tree(wt); wt = F90_Wrap_ARREXP(wt); } else { - wt = cwh_expr_temp(ty,WN_COPY_Tree(rsz),f_T_PASSED); + /* character array case */ + WN *e_sz = WN_Intconst(MTYPE_I4,1); + wt = cwh_expr_temp(ty,WN_COPY_Tree(e_sz),f_T_PASSED); wr = WN_COPY_Tree(wt) ; } ------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 _______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel