Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#4369 cernlib2006-2006b-21

Added_to_Fink
closed-accepted
Remi Mommsen
None
5
2013-11-18
2013-11-16
Jack Howarth
No

The attached packaging for cernlib2006-2006b-21 properly fixes the failures with the fortified strcpy on 10.9 by replacing instances of the illegal…

strcpy(p, p+1)

with

memmove(p, p+1, strlen(p+1) + 1)

as recommended by Apple. The info file as adds…

perl -pi -e 's|CDebugFlags -O0|CDebugFlags -O3 -fno-aggressive-loop-optimizations|g' config/MacOSX.cf
perl -pi -e 's|OptimisedFortranFlags -O0|OptimisedFortranFlags -O3 -fno-aggressive-loop-optimizations|g' config/MacOSX.cf

to the PatchScript. The problem optimization is aggressive loop optimizations producing undefined behaviors. Unfortunately -Waggressive-loop-optimizations doesn't detect every instance of these problem loop optimizations which produce undefined behaviors yet so we can't just append -fno-aggressive-loop-optimizations to a subset of source files. Tested without regressions on 'fink -m' on 10.9.

Discussion

  • Jack Howarth
    Jack Howarth
    2013-11-16

    Info file for cernlib2006-2006b-21.

     
    Attachments
  • Jack Howarth
    Jack Howarth
    2013-11-16

    Compressed patch source file for cernlib2006-2006b-21

     
  • Jack Howarth
    Jack Howarth
    2013-11-16

    Diff to current info file…

    Index: cernlib2006.info

    RCS file: /cvsroot/fink/dists/10.7/stable/main/finkinfo/sci/cernlib2006.info,v
    retrieving revision 1.14
    diff -r1.14 cernlib2006.info
    4c4
    < Revision: 20


    Revision: 21
    25c25
    < Source2-MD5: f0395fa4d9ad2cfc4cdfc7a59e142953


    Source2-MD5: b528c1d9cd93b2d52f3c3c6dd191f5c3
    37a38,39
    perl -pi -e 's|CDebugFlags -O0|CDebugFlags -O3 -fno-aggressive-loop-optimizations|g' config/MacOSX.cf
    perl -pi -e 's|OptimisedFortranFlags -O0|OptimisedFortranFlags -O3 -fno-aggressive-loop-optimizations|g' config/MacOSX.cf
    54,58d55
    < if [[ $(sw_vers -productVersion | cut -d. -f1-2) > 10.8 ]]; then
    < # actual problem file is kuipcc.c and bug also manifests if kuipc is compiled with clang rather than gcc-4
    < # radr://15442262, "default -D_FORTIFY_SOURCE=2 on 10.9 breaks kuipc from cernlib2006 on 10.9"
    < perl -pi -e 's|CDEBUGFLAGS = -O0 |CDEBUGFLAGS = -O0 -D_FORTIFY_SOURCE=0 |g' %b/packlib/kuip/programs/kuipc/Makefile
    < fi

     
  • Jack Howarth
    Jack Howarth
    2013-11-16

    Changes to eliminate the illegal strcpy usages which were added to the previous source cernlib2006-2006b-20.patch file to create the new cernlib2006-2006b-21.patch file.

     
    Attachments
  • Jack Howarth
    Jack Howarth
    2013-11-16

    Remi will need to place this new patch file on his server for this update.

     
  • Remi Mommsen
    Remi Mommsen
    2013-11-18

    Hi Jack,

    thanks for following up on the strcpy issue. I committed a new revision 21 using your memmove patch. As I applied it to the original source, the patch file has now a different order than the one attached to this ticket.

    However, I refrained from changing the optimisation. The correctness of the result is more important than the speed. Anyway, cernlib is much faster nowadays than anyone dreamed of in the 1980's (:

    Remi

     
  • Remi Mommsen
    Remi Mommsen
    2013-11-18

    • status: open --> closed-accepted
    • Group: Undergoing_Validation --> Added_to_Fink
     
  • Jack Howarth
    Jack Howarth
    2013-11-18

    Remi,
    You might want to at least consider...

    perl -pi -e 's|CDebugFlags -O0|CDebugFlags -O2 -fno-aggressive-loop-optimizations|g' config/MacOSX.cf
    perl -pi -e 's|OptimisedFortranFlags -O0|OptimisedFortranFlags -O2 -fno-aggressive-loop-optimizations|g' config/MacOSX.cf

    You do realize that the flag combination that you are using, -O0 -ftree-vectorize -funroll-loops, is about as untested a combination of flags on FSF gcc as exists.

     
  • Jack Howarth
    Jack Howarth
    2013-11-18

    I would also note that the reason -O0 is being used here is that, prior to gcc 4.8, there was no way to easily turn off aggressive loop optimizations at the higher optimization levels. If you use perl edit of...

    perl -pi -e 's|OptimisedFortranFlags -O0|OptimisedFortranFlags -O2 -Waggressive-loop-optimizations|g' config/MacOSX.cf

    ...you will see a large number of fortran source files producing warnings of the effect...

    fmveri.F: In function 'fmveri':
    fmveri.F:664:0: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
    IF(IQ(LADDR+MUSWFA+I).EQ.0) GOTO 50
    ^
    fmveri.F:663:0: note: containing loop
    DO 50 I=0,9
    ^

    Unfortunately, FSF gcc isn't yet able to warn on every single instance of this so the blanket use of -fno-aggressive-loop-optimizations is required. Also, note that we aren't adding anything like -ffast-math at -O2 so there should be no rounding issues introduced.