Compilation error: /usr/include/nss/pkcs11n.h:365:26: error: "__GNUC_MINOR" is not defined

Bug #915069 reported by Thomas Bechtold
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NSS
Fix Released
Medium
nss (Debian)
Fix Released
Unknown
nss (Ubuntu)
Fix Released
High
Unassigned

Bug Description

i tried to build network-manager from git and got the following compilation error:

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../include -I../include -pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/dbus-1.0 -I/usr/lib/i386-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/uuid -DG_DISABLE_DEPRECATED -I/usr/include/nss -I/usr/include/nspr -Wall -std=gnu89 -g -O2 -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wfloat-equal -Wno-unused-parameter -Wno-sign-compare -fno-strict-aliasing -Wno-unused-but-set-variable -Wundef -Werror -MT libnm_util_la-crypto_nss.lo -MD -MP -MF .deps/libnm_util_la-crypto_nss.Tpo -c crypto_nss.c -fPIC -DPIC -o .libs/libnm_util_la-crypto_nss.o
In file included from /usr/include/nss/pkcs11t.h:1780:0,
                 from /usr/include/nss/keythi.h:41,
                 from /usr/include/nss/keyt.h:41,
                 from /usr/include/nss/pk11pub.h:43,
                 from crypto_nss.c:31:
/usr/include/nss/pkcs11n.h:365:26: error: "__GNUC_MINOR" is not defined [-Werror=undef]
cc1: all warnings being treated as errors

i did:
./autogen.sh && make with the latest git snapshot from NM.

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: libnss3 3.13.1.with.ckbi.1.88-1ubuntu2
ProcVersionSignature: Ubuntu 3.2.0-8.14-generic 3.2.0
Uname: Linux 3.2.0-8-generic i686
ApportVersion: 1.90-0ubuntu1
Architecture: i386
Date: Wed Jan 11 23:16:44 2012
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release i386 (20110426)
SourcePackage: nss
UpgradeStatus: Upgraded to precise on 2012-01-10 (1 days ago)

Related branches

Revision history for this message
In , Chemobejk (chemobejk) wrote :

PROBLEM:

A pidgin-sipe user complained about compilation errors when he compiled it against NSS 3.13.1 on OpenSuse 11.4. Here are the important bits from the GCC command line:

gcc ... -Werror -Wall -Wextra -Waggre gate-return -Wcast-align -Wdeclaration-after-statement -Winit-self -Wmissing-dec larations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wundef ... -I/usr/include/nss3 -I/usr/include/nspr4 ... -c sipe-cert-crypto-nss.c
cc1: warnings being treated as errors
In file included from /usr/include/nss3/pkcs11t.h:1780:0,
                           from /usr/include/nss3/keythi.h:41,
                           from /usr/include/nss3/keyt.h:41,
                           from /usr/include/nss3/cert.h:55,
                           from sipe-cert-crypto-nss.c:29:
 /usr/include/nss3/pkcs11n.h:365:26: error: "__GNUC_MINOR" is not defined

The same code compiles fine with NSS < 3.13.

ROOT CAUSE:

In 3.13.1 pkcs11n.h has this construct:

#if __GNUC__ > 3
...
#if (__GNUC__ == 4) && (__GNUC_MINOR < 5)
...
#else

which is clearly incorrect. It assumes __GNUC__ is defined, i.e. GCC, and __GNUC_MINOR is a typo.

PROPOSED FIX:

pkcs11n.h should have instead:

#if defined(__GNUC__) && (__GNUC__ > 3)
...
#if (__GNUC__ == 4) && (__GNUC_MINOR__ < 5)
...
#else

That should work with all compilers and fix the __GNUC_MINOR__ typo.

Revision history for this message
In , Chemobejk (chemobejk) wrote :

The problem was introduced in v1.22 with the fix for bug #642503.

See comment: https://bugzilla.mozilla.org/show_bug.cgi?id=642503#c20

Revision history for this message
In , Rrelyea (rrelyea) wrote :

Elio, this looks like the same issue you are dealing with.

The reason we don't trip over the undefines is we don't flip the flag to make undefined comparisons an error.

Also we currently only have built this with GCC 3.x or GCC 4.5 or greater. This patch will allow GCC 4.1, for instance, to work correctly.

bob

Revision history for this message
In , T-matsuu (t-matsuu) wrote :

Created attachment 575453
fix

Prepare a patch what comment 0 says.

Revision history for this message
In , Kai Engert (kaie) wrote :

Comment on attachment 575453
fix

This is obviously correct. r=kaie

Revision history for this message
In , Kai Engert (kaie) wrote :

checked in

Checking in pkcs11n.h;
/cvsroot/mozilla/security/nss/lib/util/pkcs11n.h,v <-- pkcs11n.h
new revision: 1.27; previous revision: 1.26
done

Revision history for this message
Thomas Bechtold (toabctl) wrote :
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Could be distro-patched I guess, since we already know what the changes would need to be from the upstream bug at Mozilla... Needs a once over by the security team though.

We don't run into this building the NM package because -Wundef and -Werror aren't passed to gcc.

Changed in nss (Ubuntu):
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Patch in upstream mozilla bug looks fine to me, __GNUC_MINOR is obviously a typo. ACK.

Changed in nss (Debian):
status: Unknown → Confirmed
Changed in nss:
importance: Unknown → Medium
status: Unknown → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package nss - 3.13.1.with.ckbi.1.88-1ubuntu3

---------------
nss (3.13.1.with.ckbi.1.88-1ubuntu3) precise; urgency=low

  * Fix LP: #915069 - Add patch from upstream to fix an error in pkcs11n.h
    - add debian/patches/98_fix_header_error.patch
    - update debian/patches/series
 -- Chris Coulson <email address hidden> Thu, 12 Jan 2012 11:15:39 +0000

Changed in nss (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
In , Wan-Teh Chang (wtc-google) wrote :

The test
    #if __GNUC__ > 3
is correct even if __GNUC__ is not defined. The C preprocessor
replaces an undefined macro with 0L in a conditional expression.
So if __GNUC__ is not defined, the test
    #if __GNUC__ > 3
will fail, which is the expected result.

Revision history for this message
In , Chemobejk (chemobejk) wrote :

(In reply to Wan-Teh Chang from comment #6)
> The test
> #if __GNUC__ > 3
> is correct even if __GNUC__ is not defined.

You are missing the point. Any non-GCC compiler that has the equivalent of GCCs "-Werror -Wundef" will not compile this statement. ARM RVCT would be one example.

Changed in nss (Debian):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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