Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 446684 - net-misc/lksctp-tools wrong inclusion order can trigger build failures
Summary: net-misc/lksctp-tools wrong inclusion order can trigger build failures
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Diego Elio Pettenò (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-10 03:41 UTC by Paul Preney
Modified: 2012-12-10 20:44 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
This file demonstrates the bug if the DEMONSTRATE_BUG is defined. (bug-demo.cxx,293 bytes, text/plain)
2012-12-10 03:41 UTC, Paul Preney
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Preney 2012-12-10 03:41:11 UTC
Created attachment 331918 [details]
This file demonstrates the bug if the DEMONSTRATE_BUG is defined.

With package net-misc/lksctp-tools there is:

    #define IPPROTO_SCTP    132

in /usr/include/netinet/sctp.h on line 50. It is enclosed within a #ifndef IPPROTO_SCTP ... #endif (i.e., in lines 49 and 51). Unfortunately, this means if that one writes:

    #include <netinet/in.h>
    #include <netinet/sctp.h>

the code will compile correctly, but, if one writes (or more likely indirectly #includes these files in this order):

    #include <netinet/sctp.h>
    #include <netinet/in.h>

it will not since IPPROTO_SCP will be defined to be 132 and this will cause netinet/in.h to fail compiling with the following error:

    $ g++ -DDEMONSTRATE_BUG bug-demo.cxx                     [22:24]
    In file included from bug-demo.cxx:12:0:
    /usr/include/netinet/in.h:86:5: error: expected identifier before numeric constant
    /usr/include/netinet/in.h:86:5: error: expected ‘}’ before numeric constant
    /usr/include/netinet/in.h:86:5: error: expected unqualified-id before numeric constant
    bug-demo.cxx:13:1: error: expected declaration before ‘}’ token
    $

since that line is part of an enum declaration with the following in it:

    IPPROTO_SCTP = 132,    /* Stream Control Transmission Protocol.  */

i.e., IPPROTO_SCTP will be replaced by the preprocessor with 132 resulting in the line 132 = 132 --which explains the error the compiler reports.

These are the relevant files (and the versions of the packages I have installed):

/usr/include/netinet/in.h is from sys-libs/glibc-2.15-r3
/usr/include/netinet/sctp.h is from net-misc/lksctp-tools-1.0.11-r1

This bug can be easily reproduced using the very short attached program. Run it as follows:

    $ g++ bug-demo.cxx && ./a.out
    132
    $ g++ -DDEMONSTRATE_BUG bug-demo.cxx && ./a.out
    In file included from bug-demo.cxx:15:0:
    /usr/include/netinet/in.h:86:5: error: expected identifier before numeric constant
    /usr/include/netinet/in.h:86:5: error: expected ‘}’ before numeric constant
    /usr/include/netinet/in.h:86:5: error: expected unqualified-id before numeric constant
    bug-demo.cxx:16:3: error: expected declaration before ‘}’ token
    zsh: exit 1     g++ -DDEMONSTRATE_BUG bug-demo.cxx
    $

FYI, emerge --info net-misc/lksctp-tools reports:

Portage 2.1.11.31 (default/linux/amd64/10.0/desktop/kde, gcc-4.5.4, glibc-2.15-r3, 3.5.7-gentoo x86_64)
=================================================================
                        System Settings
