FTBFS of Dovecot 2.2.25 in Ubuntu due to -Bsymbolic-functions

Bug #1636781 reported by Christian Ehrhardt 
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dovecot (Ubuntu)
Fix Released
High
Christian Ehrhardt 

Bug Description

I was wondering about a crash when building dovecot 2.2.25 on latest Ubuntu.
I wondered as I've had the same source building on Debian just fine.

Some debugging led me to this weird behavior:
Using this gdb command file called autoreportissue in my case:
break dcrypt_initialize
  commands
    p dcrypt_vfs
    p &dcrypt_vfs
    watch dcrypt_vfs
    c
  end
break dcrypt_set_vfs
  commands
    p dcrypt_vfs
    p &dcrypt_vfs
    c
  end
r

Running test-crypto on Debian and Ubuntu reported those two behaviours:
gdb -d /root/dovecot-2.2.25/src/ -x autoreportissue ./test-crypto

Good:
Breakpoint 1, dcrypt_initialize (backend=0x555555587c02 "openssl", set=0x0, error_r=0x0) at dcrypt.c:15
15 if (dcrypt_vfs != NULL) {
$1 = (struct dcrypt_vfs *) 0x0
$2 = (struct dcrypt_vfs **) 0x555555796370 <dcrypt_vfs>
Hardware watchpoint 3: dcrypt_vfs
Breakpoint 2, dcrypt_set_vfs (vfs=0x7ffff7835020 <dcrypt_openssl_vfs>) at dcrypt.c:56
56 dcrypt_vfs = vfs;
$3 = (struct dcrypt_vfs *) 0x0
$4 = (struct dcrypt_vfs **) 0x555555796370 <dcrypt_vfs>
Hardware watchpoint 3: dcrypt_vfs
Old value = (struct dcrypt_vfs *) 0x0
New value = (struct dcrypt_vfs *) 0x7ffff7835020 <dcrypt_openssl_vfs>
dcrypt_set_vfs (vfs=0x7ffff7835020 <dcrypt_openssl_vfs>) at dcrypt.c:57
57 }

Bad:
Breakpoint 1, dcrypt_initialize (backend=0x555555589f02 "openssl", set=0x0, error_r=0x0) at dcrypt.c:11
11 {
$1 = (struct dcrypt_vfs *) 0x0
$2 = (struct dcrypt_vfs **) 0x555555798370 <dcrypt_vfs>
Hardware watchpoint 3: dcrypt_vfs
Breakpoint 2, dcrypt_set_vfs (vfs=0x7ffff780a020 <dcrypt_openssl_vfs>) at dcrypt.c:56
56 dcrypt_vfs = vfs;
$3 = (struct dcrypt_vfs *) 0x0
$4 = (struct dcrypt_vfs **) 0x7ffff780a890 <dcrypt_vfs>
Panic: file dcrypt.c: line 34 (dcrypt_initialize): assertion failed: (dcrypt_vfs != NULL)
Error: Raw backtrace: /root/dovecot-2.2.25/src/lib-dcrypt/test-crypto(+0x15f7c) [0x555555569f7c] -> /root/dovecot-2.2.25/src/lib-dcrypt/test-crypto(default_error_handler+0) [0x55555556a030] -> /root/dovecot-2.2.25/src/lib-dcrypt/test-crypto(i_fatal+0) [0x55555556a2ff] -> /root/dovecot-2.2.25/src/lib-dcrypt/test-crypto(dcrypt_initialize+0x140) [0x55555555f030] -> /root/dovecot-2.2.25/src/lib-dcrypt/test-crypto(main+0x23) [0x55555556706d] -> /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x7ffff782d3f1] -> /root/dovecot-2.2.25/src/lib-dcrypt/test-crypto(_start+0x2a) [0x55555555edea]
Program received signal SIGABRT, Aborted.

One can see that in the bad case the pointer of dcrypt_vfs is pointing to something of the scope of the .libs/libdcrypt_openssl.so file and not the dcrypt_initialize of test-crypto.

That made me wonder even more - where would this issue of variable scope come from. After more debugging I found that the linker flag "-Bsymbolic-functions" is the reason. This is default on recent Ubuntu, but not on Debian (?yet?).

Eventually what happens is that the dcrypt_vfs becomes part of the .libs/libdcrypt_openssl.so. So the call from there to dcrypt_set_vfs ends up setting not the expected variable.
I was unable to come up with a reasonable fix since I'm not enough into your sublib structure.

For now - on the merge - I'm adding a workaround to strip this flag in Ubuntu as other packages with the same issue did the same.

I'll write it in a way to make it Debian includeable if they are willing to accept to reduce more delta later on.

Changed in dovecot (Ubuntu):
status: New → Triaged
importance: Undecided → High
assignee: nobody → ChristianEhrhardt (paelzer)
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I made some experiments if the smaller diff of adding "--dynamic-list-data" would be enough.
That would keep the effect of the otherwise default "-Bsymbolic-functions", but not for global symbols.

Since the debugged case was for a variable that might have helped, but it did not.
Therefore the solution is like in several other packages to strip the "-Bsymbolic-functions" option.

I reported to upstream Dovecot in the hope to one day be able to drop the delta.
In case that fails the fix is guarded by a "ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes)".
That is used in other non-delta packages for similar things to make it into Debian.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thread now at upstream and response is good, so we might get a "real fix" sometime:
See http://www.dovecot.org/list/dovecot/2016-October/105856.html

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

This bug was fixed in the package dovecot - 1:2.2.25-1ubuntu1

---------------
dovecot (1:2.2.25-1ubuntu1) zesty; urgency=medium

  * Merge with Debian (LP: #1633220); Remaining Changes:
    + Add updated autopkgtest to debian/tests/*.
    + Drop build dependency on libstemmer-dev (universe)
    + Use Snakeoil SSL certificates by default
      - d/control: Depend on ssl-cert
    + Add mail-stack-delivery
      - add package in d/rules, d/control
      - add d/*mail-stack-delivery* maintainer scripts and default conf
      - d/mail-stack-delivery.preinst: Move previously installed backups and
        config files to a new package namespace.
      - d/mail-stack-delivery.README.Debian clarified use of configuration files
    + Disable dovecot-lucene plugin as it had various issues, has universe
      dependencies and is deprecated in favor of solr anyway.
    + handle conffile removal of /etc/init/dovecot.conf (due to dropping
      upstart). Can be removed once no upgrade path from <yakkety is left.
  * Added changes:
    + Fix FTBFS of dovecot 2.2.25 in Ubuntu due to being incompatible with
      -Bsymbolic-functions linker flag (LP: #1636781).
  * Dropped Changes as they got accepted in Debian:
    + add lsb base dependency to ensure debian/dovecot-core.dovecot.init is
      working correctly
    + Add ufw integration:
      - d/dovecot-core.ufw.profile: new ufw profile.
      - d/rules: install profile in dovecot-core.
      - d/control: dovecot-core - suggest ufw.
    + Add apport hook:
      - d/rules, d/source_dovecot.py
    + Remove lintian override for drac

 -- Christian Ehrhardt <email address hidden> Tue, 25 Oct 2016 13:12:40 +0200

Changed in dovecot (Ubuntu):
status: Triaged → 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.