coinor-osi fails to build from source on arm64 (but did succeed before)

Bug #1263576 reported by Matthias Klose
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GCC
Fix Released
Medium
Kugan Vivekanandarajah
gcc
Fix Released
Medium
clp (Ubuntu)
Fix Released
High
Unassigned
Trusty
Fix Released
High
Unassigned
coinor-osi (Ubuntu)
Fix Released
High
Unassigned
Trusty
Fix Released
High
Unassigned
gcc-4.7 (Ubuntu)
Fix Released
Undecided
Unassigned
Trusty
Fix Released
Undecided
Unassigned
gcc-4.8 (Ubuntu)
Fix Released
Undecided
Unassigned
Trusty
Fix Released
Undecided
Unassigned

Bug Description

coinor-osi fails to build from source on arm64 (but did fail before), running the test just segfaults. lowering the compiler options to -O0 shows the same behavior.

cd test; make test
make[2]: Entering directory `/build/buildd/coinor-osi-0.106.4/test'
g++ -DHAVE_CONFIG_H -I. -I`echo .` -I../src/Osi -I`echo ./../src/Osi` -I`echo ./../src/OsiCommonTest` -I/usr/include/coin -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Werror=format-security -DOSI_BUILD -c -o unitTest.o unitTest.cpp
g++ -DHAVE_CONFIG_H -I. -I`echo .` -I../src/Osi -I`echo ./../src/Osi` -I`echo ./../src/OsiCommonTest` -I/usr/include/coin -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Werror=format-security -DOSI_BUILD -c -o OsiTestSolver.o OsiTestSolver.cpp
g++ -DHAVE_CONFIG_H -I. -I`echo .` -I../src/Osi -I`echo ./../src/Osi` -I`echo ./../src/OsiCommonTest` -I/usr/include/coin -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Werror=format-security -DOSI_BUILD -c -o OsiTestSolverInterface.o OsiTestSolverInterface.cpp
g++ -DHAVE_CONFIG_H -I. -I`echo .` -I../src/Osi -I`echo ./../src/Osi` -I`echo ./../src/OsiCommonTest` -I/usr/include/coin -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Werror=format-security -DOSI_BUILD -c -o OsiTestSolverInterfaceIO.o OsiTestSolverInterfaceIO.cpp
g++ -DHAVE_CONFIG_H -I. -I`echo .` -I../src/Osi -I`echo ./../src/Osi` -I`echo ./../src/OsiCommonTest` -I/usr/include/coin -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Werror=format-security -DOSI_BUILD -c -o OsiTestSolverInterfaceTest.o OsiTestSolverInterfaceTest.cpp
/bin/bash ../libtool --tag=CXX --mode=link g++ -g -O2 -Wformat -Werror=format-security -DOSI_BUILD -Wl,-Bsymbolic-functions -Wl,-z,relro -o unitTest unitTest.o OsiTestSolver.o OsiTestSolverInterface.o OsiTestSolverInterfaceIO.o OsiTestSolverInterfaceTest.o ../src/OsiCommonTest/libOsiCommonTests.la ../src/Osi/libOsi.la -lCoinUtils -lbz2 -lz -lm
mkdir .libs
g++ -g -O2 -Wformat -Werror=format-security -DOSI_BUILD -Wl,-Bsymbolic-functions -Wl,-z -Wl,relro -o .libs/unitTest unitTest.o OsiTestSolver.o OsiTestSolverInterface.o OsiTestSolverInterfaceIO.o OsiTestSolverInterfaceTest.o ../src/OsiCommonTest/.libs/libOsiCommonTests.so ../src/Osi/.libs/libOsi.so -lCoinUtils -lbz2 -lz -lm
creating unitTest
./unitTest -mpsDir=`echo /usr/share/coin/Data/Sample`
Testing OsiRowCut with OsiTestSolverInterface
make[2]: *** [test] Segmentation fault
make[2]: Leaving directory `/build/buildd/coinor-osi-0.106.4/test'
make[1]: *** [test] Error 2

Tags: patch arm64
Matthias Klose (doko)
Changed in coinor-osi (Ubuntu Trusty):
importance: Undecided → High
milestone: none → ubuntu-14.04-beta-1
status: New → Confirmed
Matthias Klose (doko)
tags: added: arm64
Revision history for this message
Matthias Klose (doko) wrote :

clp fails the same way:

cd test; make test
make[2]: Entering directory `/build/buildd/clp-1.15.5/test'
g++ -DHAVE_CONFIG_H -I. -I. -I../src -I../src -I`echo ./../src` -I`echo ./../src/OsiClp` -I/usr/include/coin -I/usr/include/coin -I/usr/include/coin -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Werror=format-security -DCLP_BUILD -c -o osiUnitTest.o osiUnitTest.cpp
g++ -DHAVE_CONFIG_H -I. -I. -I../src -I../src -I`echo ./../src` -I`echo ./../src/OsiClp` -I/usr/include/coin -I/usr/include/coin -I/usr/include/coin -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Werror=format-security -DCLP_BUILD -c -o OsiClpSolverInterfaceTest.o OsiClpSolverInterfaceTest.cpp
/bin/bash ../libtool --tag=CXX --mode=link g++ -g -O2 -Wformat -Werror=format-security -DCLP_BUILD -Wl,-Bsymbolic-functions -Wl,-z,relro -o osiUnitTest osiUnitTest.o OsiClpSolverInterfaceTest.o ../src/libClp.la ../src/OsiClp/libOsiClp.la -lCoinUtils -lbz2 -lz -lm -lOsiCommonTests -lOsi -lCoinUtils -lbz2 -lz -lm
mkdir .libs
g++ -g -O2 -Wformat -Werror=format-security -DCLP_BUILD -Wl,-Bsymbolic-functions -Wl,-z -Wl,relro -o .libs/osiUnitTest osiUnitTest.o OsiClpSolverInterfaceTest.o ../src/.libs/libClp.so ../src/OsiClp/.libs/libOsiClp.so -lOsiCommonTests -lOsi -lCoinUtils -lbz2 -lz -lm
creating osiUnitTest
../src/clp -dirSample `echo /usr/share/coin/Data/Sample` -unitTest || exit 1
Coin LP version 1.15.5, build Dec 23 2013
command line - /build/buildd/clp-1.15.5/src/.libs/lt-clp -dirSample /usr/share/coin/Data/Sample -unitTest
***Skipped Testing on netlib ***
***use -netlib to test class***
All tests completed successfully
if test -e osiUnitTest ; then \
   ./osiUnitTest -mpsDir=`echo /usr/share/coin/Data/Sample` || exit 1 ; \
 fi
Testing OsiRowCut with OsiClpSolverInterface
/bin/bash: line 2: 31828 Segmentation fault ./osiUnitTest -mpsDir=`echo /usr/share/coin/Data/Sample`
make[2]: *** [test] Error 1
make[2]: Leaving directory `/build/buildd/clp-1.15.5/test'
make[1]: *** [test] Error 2

Changed in clp (Ubuntu Trusty):
importance: Undecided → High
milestone: none → ubuntu-14.04-beta-1
status: New → Confirmed
Matthias Klose (doko)
summary: - coinor-osi fails to build from source on arm64 (but did fail before)
+ coinor-osi fails to build from source on arm64 (but did succeed before)
Revision history for this message
William Grant (wgrant) wrote :

This seems to be a gcc bug with very negative vcall_offsets in aarch64 multiple inheritance thunks. http://paste.ubuntu.com/6637563/ is an example of two consecutive thunks, with the second adding 263 instead of subtracting 264. aarch64_build_constant seems to not handle negative integers. I tried a quick gcc patch to avoid using aarch64_build_constant, and the coinor-osi tests succeed.

tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gcc-4.7 - 4.7.3-9ubuntu2

---------------
gcc-4.7 (4.7.3-9ubuntu2) trusty; urgency=medium

  * Apply proposed patch for LP: #1263576.
 -- Matthias Klose <email address hidden> Fri, 27 Dec 2013 17:15:24 +0100

Changed in gcc-4.7 (Ubuntu Trusty):
status: New → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package coinor-osi - 0.106.4-1ubuntu4

---------------
coinor-osi (0.106.4-1ubuntu4) trusty; urgency=medium

  * Build using GCC 4.7 on arm64.
 -- Matthias Klose <email address hidden> Fri, 27 Dec 2013 19:31:48 +0100

Changed in coinor-osi (Ubuntu Trusty):
status: Confirmed → Fix Released
Revision history for this message
In , Doko-v (doko-v) wrote :

seen in a segfault running the tests in the coinor-osi package,
https://launchpad.net/bugs/1263576, both in saucy and trusty, version 0.106.4
and 0.106.5. Version 0.103 doesn't show the issue.

