Please apply upstream patch for dpkg-buildsource

Bug #234901 reported by ITO Nobuaki
4
Affects Status Importance Assigned to Milestone
dpkg (Ubuntu)
Won't Fix
Undecided
Unassigned
samba (Ubuntu)
Fix Released
Medium
Steve Langasek

Bug Description

Binary package hint: dpkg

Release: Ubuntu Hardy (8.04)
Package: dpkg 1.14.16.6ubuntu3

Script dpkg-buildsource includes harmful default option "-Wl,-Bsymbolic-functions" for LDFLAGS.

This affects many "pkg-config"-like mechanizm based programs, such as krb5-config, mysql-config, net-snmp-config, etc. And this flag cascades to other packages such as cupsys, samba, etc, using such packages.

Upstream of dpkg fixed this bug on this commit:
http://git.debian.org/?p=dpkg/dpkg.git;a=commit;h=12617e848c82f2c5809fb2112170177ad9cda4e6

But the version of the source in Ubuntu Hardy differs from it, So I created patch having same meaning. (I attached to this report).

Further information:

Linker flag "-Bsymbolic(-functions)" is for library developers, not for library users.
Unintended usage for this flag may break condition on run-time, for example, non-correct initialization.

Example:

Samba package was built with "-Wl,Bsymbolic-functions" flag unintentionally.
(This flag was incorporated by krb5-config and cups-config.)

If you use "wins" option for "host" in nsswitch.conf, following simple program built with "-lsmbclient" stops accidentally.

#include <netdb.h>
int main(int argc, char *argv[])
{
    gethostbyname("non-existent hostname or NMB hostname");
    return 0;
}

(Mechanism: Both of libsmbclient.so and libnss_wins.so include same source lib/debug.c. That file has symbol named "DEBUGLEVEL_CLASS" as variable, and symbol named "debug_add_class" as function. With "-Bsymbolic-functions" flag, the symbol "debug_add_class" is resolved in each library, but the symbol "DEBUGLEVEL_CLASS" is commonly allocated for both of libraries. Libnss_wins.so falsely recognizes DEBUGLEVEL_CLASS is already initialized. And realloc() for uninitialized area fails. This is not a samba's bug. Unintentional use "-Wl,-Bsymbolic-functions" fires that bug.)

Revision history for this message
ITO Nobuaki (daydream-trippers+bugs) wrote :
Revision history for this message
Colin Watson (cjwatson) wrote :

We've already taken most of the hit of introducing -Wl,-Bsymbolic-functions in Hardy; it was an intentional decision, although it's true that it has had slightly more consequences than we'd like. Rather than reverting it, I think the minimal fix for Hardy would be to cause samba's packaging to cancel the LDFLAGS that are undesirable for it.

Revision history for this message
ITO Nobuaki (daydream-trippers+bugs) wrote :

Thanks for your comment. I got two points from your message.

1. Using linker flag "-Bsymbolic-functions" for building library is your policy.

Certainly it's not bad idea. It makes shared libraries more robust, so it seems to be good manner indeed.
(But ... I wonder why not "-Bsymbolic" instead of "-Bsymbolic-functions". Could you tell me the reason?)

2. In some conditions, Samba might not work well if it is built with "-Bsymbolic-functions".

In further update, the flag "-Bsymbolic-functions" would be removed from Samba package.

Still now I have to say my opinion:
- The linker flag "-Bsymbolic(-functions)" is for build-time usage principally.
- Do not force developers to use the flag who link their program against those libraries.

As you have already written, "dpkg" itself doesn't need to be modified. On the other hand, some of "*-config" scripts apply build-time LDFLAGS for "--libs" configuration. That make unfortunate consequences.

Upon my little investigation, following programs incorrectly state "-Bsymbolic-functions" when they are called with "--libs" or "--ldflags" argument.

- krb5-config in krb5
- cups-config in cupsys
- net-snmp-config in net-snmp
- mysql_config in mysql-dfsg (see https://bugs.launchpad.net/ubuntu/+source/mysql-dfsg-5.0/+bug/225741)

More affected packages may exist. There are many many packages in Ubuntu, so I could not cover them all. I think these packages would be modified.

Not all of packages (having *-config script) are affected. Some programs (ex. pth-config in pth) don't have "-Bsymbolic-functions" (but was built with "-Bsymbolic-functions"). And some packages which support pkg-config (ex. libssl) have "-Bsymbolic-functions" in "Libs.private", not in "Libs". Good.

Steve Langasek (vorlon)
Changed in samba:
assignee: nobody → vorlon
Revision history for this message
Richard Laager (rlaager) wrote :

Given the last comment, shouldn't this be marked as a duplicate of #225741, with that bug having tasks added for krb5, cupsys, and net-snmp-config? (This also brings up the point that those libraries should use pkg-config instead of their own -config application.)

Steve Langasek (vorlon)
Changed in samba:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Nigel Babu (nigelbabu) wrote :

Thank you for the patch, however,based on cjwatson's comments above, I'm rejecting this patch. Please feel free to remove the patch-rejected tag if you have a new patch that needs to be reviewed.

tags: added: patch-rejected
Revision history for this message
Raphaël Hertzog (hertzog) wrote :

Upstream doesn't impose anything. ubuntu has made the choice to keep that setting via the Dpkg::Vendor infrastructure. Thus marking it as wontfix for dpkg.

Changed in dpkg (Ubuntu):
status: New → Won't Fix
Revision history for this message
Steve Langasek (vorlon) wrote :

I'm not sure by what mechanism this has been fixed, but testing with nss_wins + libsmbclient in precise, I can no longer reproduce a crash due to -Wl,-Bsymbolic-functions.

According to the build log at https://launchpad.net/ubuntu/+source/samba/2:3.6.3-1ubuntu1/+build/3228461/+files/buildlog_ubuntu-precise-amd64.samba_2%3A3.6.3-1ubuntu1_BUILDING.txt.gz, the latest samba is built with these options:

      LDFLAGS = -pie -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -L./bin
      LDSHFLAGS = -fPIC -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -L./bin -lc -Wl,-z,defs

Perhaps the presence of -Bsymbolic here resolves this.

Changed in samba (Ubuntu):
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.