unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* problems with symbol hiding on Debian Squeeze i386
@ 2011-07-11 19:25 David Bremner
  2011-07-16 20:34 ` david
  2011-07-16 23:18 ` problems with symbol hiding on Debian Squeeze i386 anarcat
  0 siblings, 2 replies; 6+ messages in thread
From: David Bremner @ 2011-07-11 19:25 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 2678 bytes --]


Julien Valroth reported on IRC that he had problems with the initial
call of 'notmuch new' crashing with

terminate called after throwing an instance of 'Xapian::InvalidArgumentError'

I confirmed that the following quick and dirty patch seems to fix the problem.

--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -36,7 +36,7 @@ LIBRARY_SUFFIX = so
 LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
 SONAME = $(LINKER_NAME).$(LIBNOTMUCH_VERSION_MAJOR)
 LIBNAME = $(SONAME).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
-LIBRARY_LINK_FLAG = -shared -Wl,--version-script=notmuch.sym,-soname=$(SONAME)
+LIBRARY_LINK_FLAG = -shared -Wl,-soname=$(SONAME)
 ifeq ($(LIBDIR_IN_LDCONFIG),1)
 ifeq ($(DESTDIR),)
 LIBRARY_INSTALL_POST_COMMAND=ldconfig

I haven't quite decided what to do about this yet, but I thought I'd get
this on the record, because it seems to me a few people have been having
problems with this.

FWIW, I tested with various versions of xapian and libgmime, but the
problem still exists for  gmime 2.4.25-1, and xapian 1.2.5-1, both
recompiled for squeeze.

If you install the libxapian22 from sid, then gcc and libc6 are both
upgraded, and the problem goes away (but you are not really running
squeeze anymore).  

About the only good news is that the symbol hiding test does indeed fail
on squeeze i386.

I have appended part of the backtrace, in case anyone finds it
illuminating.  As far as I can tell without line numbers, the catch in
_notmuch_message_remove_term is failing. I suppose this could be the
kind of "exceptions start mysteriously malfunctioning" that
http://gcc.gnu.org/wiki/Visibility warns about.

Xapian _seems_ to do the right thing with visisibility
declarations for these exception classes.

I don't know what, if anything to conclude from the fact that everything
seems to work fine in gcc 4.6.

backtrace:

#4  0xf7ac2442 in std::terminate() () from /usr/lib/libstdc++.so.6
#5  0xf7ac2581 in __cxa_throw () from /usr/lib/libstdc++.so.6
#6  0xf7b3fb83 in Xapian::Document::Internal::remove_term(std::string const&) ()
   from /usr/lib/sse2/libxapian.so.22
#7  0xf7b3fc76 in Xapian::Document::remove_term(std::string const&) ()
   from /usr/lib/sse2/libxapian.so.22
#8  0xf7fd5233 in _notmuch_message_remove_term ()
   from /home/bremner/software/upstream/notmuch/lib/libnotmuch.so.1
#9  0xf7fd5389 in notmuch_message_remove_tag ()
   from /home/bremner/software/upstream/notmuch/lib/libnotmuch.so.1
#10 0xf7fd63ea in notmuch_message_maildir_flags_to_tags ()
   from /home/bremner/software/upstream/notmuch/lib/libnotmuch.so.1
#11 0x08050483 in add_files_recursive ()

[-- Attachment #2: Type: application/pgp-signature, Size: 315 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* (no subject)
  2011-07-11 19:25 problems with symbol hiding on Debian Squeeze i386 David Bremner
@ 2011-07-16 20:34 ` david
  2011-07-16 20:34   ` [PATCH 1/2] libnotmuch: export Xapian typeinfo symbols david
  2011-07-16 20:34   ` [PATCH 2/2] debian: add (demangled) Xapian exception typeinfo symbols to libnotmuch1.symbols david
  2011-07-16 23:18 ` problems with symbol hiding on Debian Squeeze i386 anarcat
  1 sibling, 2 replies; 6+ messages in thread
From: david @ 2011-07-16 20:34 UTC (permalink / raw)
  To: notmuch

So, my conclusion is that we need to export these typeinfo symbols,
and it seems to be sufficient to do so to fix the failing tests and
crashes discussed above. I think I managed to add them to the debian
symbols file in a better way, so every toolchain change and different
architecture doesn't make the symbols checking barf. We'll have to see
about that; at least it builds cleanly on i386 and amd64.

In any case, if no-one has strong objections, I plan to push this
(first to release for the fabled bug-fix release, and then merge to
master).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] libnotmuch: export Xapian typeinfo symbols
  2011-07-16 20:34 ` david
@ 2011-07-16 20:34   ` david
  2011-07-17  1:29     ` [PATCH] " david
  2011-07-16 20:34   ` [PATCH 2/2] debian: add (demangled) Xapian exception typeinfo symbols to libnotmuch1.symbols david
  1 sibling, 1 reply; 6+ messages in thread