both the 4.7 and 4.8 linaro branches show this behaviour, and trunk 20131121
(didn't build a newer one yet).

William Grant tracked that down to a bug with very negative vcall_offsets in
aarch64 multiple inheritance thunks. The example below has two consecutive
thunks, with the second adding 263 instead of subtracting 264.
aarch64_build_constant seems to not handle negative integers. He tried a quick
gcc patch to avoid using aarch64_build_constant, and the coinor-osi tests succeed.

0000000000401ca4 <_ZTv0_n256_N1C2adEv>:
  401ca4: f9400010 ldr x16, [x0]
  401ca8: f8500211 ldr x17, [x16,#-256]
  401cac: 8b110000 add x0, x0, x17
  401cb0: 17fffff9 b 401c94 <_ZN1C2adEv>

[...]

0000000000401cc4 <_ZTv0_n264_N1C2aeEv>:
  401cc4: f9400010 ldr x16, [x0]
  401cc8: d28020f1 mov x17, #0x107 // #263
  401ccc: f8716a11 ldr x17, [x16,x17]
  401cd0: 8b110000 add x0, x0, x17
  401cd4: 17fffff8 b 401cb4 <_ZN1C2aeEv>

Any chance for a quick 2013 review?

Thanks, Matthias

--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -2540,8 +2540,8 @@
    addr = plus_constant (Pmode, temp0, vcall_offset);
       else
  {
- aarch64_build_constant (IP1_REGNUM, vcall_offset);
- addr = gen_rtx_PLUS (Pmode, temp0, temp1);
+ aarch64_add_constant (IP0_REGNUM, IP1_REGNUM, vcall_offset);
+ addr = temp0;
  }

       aarch64_emit_move (temp1, gen_rtx_MEM (Pmode,addr));

Changed in gcc:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
In , Matthew Gretton-Dann (matthew-gretton-dann) wrote :

I think the actual issue is with the code in aarch64_build_constant:

      /* zcount contains the number of additional MOVK instructions
  required if the constant is built up with an initial MOVZ instruction,
  while ncount is the number of MOVK instructions required if starting
  with a MOVN instruction. Choose the sequence that yields the fewest
  number of instructions, preferring MOVZ instructions when they are both
  the same. */
      if (ncount < zcount)
 {
   emit_move_insn (gen_rtx_REG (Pmode, regnum),
     GEN_INT ((~val) & 0xffff));
   tval = 0xffff;
 }
      else
 {
   emit_move_insn (gen_rtx_REG (Pmode, regnum),
     GEN_INT (val & 0xffff));
   tval = 0;
 }

The GEN_INT in the first if branch is incorrect as it truncates the immediate at 16-bits, and so we will never generate the "MOVN" form. What it should be instead is: GEN_INT (~((~val) & 0xffff)) or equivalent.

Changed in gcc-linaro:
assignee: nobody → Kugan Vivekanandarajah (kugan-vivekanandarajah)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Kugan Vivekanandarajah (kugan-vivekanandarajah) wrote :

Reduced testcase to reproduce this.

Revision history for this message
Matthias Klose (doko) wrote :

coinor-osi and clp now built again with the fixed gcc-4.8 4.8.2-13ubuntu1

Changed in clp (Ubuntu Trusty):
status: Confirmed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gcc-4.8 - 4.8.2-13ubuntu1

---------------
gcc-4.8 (4.8.2-13ubuntu1) trusty; urgency=medium

  * Merge with Debian; remaining changes:
    - Build from the upstream source.

gcc-4.8 (4.8.2-13) unstable; urgency=medium

  * Update to SVN 20140112 (r206564) from the gcc-4_8-branch.
    - Fix miscompilation due to wrong RTL-optimization (see
      PR rtl-optimization/59137). Closes: #716635.

  [ Aurelien Jarno ]
  * Reenable the testsuite on mips.

  [ Matthias Klose ]
  * Add libgcc, libstdc++, libgfortran symbols files for ppc64el.
  * Update libitm symbols for non-default multilibs.
  * Add libgcc, libstdc++, libgfortran symbols files for arm64.
  * Fix PR target/59588 (AArch64), backport proposed patch. LP: #1263576.
  * Fix PR target/59744 (AArch64), taken from the trunk. LP: #1267761.
 -- Matthias Klose <email address hidden> Sun, 12 Jan 2014 14:16:19 +0100

Changed in gcc-4.8 (Ubuntu Trusty):
status: New → Fix Released
Revision history for this message
In , Clyon (clyon) wrote :

Author: clyon
Date: Wed Jan 15 10:27:55 2014
New Revision: 206628

URL: http://gcc.gnu.org/viewcvs?rev=206628&root=gcc&view=rev
Log:
2014-01-15 Matthew Gretton-Dann <email address hidden>
            Kugan Vivekanandarajah <email address hidden>

 gcc/
 PR target/59695
 * config/aarch64/aarch64.c (aarch64_build_constant): Fix incorrect
 truncation.

 gcc/testsuite/
 PR target/59695
 * g++.dg/pr59695.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/pr59695.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/aarch64/aarch64.c
    trunk/gcc/testsuite/ChangeLog

Revision history for this message
In , Clyon (clyon) wrote :

Author: clyon
Date: Fri Jan 17 11:05:04 2014
New Revision: 206703

URL: http://gcc.gnu.org/viewcvs?rev=206703&root=gcc&view=rev
Log:
2014-01-17 Kugan Vivekanandarajah <email address hidden>

 gcc/
 Backport from mainline
 2014-01-15 Matthew Gretton-Dann <email address hidden>
            Kugan Vivekanandarajah <email address hidden>

 PR target/59695
 * config/aarch64/aarch64.c (aarch64_build_constant): Fix incorrect
 truncation.

 gcc/testsuite/
 Backport from mainline
 2014-01-15 Matthew Gretton-Dann <email address hidden>
     Kugan Vivekanandarajah <email address hidden>

 PR target/59695
 * g++.dg/pr59695.C: New testcase.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/pr59695.C
      - copied unchanged from r206628, trunk/gcc/testsuite/g++.dg/pr59695.C
Modified:
    branches/gcc-4_8-branch/ (props changed)
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/config/aarch64/aarch64.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog

Propchange: branches/gcc-4_8-branch/
            ('svn:mergeinfo' modified)

Revision history for this message
In , Ramana-gcc (ramana-gcc) wrote :

Fixed now presumably.

Changed in gcc:
status: New → Fix Released
Changed in gcc-linaro:
status: Confirmed → Fix Committed
Changed in gcc-linaro:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.