[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2024-11-01 Thread Bug Watch Updater
Launchpad has imported 17 comments from the remote bug at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868.

If you reply to an imported comment from within Launchpad, your comment
will be sent to the remote bug automatically. Read more about
Launchpad's inter-bugtracker facilities at
https://help.launchpad.net/InterBugTracking.


On 2015-07-14T12:05:54+00:00 Doko-v wrote:

Created attachment 35975
preprocessed source

[forwarded from
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1473674]

seen in the apt package manager, when built with -O3. Works with -O2 or
-O3 -fno-inline-functions -finline-small-functions, on at least x86_64
and powerpc64le. The test CDROMTest.FindPackages from the apt testsuite
then fails.

built with g++ -c -g -O3 -fPIE -fstack-protector-strong -fPIC

upstream writes:

There is a Cdrom wrapper:
"""
class Cdrom : public pkgCdrom {
   public:
  bool FindPackages(std::string const &CD,
 std::vector &List,
 std::vector &SList,
 std::vector &SigList,
 std::vector &TransList,
 std::string &InfoDir) {
  std::string const startdir = SafeGetCWD();
  EXPECT_FALSE(startdir.empty());
  bool const result = pkgCdrom::FindPackages(CD, List, SList, SigList, 
TransList, InfoDir, NULL, 0);
...
}
"""

and a unittest that calls it:
"""
TEST(CDROMTest,FindPackages)
{
   Cdrom cd;
  std::string InfoDir;
  EXPECT_TRUE(cd.FindPackages(path, Packages, Sources, Signatur, Translation, 
InfoDir));
...
  EXPECT_EQ(path + "/.disk/", InfoDir);
}
"""
The actual code for this is apt-pkg/cdrom.cc:
"""
bool pkgCdrom::FindPackages(string CD,
   vector &List,
   vector &SList,
   vector &SigList,
   vector &TransList,
   string &InfoDir, pkgCdromStatus *log,
   unsigned int Depth)
{
...
   if (DirectoryExists(".disk") == true)
   {
  if (InfoDir.empty() == true)
  InfoDir = CD + ".disk/";
   }
...
"""

So I suspect that the optimizer gets confused that InfoDir is a
reference or it gets confused because InfoDir is not used in
FindPackages anymore and it assumes its dead code.

I tried to create a simplified testcase but failed so far. Whats interessting 
is that if I add a std::cerr << "debug" line into cdrom.cc lines (or even a "CD 
= CD"):
"""
   if (DirectoryExists(".disk") == true)
   {
  if (InfoDir.empty() == true) {
std::cerr << "debug" << std::endl;
  InfoDir = CD + ".disk/";
}
   }
"""
it works (which indicates dead-code elimination to me).

Reply at:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1473674/comments/4


On 2015-07-14T12:25:42+00:00 Trippels wrote:

Have you tried to build with -fsanitize=undefined?

Reply at:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1473674/comments/5


On 2015-07-14T13:02:47+00:00 Doko-v wrote:

the testsuite passes with -fsanitize=undefined (no additional output)
and both -fsanitize=undefined -fsanitize-undefined-trap-on-error doesn't
abort either.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1473674/comments/6


On 2015-07-16T09:12:36+00:00 Rguenth wrote:

GCC 5.2 is being released, adjusting target milestone to 5.3.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1473674/comments/7


On 2015-07-21T22:10:17+00:00 Bill-schmidt wrote:

Hm.  I compiled it as stated and I see a bunch of code that appears to
be storing the ".disk/" string.  So it doesn't look like dead code
elimination.  Perhaps a branch is short circuiting this, or the address
of where to store it has been corrupted.

I don't have any way to confirm that I'm reproducing the problem when I
compile, from what's given here.  It might be helpful to provide the
full test case without ellipses, and the failure message given by the
test.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1473674/comments/9


On 2015-07-22T13:54:47+00:00 Bill-schmidt wrote:

Using current trunk, I compared the 193t.optimized dumps for the
original cdrom.ii attachment and for the same attachment modified to add
the debug output statement from the end of comment 2.  Other than the
added statements for the debug output, there don't appear to be any
changes.  This bug is marked as 5.1/6 regression -- are you certain that
it regresses on trunk?  Will check 5.1 the same way.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1473674/comments/10


On 2015-07-22T13:55:28+00:00 Bill-schmidt wrote:

Sorry, not from comment 2 on this bugzilla; comment 2 from the launchpad
bug.

Reply at:
https://bugs.launchpad.net/ubuntu/+sou

[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2016-08-13 Thread Matthias Klose
commit 9101c36c653cf90ccd133d6e85eca6b264de4b81
Author: David Kalnischkies 
Date:   Fri Aug 12 19:11:01 2016 +0200

drop "incorrect" const attribute from DirectoryExists

Since its existence in 2010 DirectoryExists was always marked with this
attribute, but for no real reason. Arguably a check for the existence of
the file is not modifying global state, so theoretically this shouldn't
be a problem. It is wrong from a logical point of view through as
between two calls the directory could be created so the promise we made
to the compiler that it could remove the second call would be wrong, so
API wise it is wrong.

The problem for the compiler is a lot more likely through in the
underlying implementation of stat() and co, so for both reasons lets
drop this attribute here and be (hopefully) done with it forever.

It's a bit mysterious that this is only observeable on ppc64el and can be
fixed by reordering code ever so slightly, but in the end its more our
fault for adding this attribute than the compilers fault for doing
something silly based on the attribute.

LP: 1473674

diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 4a1676d..15665f8 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -164,7 +164,7 @@ bool RemoveFile(char const * const Function, std::string 
const &FileName);
 int GetLock(std::string File,bool Errors = true);
 bool FileExists(std::string File);
 bool RealFileExists(std::string File);
-bool DirectoryExists(std::string const &Path) APT_CONST;
+bool DirectoryExists(std::string const &Path);
 bool CreateDirectory(std::string const &Parent, std::string const &Path);
 time_t GetModificationTime(std::string const &Path);
 bool Rename(std::string From, std::string To);

** Changed in: gcc-6 (Ubuntu)
   Status: New => Invalid

** Changed in: gcc-5 (Ubuntu)
   Status: New => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2016-08-13 Thread Launchpad Bug Tracker
This bug was fixed in the package apt - 1.3~rc1ubuntu2

---
apt (1.3~rc1ubuntu2) yakkety; urgency=medium

  * Don't build with -O3. See LP: #1473674.

 -- Matthias Klose   Fri, 12 Aug 2016 09:44:56 +0200

** Changed in: apt (Ubuntu)
   Status: Confirmed => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2016-08-12 Thread Matthias Klose
seen again  with https://launchpad.net/ubuntu/+source/apt/1.3~rc1ubuntu1
work around with https://launchpad.net/ubuntu/+source/apt/1.3~rc1ubuntu2


** No longer affects: gcc-6 (Ubuntu Wily)

** No longer affects: gcc-5 (Ubuntu Wily)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2016-08-12 Thread Matthias Klose
** Also affects: gcc-6 (Ubuntu)
   Importance: Undecided
   Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2015-11-28 Thread Julian Andres Klode
DonKult added another workaround for this, which is now in 1.1.2:

http://anonscm.debian.org/cgit/apt/apt.git/commit/?id=0300f0077af832e87beb290f26b13404cab81fd3

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2015-07-22 Thread William J. Schmidt
Spent some time trying to reproduce this upstream.  From the information
given, I am unable to do so.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2015-07-21 Thread William J. Schmidt
As a guess, is FindPackages being inlined?  If so, and if the parameter
passed in as &InfoDir isn't subsequently used, the compiler would be
within its rights to remove the assignment to InfoDir.  May want to
check callers of FindPackages for this possibility.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2015-07-14 Thread Matthias Klose
** Bug watch added: GCC Bugzilla #66868
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

** Also affects: gcc via
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868
   Importance: Unknown
   Status: Unknown

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2015-07-14 Thread Matthias Klose
just building apt-pkg/cdrom.cc with -O2 works

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2015-07-14 Thread Michael Vogt
I looked into this and the issue is the following:

There is a Cdrom wrapper:
"""
class Cdrom : public pkgCdrom {
   public:
  bool FindPackages(std::string const &CD,
std::vector &List,
std::vector &SList,
std::vector &SigList,
std::vector &TransList,
std::string &InfoDir) {
 std::string const startdir = SafeGetCWD();
 EXPECT_FALSE(startdir.empty());
 bool const result = pkgCdrom::FindPackages(CD, List, SList, SigList, 
TransList, InfoDir, NULL, 0);
...
}
"""

and a unittest that calls it:
"""
TEST(CDROMTest,FindPackages)
{
   Cdrom cd;
  std::string InfoDir; 
  EXPECT_TRUE(cd.FindPackages(path, Packages, Sources, Signatur, Translation, 
InfoDir));
...
  EXPECT_EQ(path + "/.disk/", InfoDir);
}
"""

The actual code for this is apt-pkg/cdrom.cc:
"""
bool pkgCdrom::FindPackages(string CD,
vector &List,
vector &SList, 
vector &SigList,
vector &TransList,
string &InfoDir, pkgCdromStatus *log,
unsigned int Depth)
{
...
   if (DirectoryExists(".disk") == true)
   {
  if (InfoDir.empty() == true)
 InfoDir = CD + ".disk/";
   }
...
"""

So I suspect that the optimizer gets confused that InfoDir is a
reference or it gets confused because InfoDir is not used in
FindPackages anymore and it assumes its dead code.

I tried to create a simplified testcase but failed so far. Whats interessting 
is that if I add a std::cerr << "debug" line into cdrom.cc lines (or even a "CD 
= CD"):
"""
   if (DirectoryExists(".disk") == true)
   {
  if (InfoDir.empty() == true) {
std::cerr << "debug" << std::endl;
 InfoDir = CD + ".disk/";
}
   }
"""
it works (which indicates dead-code elimination to me).

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1473674] Re: apt fails a test from the testsuite on ppc64el when built with gcc-5 and -O3

2015-07-11 Thread Matthias Klose
the test fails too on amd64 with -O3

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1473674

Title:
  apt fails a test from the testsuite on ppc64el when built with gcc-5
  and -O3

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1473674/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs