PendingMessages member variable of APT's GlobalError class initializes as "true" with -std=c++11

Bug #1000508 reported by Jonathan Thomas
26
This bug affects 7 people
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Fix Released
High
Unassigned
gcc-4.7 (Ubuntu)
Fix Released
High
Unassigned

Bug Description

Symptoms: If a program using libapt-pkg is compiled with -std=c++11 with gcc 4.7 (this used to work in gcc 4.6), APT's global GlobalError class[1] (accessible via the macro "_error" in any file that includes apt-pkg/error.h) always returns "true" when the PendingError() member is called. This happens directly after the GlobalError instance is created, so there is no chance for libapt-pkg to have put anything on the error stack. Calling Discard() or DumpErrors() does not clear the flag, and none of the functions that print the errors to stdout actually print anything. (Presumably, the error stack really is empty)

This behavior is not present when compiling an application with -std=c++11 with gcc 4.6, and the issue goes away if compiled without the c++11 cxxflag with gcc 4.7.

The impact is fairly severe. The libqapt library utilizes c++11 features in its source code, so this effectively breaks the qaptworker runtime utility from running any sort of apt transaction (Cache update, commit) due to the fact that it can't check for errors reliably, and will error out immediately due to the detected "error". This, in effect, breaks the Muon Suite (Kubuntu's default package manager.) which uses libqapt (and the qaptworker) for running apt tasks that require administrative access. For this reason I'm assigning the bug priority for this report to "high".

I've attached a (very) small Minimally Reproducible Testcase along with a small build script that should aid in making testing this bug convenient. The test case prints "error!" if the bug is present, and will return silently if everything is working as it should.

[1]http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/quantal/apt/quantal/view/head:/apt-pkg/contrib/error.cc (also error.h)

Revision history for this message
Jonathan Thomas (echidnaman) wrote :
Changed in apt (Ubuntu):
importance: Undecided → High
Revision history for this message
Jonathan Thomas (echidnaman) wrote :
tags: added: kubuntu
Changed in gcc-4.7 (Ubuntu):
milestone: none → quantal-alpha-1
Changed in apt (Ubuntu):
milestone: none → quantal-alpha-1
Revision history for this message
David Kalnischkies (donkult) wrote :

I can confirm this as long as APT isn't build with the -std=c++11 flag, too. [0]
The boolean is properly initialized in the (only) constructor to false, so this doesn't make that much sense.

[0] It fails to build currently, but the fix is simple:
Compiling http.cc to ../build/obj/methods/http.o
http.cc: In member function ‘void HttpMethod::SendReq(pkgAcqMethod::FetchItem*, CircleBuf&)’:
http.cc:761:41: error: unable to find string literal operator ‘operator"" PACKAGE_VERSION’
make[1]: *** [../build/obj/methods/http.o] Fehler 1
Just add spaces around the constant - the c++11 standard requires it. (same for https.cc)

After these two fixes APT builds happily (tested on debian gcc4.7.0-8) - also it's testcases which are executed at buildtime: test/libapt/globalerror_test.cc which doesn't fail, so everything seems to be fine then.

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

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in apt (Ubuntu):
status: New → Confirmed
Changed in gcc-4.7 (Ubuntu):
status: New → Confirmed
Changed in gcc-4.7 (Ubuntu):
milestone: quantal-alpha-1 → quantal-alpha-2
Changed in apt (Ubuntu):
milestone: quantal-alpha-1 → quantal-alpha-2
Revision history for this message
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:
http://iso.qa.ubuntu.com/qatracker/reports/bugs/1000508

tags: added: iso-testing
Revision history for this message
Matthias Klose (doko) wrote :
Revision history for this message
Michael Vogt (mvo) wrote :

So my understanding of this is that if we build libapt itself with "-std=c++11 " the ABI issue is fixed, we need a ABI bump in libapt for this but it will (after a rebuild) not break old that do not build with "-std=c++11". Or is this a XOR either all clients (synpaptic, python-apt, qapt etc etc) need -std=c++11 or none?

Revision history for this message
Michael Vogt (mvo) wrote :

Talking to Doko about this it seems like my suggestion in #8 is actually bogus.

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

this is a change in GCC 4.7's c++11 mode (see http://gcc.gnu.org/wiki/Cxx11AbiCompatibility). There is no "easy" solution. c++0x/c++11 mode is still marked experimental in GCC, so better don't use it in production code. so either:

 - build qapt in c++98 mode
 - rebuilding libapt-pkg in c++11 mode isn't a solution, because it will break binaries,
    which are built in c++98 mode.
 - build libapt-pkg both in c++98 and c++11 mode with a different soname. This approach
   doesn't scale for the whole distribution.
 - avoid the ABI incompatibility by changing libapt-pkg's ABI, so that it works with both
   c++98 and c++11 mode ().

The last one may be an option until you find the next incompatibility, so in the long term it might be better to just build in c++98 mode.

Changed in gcc-4.7 (Ubuntu):
status: Confirmed → Won't Fix
Changed in apt (Ubuntu):
milestone: quantal-alpha-2 → quantal-alpha-3
Revision history for this message
Matthias Klose (doko) wrote :

so, this is now backed out in the gcc-4.7 package, pending a proper upstream solution.

Changed in gcc-4.7 (Ubuntu):
status: Won't Fix → In Progress
Revision history for this message
Michael Vogt (mvo) wrote :

A new version of apt was uploaded since the new gcc hit the archive so it got rebuild already and there is no need for anything else on the apt side AFAICT. Closing this bug, please reopen if I'm missing something.

Changed in apt (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Matthias Klose (doko) wrote :

was reverted upstream, now in quantal

Changed in gcc-4.7 (Ubuntu):
milestone: quantal-alpha-2 → none
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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