This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix declaration of the Mem common

This fixes again a problem that with optimization, if an array of
length 1 (or 2) is repeatedly accessed, some of the accesses may be
removed.

Generally, this is translated into C code (by f2c), and in C an access
outside of the declared array bounds leads to undefined behaviour.

I still think that this patch is buggy since it does not address the
main problem of the Mem common: This common is a fake; it is defined
at address NULL (in zvsjmp.s). Instead, it addresses __real__
pointers, which were just "translated" to (fake)
indices. F.e. accessing memd[0] will create a segfault.

Instead, this common block should be transformed into normal pointer
arithmetics. This should not be a problem, since it is translated to C
via f2c anyway... and newer Fortran version have pointer arithmetic on
board.

But as a first step, we create the arrays in the same size as the memc
common block (60,000 entries).
  • Loading branch information...
olebole committed May 22, 2017
1 parent 8a82134 commit e5f8b2cfe5d875d4eaea07de807b40c0bbdb6795
Showing with 63 additions and 84 deletions.
  1. +55 −76 unix/boot/spp/rpp/rppfor/poicod.f
  2. +8 −8 unix/boot/spp/rpp/rpprat/poicod.r
@@ -62,87 +62,66 @@ subroutine poicod (decla0)
integer mem( 60000)
common/cdsmem/mem
integer spoin0(9)
integer p1(16)
integer p2(18)
integer p3(18)
C integer p4(18)
C integer p5(18)
C integer p6(25)
integer p4(16)
integer p5(16)
integer p6(13)
integer p7(25)
integer p8(16)
integer p1(20)
integer p2(22)
integer p3(22)
integer p4(20)
integer p5(20)
integer p6(17)
integer p7(29)
integer p8(20)
integer p9(61)
integer pa(18)
C data spoin0(1)/105/,spoin0(2)/110/,spoin0(3)/116/,spoin0(4)/101/,s
C *poin0(5)/103/,spoin0(6)/101/,spoin0(7)/114/,spoin0(8)/42/,spoin0(9
C *)/56/,spoin0(10)/32/,spoin0(11)/-2/
data spoin0(1)/105/,spoin0(2)/110/,spoin0(3)/116/,spoin0(4)/101/,s
*poin0(5)/103/,spoin0(6)/101/,spoin0(7)/114/,spoin0(8)/32/,spoin0(9
*)/-2/
data spoin0(1),spoin0(2),spoin0(3),spoin0(4),spoin0(5),spoin0(6),s
*poin0(7),spoin0(8),spoin0(9)/105,110,116,101,103,101,114,32,-2/
data p1(1)/108/,p1(2)/111/,p1(3)/103/,p1(4)/105/,p1(5)/99/,p1(6)/9
*7/,p1(7)/108/,p1(8)/32/,p1(9)/77/,p1(10)/101/,p1(11)/109/,p1(12)/9
*8/,p1(13)/40/,p1(14)/49/,p1(15)/41/,p1(16)/-2/
data p2(1)/105/,p2(2)/110/,p2(3)/116/,p2(4)/101/,p2(5)/103/,p2(6)/
*101/,p2(7)/114/,p2(8)/42/,p2(9)/50/,p2(10)/32/,p2(11)/77/,p2(12)/1
*01/,p2(13)/109/,p2(14)/99/,p2(15)/40/,p2(16)/49/,p2(17)/41/,p2(18)
*/-2/
data p3(1)/105/,p3(2)/110/,p3(3)/116/,p3(4)/101/,p3(5)/103/,p3(6)/
*101/,p3(7)/114/,p3(8)/42/,p3(9)/50/,p3(10)/32/,p3(11)/77/,p3(12)/1
*01/,p3(13)/109/,p3(14)/115/,p3(15)/40/,p3(16)/49/,p3(17)/41/,p3(18
*)/-2/
data p1(1),p1(2),p1(3),p1(4),p1(5),p1(6),p1(7),p1(8),p1(9),p1(10),
*p1(11),p1(12),p1(13),p1(14),p1(15),p1(16),p1(17),p1(18),p1(19),p1(
*20)/108,111,103,105,99,97,108,32,77,101,109,98,40,54,48,48,48,48,4
*1,-2/
data p2(1),p2(2),p2(3),p2(4),p2(5),p2(6),p2(7),p2(8),p2(9),p2(10),
*p2(11),p2(12),p2(13),p2(14),p2(15),p2(16),p2(17),p2(18),p2(19),p2(
*20),p2(21),p2(22)/105,110,116,101,103,101,114,42,50,32,77,101,109,
*99,40,54,48,48,48,48,41,-2/
data p3(1),p3(2),p3(3),p3(4),p3(5),p3(6),p3(7),p3(8),p3(9),p3(10),
*p3(11),p3(12),p3(13),p3(14),p3(15),p3(16),p3(17),p3(18),p3(19),p3(
*20),p3(21),p3(22)/105,110,116,101,103,101,114,42,50,32,77,101,109,
*115,40,54,48,48,48,48,41,-2/
data p4(1),p4(2),p4(3),p4(4),p4(5),p4(6),p4(7),p4(8),p4(9),p4(10),
*p4(11),p4(12),p4(13),p4(14),p4(15),p4(16),p4(17),p4(18),p4(19),p4(
*20)/105,110,116,101,103,101,114,32,77,101,109,105,40,54,48,48,48,4
*8,41,-2/
data p5(1),p5(2),p5(3),p5(4),p5(5),p5(6),p5(7),p5(8),p5(9),p5(10),
*p5(11),p5(12),p5(13),p5(14),p5(15),p5(16),p5(17),p5(18),p5(19),p5(
*20)/105,110,116,101,103,101,114,32,77,101,109,108,40,54,48,48,48,4
*8,41,-2/
data p6(1),p6(2),p6(3),p6(4),p6(5),p6(6),p6(7),p6(8),p6(9),p6(10),
*p6(11),p6(12),p6(13),p6(14),p6(15),p6(16),p6(17)/114,101,97,108,32
*,77,101,109,114,40,54,48,48,48,48,41,-2/
data p7(1),p7(2),p7(3),p7(4),p7(5),p7(6),p7(7),p7(8),p7(9),p7(10),
*p7(11),p7(12),p7(13),p7(14),p7(15),p7(16),p7(17),p7(18),p7(19),p7(
*20),p7(21),p7(22),p7(23),p7(24),p7(25),p7(26),p7(27),p7(28),p7(29)
*/100,111,117,98,108,101,32,112,114,101,99,105,115,105,111,110,32,7
*7,101,109,100,40,54,48,48,48,48,41,-2/
data p8(1),p8(2),p8(3),p8(4),p8(5),p8(6),p8(7),p8(8),p8(9),p8(10),
*p8(11),p8(12),p8(13),p8(14),p8(15),p8(16),p8(17),p8(18),p8(19),p8(
*20)/99,111,109,112,108,101,120,32,77,101,109,120,40,54,48,48,48,48
*,41,-2/
data p9(1),p9(2),p9(3),p9(4),p9(5),p9(6),p9(7),p9(8),p9(9),p9(10),
*p9(11),p9(12),p9(13),p9(14),p9(15),p9(16),p9(17),p9(18),p9(19),p9(
*20),p9(21),p9(22),p9(23),p9(24),p9(25),p9(26),p9(27),p9(28),p9(29)
*,p9(30),p9(31),p9(32),p9(33),p9(34),p9(35),p9(36),p9(37),p9(38),p9
*(39),p9(40),p9(41),p9(42),p9(43),p9(44),p9(45),p9(46),p9(47),p9(48
*),p9(49),p9(50),p9(51),p9(52),p9(53),p9(54),p9(55),p9(56),p9(57),p
*9(58),p9(59),p9(60),p9(61)/101,113,117,105,118,97,108,101,110,99,1
*01,32,40,77,101,109,98,44,32,77,101,109,99,44,32,77,101,109,115,44
*,32,77,101,109,105,44,32,77,101,109,108,44,32,77,101,109,114,44,32
*,77,101,109,100,44,32,77,101,109,120,41,-2/
data pa(1),pa(2),pa(3),pa(4),pa(5),pa(6),pa(7),pa(8),pa(9),pa(10),
*pa(11),pa(12),pa(13),pa(14),pa(15),pa(16),pa(17),pa(18)/99,111,109
*,109,111,110,32,47,77,101,109,47,32,77,101,109,100,-2/
data p4(1)/105/,p4(2)/110/,p4(3)/116/,p4(4)/101/,p4(5)/103/,p4(6)/
*101/,p4(7)/114/,p4(8)/32/,p4(9)/77/,p4(10)/101/,p4(11)/109/,p4(12)
*/105/,p4(13)/40/,p4(14)/49/,p4(15)/41/,p4(16)/-2/
data p5(1)/105/,p5(2)/110/,p5(3)/116/,p5(4)/101/,p5(5)/103/,p5(6)/
*101/,p5(7)/114/,p5(8)/32/,p5(9)/77/,p5(10)/101/,p5(11)/109/,p5(12)
*/108/,p5(13)/40/,p5(14)/49/,p5(15)/41/,p5(16)/-2/
C data p4(1)/105/,p4(2)/110/,p4(3)/116/,p4(4)/101/,p4(5)/103/,p4(6)/
C *101/,p4(7)/114/,p4(8)/42/,p4(9)/56/,p4(10)/32/,p4(11)/77/,p4(12)/1
C *01/,p4(13)/109/,p4(14)/105/,p4(15)/40/,p4(16)/49/,p4(17)/41/,p4(18
C *)/-2/
C data p5(1)/105/,p5(2)/110/,p5(3)/116/,p5(4)/101/,p5(5)/103/,p5(6)/
C *101/,p5(7)/114/,p5(8)/42/,p5(9)/56/,p5(10)/32/,p5(11)/77/,p5(12)/1
C *01/,p5(13)/109/,p5(14)/108/,p5(15)/40/,p5(16)/49/,p5(17)/41/,p5(18
C *)/-2/
C data p6(1)/100/,p6(2)/111/,p6(3)/117/,p6(4)/98/,p6(5)/108/,p6(6)/1
C *01/,p6(7)/32/,p6(8)/112/,p6(9)/114/,p6(10)/101/,p6(11)/99/,p6(12)/
C *105/,p6(13)/115/,p6(14)/105/,p6(15)/111/,p6(16)/110/,p6(17)/32/,p6
C *(18)/77/,p6(19)/101/,p6(20)/109/,p6(21)/114/,p6(22)/40/,p6(23)/49/
C *,p6(24)/41/,p6(25)/-2/
data p6(1)/114/,p6(2)/101/,p6(3)/97/,p6(4)/108/,p6(5)/32/,p6(6)/77
*/,p6(7)/101/,p6(8)/109/,p6(9)/114/,p6(10)/40/,p6(11)/49/,p6(12)/41
*/,p6(13)/-2/
data p7(1)/100/,p7(2)/111/,p7(3)/117/,p7(4)/98/,p7(5)/108/,p7(6)/1
*01/,p7(7)/32/,p7(8)/112/,p7(9)/114/,p7(10)/101/,p7(11)/99/,p7(12)/
*105/,p7(13)/115/,p7(14)/105/,p7(15)/111/,p7(16)/110/,p7(17)/32/,p7
*(18)/77/,p7(19)/101/,p7(20)/109/,p7(21)/100/,p7(22)/40/,p7(23)/49/
*,p7(24)/41/,p7(25)/-2/
data p8(1)/99/,p8(2)/111/,p8(3)/109/,p8(4)/112/,p8(5)/108/,p8(6)/1
*01/,p8(7)/120/,p8(8)/32/,p8(9)/77/,p8(10)/101/,p8(11)/109/,p8(12)/
*120/,p8(13)/40/,p8(14)/49/,p8(15)/41/,p8(16)/-2/
data p9(1)/101/,p9(2)/113/,p9(3)/117/,p9(4)/105/,p9(5)/118/,p9(6)/
*97/,p9(7)/108/,p9(8)/101/,p9(9)/110/,p9(10)/99/,p9(11)/101/,p9(12)
*/32/,p9(13)/40/,p9(14)/77/,p9(15)/101/,p9(16)/109/,p9(17)/98/,p9(1
*8)/44/,p9(19)/32/,p9(20)/77/,p9(21)/101/,p9(22)/109/,p9(23)/99/,p9
*(24)/44/,p9(25)/32/,p9(26)/77/,p9(27)/101/,p9(28)/109/,p9(29)/115/
*,p9(30)/44/,p9(31)/32/,p9(32)/77/,p9(33)/101/,p9(34)/109/,p9(35)/1
*05/,p9(36)/44/,p9(37)/32/,p9(38)/77/,p9(39)/101/,p9(40)/109/,p9(41
*)/108/,p9(42)/44/,p9(43)/32/,p9(44)/77/,p9(45)/101/,p9(46)/109/,p9
*(47)/114/,p9(48)/44/,p9(49)/32/,p9(50)/77/,p9(51)/101/,p9(52)/109/
*,p9(53)/100/,p9(54)/44/,p9(55)/32/,p9(56)/77/,p9(57)/101/,p9(58)/1
*09/,p9(59)/120/,p9(60)/41/,p9(61)/-2/
data pa(1)/99/,pa(2)/111/,pa(3)/109/,pa(4)/109/,pa(5)/111/,pa(6)/1
*10/,pa(7)/32/,pa(8)/47/,pa(9)/77/,pa(10)/101/,pa(11)/109/,pa(12)/4
*7/,pa(13)/32/,pa(14)/77/,pa(15)/101/,pa(16)/109/,pa(17)/100/,pa(18
*)/-2/
if (.not.(memflg .eq. 0))goto 23000
call poidec (p1)
call poidec (p2)
@@ -9,14 +9,14 @@ include COMMON_BLOCKS
string spointer XPOINTER
# Fortran declarations for the MEM common.
string p1 "logical Memb(1)"
string p2 "integer*2 Memc(1)"
string p3 "integer*2 Mems(1)"
string p4 "integer Memi(1)"
string p5 "integer Meml(1)"
string p6 "real Memr(1)"
string p7 "double precision Memd(1)"
string p8 "complex Memx(1)"
string p1 "logical Memb(60000)"
string p2 "integer*2 Memc(60000)"
string p3 "integer*2 Mems(60000)"
string p4 "integer Memi(60000)"
string p5 "integer Meml(60000)"
string p6 "real Memr(60000)"
string p7 "double precision Memd(60000)"
string p8 "complex Memx(60000)"
string p9 "equivalence (Memb, Memc, Mems, Memi, Meml, Memr, Memd, Memx)"
string pa "common /Mem/ Memd"

0 comments on commit e5f8b2c

Please sign in to comment.