=================================================================
System uname: Linux-3.5.7-gentoo-x86_64-Intel-R-_Core-TM-_i7_CPU_Q_720_@_1.60GHz-with-gentoo-2.1
Timestamp of tree: Mon, 10 Dec 2012 01:45:01 +0000
ld GNU ld (GNU Binutils) 2.22
app-shells/bash:          4.2_p37
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.3-r2, 3.2.3
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.27.1
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.11.6
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.9.6-r3, 1.10.3, 1.11.6
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.5.4, 4.8.0_alpha20121202::toolchain
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.1 (virtual/os-headers)
sys-libs/glibc:           2.15-r3
Repositories: gentoo toolchain
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -mtune=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0 /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.4/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -mtune=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--jobs=7 --load-average=7 --complete-graph=y --with-bdeps=y --ask-enter-invalid --autounmask=y --autounmask-write=y --keep-going=y"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch parallel-install protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://mirror.csclub.uwaterloo.ca/gentoo-distfiles/"
LANG="en_CA.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j7 -l7"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/toolchain"
SYNC="rsync://rsync4.ca.gentoo.org/gentoo-portage"
USE="64bit X Xaw3d a52 aac aalib accessibility acl acpi addressbook aim akonadi alsa amd64 amr ao apache2 apng aspell attica audiofile autoipd avahi bash-completion bazaar bcmath berkdb bidi binfilter blas blender blender-game bluetooth boost branding bs2b btrfs bzip2 bzlib cairo calendar canna caps cdda cddb cdr cgi cjk clamav cleartype cli consolekit context contrast contrib coverage coverart cracklib crypt cscope css ctype cups curl curlwrappers cvs cxx cyrillic dar64 dbase dbi dbm dbus dbx dc1394 declarative derby designer-plugin desktop-globe detex device-mapper dga dia dirac directfb djvu dmraid doc docbook dot dri dselect dts dv dvb dvd dvdr dvdread dvi2tty dvipdfm eap-sim emacs embedded emboss emovix en enchant encode enscript espeak evo examples exif expat extensions extra extras faac faad fam farcs fasteap fat fax fbcon festival ffmpeg fftw firefox firefox3 fits flac flatfile fltk fluidsynth fontconfig foomaticdb fortran freetds freewnn ftp g3dvl games gcdmaster gcrypt gd gdbm genlocation geoip ggi gif gimp ginac git glew glitz glut gme gmp gnome gnome-keyring gnumeric gnuplot gnustep gnutls go gphoto2 gpm gps gpu graphics graphite graphviz gsl gsm gstreamer gtk gtkhtml gtkstyle gucharmap guile gzip handbook hddtemp hdf5 hfs hotpixels hpijs html humanities hunspell iconv icq icu id3tag idn ieee1394 imagemagick imlib indi inifile innodb iodbc ipod ipv6 jabber jack jadetex java java6 javascript jbig jce jfs jingle joystick jpeg jpeg-2k jpeg2k kate kde kdepim kerberos kipi kontact kpathsea ladspa lame lapack lash latex latex3 lcdfilter lcms ldap lensfun libass libcaca libgda libnotify libproxy libsamplerate libtiger libv4l libv4l2 libwww lirc live lm_sensors lua luatex lvm lyx lzma lzo m17n-lib macvtap mad maildir mailwrapper matroska mbox mbrola mcve md5sum mdadm mdnsresponder-compat meanwhile memlimit mercurial mhash midi migemo mikmod milter mime mjpeg mmap mmx mmxext mng mod modplug modules mono motif mozilla mp3 mp4 mpeg mpg123 mpi mpithreads mplayer msn mtp mudflap mule multilib multimedia musepack music musicbrainz mysql nas ncurses neXt netboot netcdf network networking networkmanager nfs nis nlpsolver nls nntp nocd nova nptl nsplugin ntfs ntpl numa nut nuv objc objc++ objc-gc ocaml ocamlopt odbc odk offensive offlinehelp ofx ogg okular omega openal openexr opengl openmp openvg oscar otr pam pango parted parti pcap pch pcntl pcre pda pdf pdfannotextractor pdfimport pdo perl phonon php phyp plasma plotutils png pnm policykit posix postgres postproc ppds pppd projectm pstricks publishers pulseaudio pvr python qemu qemu-ifup qimageblitz qqwry qscintilla qt3support qt4 quicktime qwt radio radius raw rdesktop rdesktop-vrdp readline reiser4 reiserfs rss rtf rtmp rtsp ruby samba sasl scanner schroedinger science script sdk sdl sdl-image semantic-desktop server session sharedext sharedmem shorten shout simplexml skins skype slang slp smartcard smp sms sndfile soap sockets socks5 soundtouch sox speex spell spice sqlite sqlite3 sse sse2 sse3 sse4 sse4_1 ssh ssl ssse3 stars startup-notification stream subversion suid svg symlink syslog sysvipc szip t1lib taglib tcl tcpd templates tex4ht theora threads tidy tiff timezone timidity tk tokenizer truetype twolame type1 udev udev-acl udisks unicode upnp upower usb utils v4l v4l2 vaapi vamp vcd vcdx vde vdpau vdr verse vhosts video videos vim-syntax virt-network virtualbox vlm vnc vorbis vpx wavpack webdav webdav-serf webkit webp wifi wimax wma-fixed wmf wps wxwidgets x264 xanim xattr xcb xcomposite xetex xfs xft xindy xinerama xinetd xml xmlrpc xmp xnest xosd xpm xscreensaver xsl xulrunner xv xvid xvmc yahoo yaz yv12 zeroconf zip zlib zsh-completion zvbi" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_CA en_GB en_US fr fr_CA fr_FR es es_MX es_US es_ES" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="nvidia vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

net-misc/lksctp-tools-1.0.11-r1 was built with the following:
USE="(consolekit) (multilib) (policykit) -static-libs"
CFLAGS="-march=native -mtune=native -O2 -pipe -fno-strict-aliasing"
CXXFLAGS="-march=native -mtune=native -O2 -pipe -fno-strict-aliasing"
Comment 1 Paul Preney 2012-12-10 03:52:15 UTC
I should also add that /usr/include/netinet/sctp.h has this larger block of code (lines 44 to 51):

   /* Socket option layer for SCTP */
   #ifndef SOL_SCTP
   #define SOL_SCTP  132
   #endif

   #ifndef IPPROTO_SCTP
   #define IPPROTO_SCTP    132
   #endif

I see no reason for such (IMHO very bad code for a header file) when netinet/in.h defines IPPROTO_SCTP. (Similarly, what is the purpose of the conditional #define of SOL_SCTP?)
Comment 2 Paul Preney 2012-12-10 04:20:11 UTC
FYI, I have also filed a bug report with the lksctp-tools project asking them to remove the offending lines. (I am waiting for moderation to permit my report through so I cannot provide a link yet.)
Comment 3 Diego Elio Pettenò (RETIRED) gentoo-dev 2012-12-10 20:44:19 UTC
Please report this upstream.