From: david @ 2011-07-16 20:34 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@debian.org>

The lack of such exporting seems to cause problems catching
exceptions, as suggested by

    http://gcc.gnu.org/wiki/Visibility

This manifested in the symbol-hiding test failing when notmuch was
compile with gcc 4.4.5. On i386, this further manifested as notmuch
new failing to run (crashing with an uncaught exception on first run).
---
 lib/Makefile.local        |    4 +---
 lib/gen-version-script.sh |   16 ++++++++++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)
 create mode 100644 lib/gen-version-script.sh

diff --git a/lib/Makefile.local b/lib/Makefile.local
index 7e2bc87..48f8852 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -76,9 +76,7 @@ $(dir)/$(LIBNAME): $(libnotmuch_modules) notmuch.sym
 	$(call quiet,CXX $(CXXFLAGS)) $(libnotmuch_modules) $(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@
 
 notmuch.sym: lib/notmuch.h
-	printf "{\nglobal:\n" > notmuch.sym
-	sed  -n 's/^\s*\(notmuch_[a-z_]*\)\s*(.*/\t\1;/p' $< >> notmuch.sym
-	printf "local: *;\n};\n" >> notmuch.sym
+	sh lib/gen-version-script.sh < $< > $@
 
 $(dir)/$(SONAME): $(dir)/$(LIBNAME)
 	ln -sf $(LIBNAME) $@
diff --git a/lib/gen-version-script.sh b/lib/gen-version-script.sh
new file mode 100644
index 0000000..1cd33be
--- /dev/null
+++ b/lib/gen-version-script.sh
@@ -0,0 +1,16 @@
+cat <<EOF
+{
+global:
+	_ZTIN6Xapian10LogicErrorE;
+ 	_ZTIN6Xapian12RuntimeErrorE;
+ 	_ZTIN6Xapian16DocNotFoundErrorE;
+ 	_ZTIN6Xapian20InvalidArgumentErrorE;
+ 	_ZTIN6Xapian5ErrorE;
+	_ZTSN6Xapian10LogicErrorE;
+	_ZTSN6Xapian12RuntimeErrorE;
+	_ZTSN6Xapian16DocNotFoundErrorE;
+	_ZTSN6Xapian20InvalidArgumentErrorE;
+	_ZTSN6Xapian5ErrorE;
+EOF
+sed  -n 's/^\s*\(notmuch_[a-z_]*\)\s*(.*/\t\1;/p'
+printf "local: *;\n};\n"
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] debian: add (demangled) Xapian exception typeinfo symbols to libnotmuch1.symbols
  2011-07-16 20:34 ` david
  2011-07-16 20:34   ` [PATCH 1/2] libnotmuch: export Xapian typeinfo symbols david
@ 2011-07-16 20:34   ` david
  1 sibling, 0 replies; 6+ messages in thread
From: david @ 2011-07-16 20:34 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@debian.org>

These are exported (again) by the library to prevent problems with
catching exceptions.
---
 debian/libnotmuch1.symbols |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/debian/libnotmuch1.symbols b/debian/libnotmuch1.symbols
index 8df6fec..05d86e6 100644
--- a/debian/libnotmuch1.symbols
+++ b/debian/libnotmuch1.symbols
@@ -70,3 +70,13 @@ libnotmuch.so.1 libnotmuch1 #MINVER#
  notmuch_threads_get@Base 0.3
  notmuch_threads_move_to_next@Base 0.3
  notmuch_threads_valid@Base 0.3
+ (c++)"typeinfo for Xapian::LogicError@Base" 0.6.1
+ (c++)"typeinfo for Xapian::RuntimeError@Base" 0.6.1
+ (c++)"typeinfo for Xapian::DocNotFoundError@Base" 0.6.1
+ (c++)"typeinfo for Xapian::InvalidArgumentError@Base" 0.6.1
+ (c++)"typeinfo for Xapian::Error@Base" 0.6.1
+ (c++)"typeinfo name for Xapian::LogicError@Base" 0.6.1
+ (c++)"typeinfo name for Xapian::RuntimeError@Base" 0.6.1
+ (c++)"typeinfo name for Xapian::DocNotFoundError@Base" 0.6.1
+ (c++)"typeinfo name for Xapian::InvalidArgumentError@Base" 0.6.1
+ (c++)"typeinfo name for Xapian::Error@Base" 0.6.1
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: problems with symbol hiding on Debian Squeeze i386
  2011-07-11 19:25 problems with symbol hiding on Debian Squeeze i386 David Bremner
  2011-07-16 20:34 ` david
@ 2011-07-16 23:18 ` anarcat
  1 sibling, 0 replies; 6+ messages in thread
From: anarcat @ 2011-07-16 23:18 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

I confirm this fixes the problem for me on Debian squeeze. Patch applies
clean on master too.

A.

-- 
Antoine Beaupré +++ Réseau Koumbit Networks +++ +1.514.387.6262 #208
--------------------------------------------------------------------
Premature optimization is the root of all evil
                        - Donald Knuth

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] libnotmuch: export Xapian typeinfo symbols
  2011-07-16 20:34   ` [PATCH 1/2] libnotmuch: export Xapian typeinfo symbols david
@ 2011-07-17  1:29     ` david
  0 siblings, 0 replies; 6+ messages in thread
From: david @ 2011-07-17  1:29 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@debian.org>

The lack of such exporting seems to cause problems catching
exceptions, as suggested by

    http://gcc.gnu.org/wiki/Visibility

This manifested in the symbol-hiding test failing when notmuch was
compile with gcc 4.4.5. On i386, this further manifested as notmuch
new failing to run (crashing with an uncaught exception on first run).
---

In this revised version, the needed typinfo symbols are computed at
build time.

 lib/Makefile.local        |    4 +---
 lib/gen-version-script.sh |   27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)
 create mode 100644 lib/gen-version-script.sh

diff --git a/lib/Makefile.local b/lib/Makefile.local
index 7e2bc87..a6076ab 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -76,9 +76,7 @@ $(dir)/$(LIBNAME): $(libnotmuch_modules) notmuch.sym
 	$(call quiet,CXX $(CXXFLAGS)) $(libnotmuch_modules) $(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@
 
 notmuch.sym: lib/notmuch.h
-	printf "{\nglobal:\n" > notmuch.sym
-	sed  -n 's/^\s*\(notmuch_[a-z_]*\)\s*(.*/\t\1;/p' $< >> notmuch.sym
-	printf "local: *;\n};\n" >> notmuch.sym
+	sh lib/gen-version-script.sh $< $(libnotmuch_modules) > $@
 
 $(dir)/$(SONAME): $(dir)/$(LIBNAME)
 	ln -sf $(LIBNAME) $@
diff --git a/lib/gen-version-script.sh b/lib/gen-version-script.sh
new file mode 100644
index 0000000..e753eaf
--- /dev/null
+++ b/lib/gen-version-script.sh
@@ -0,0 +1,27 @@
+
+# we go through a bit of work to get the unmangled names of the
+# typeinfo symbols because of
+# http://sourceware.org/bugzilla/show_bug.cgi?id=10326
+
+if [ $# -lt 2 ]; then
+    echo Usage: $0 header obj1 obj2 obj3
+    exit 1;
+fi
+
+HEADER=$1
+shift
+
+printf '{\nglobal:\n'
+nm --defined $* | awk '$3 ~ "Xapian.*Error" {print $3}' | sort | uniq | \
+while read sym; do
+    demangled=$(c++filt $sym)
+    case $demangled in
+	typeinfo*) 
+	    printf "\t$sym;\n"
+	    ;;
+	*)
+	    ;;
+    esac
+done
+sed  -n 's/^\s*\(notmuch_[a-z_]*\)\s*(.*/\t\1;/p' $HEADER
+printf "local: *;\n};\n"
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-17  1:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-11 19:25 problems with symbol hiding on Debian Squeeze i386 David Bremner
2011-07-16 20:34 ` david
2011-07-16 20:34   ` [PATCH 1/2] libnotmuch: export Xapian typeinfo symbols david
2011-07-17  1:29     ` [PATCH] " david
2011-07-16 20:34   ` [PATCH 2/2] debian: add (demangled) Xapian exception typeinfo symbols to libnotmuch1.symbols david
2011-07-16 23:18 ` problems with symbol hiding on Debian Squeeze i386 anarcat

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).