public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Brian Dessent <brian@dessent.net>
To: Jan Nieuwenhuizen <janneke-list@xs4all.nl>
Cc: cygwin-apps@cygwin.com, Dave Korn <dave.korn@artimi.com>,
	 	'hanwen' <hanwen@xs4all.nl>
Subject: Re: PING Jan Nieuwenhuizen re libguile17
Date: Sat, 22 Mar 2008 16:52:00 -0000	[thread overview]
Message-ID: <47E538D0.D8BC29A4@dessent.net> (raw)
In-Reply-To: <1206190998.6525.4.camel@peder.flower>

Jan Nieuwenhuizen wrote:

> libguile does not use C++.  As far as I understand, it is a problem that
> is introduced while linking the dlls.

The problem addressed by PR24196 and --enable-fully-dynamic-string is
entirely centered around an implementation detail of std::string in
libstdc++.  Specifically, libstdc++ has an optimization where empty
std::string objects don't get any memory allocated to them; their
internal storage pointers are instead set equal to a reference to some
static _S_empty_rep_storage object.  This allows them to be created
efficiently as well as allowing comparing for equality with other empty
strings trivially and efficiently.  This works great when libstdc++ is a
shared library as this ensures that there will only be one instance of
_S_empty_rep_storage for the entire process, so libstdc++ can always
recognise an empty std::string by comparing its pointer to the address
of _S_empty_rep_storage.

However Cygwin has never had the luxury of shared gcc target libraries
so every module that links with libstdc++ does so statically.  If you
have a process consisting of an .exe and a .dll which are both linked to
libstdc++, both modules will each have their own instance of
_S_empty_rep_storage.  If a function in one module tries to pass an
empty std::string argument to a function in the other, there will be a
crash because that module will not see that this object is an empty
string because its pointer does not point to that module's version of
_S_empty_rep_storage.  It will see it as a regular, fully initialized
string when in fact it is not.  The fix is to simply pessimize this
optimization by initializing empty std::objects with their own storage
instead of relying on having a global singleton.

The issue should have no effect on code that does not pass std::string
objects across DLLs, and by extension it should have no effect on C.  It
has nothing to do with DLLs in general or linking, and I'm struggling
more and more to see how it would be relevant in this case.

However, I have in fact verified myself that rebuilding libguile with
Cygwin gcc 3.4.4 with the PR24196 patch does fix the problem.  I'm now
wonderding if PR24196 is a red herring and the real issue is an ABI
incompatibility between 3.4 and 4.1.  To verify this hypothesis, I will
try rebuilding libguile with the older version of Cygwin gcc 3.4.4
without the PR24196 patch.

Brian

  parent reply	other threads:[~2008-03-22 16:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-27 12:51 Dave Korn
2008-01-31 16:05 ` Jan Nieuwenhuizen
2008-01-31 16:54   ` Dave Korn
2008-02-04 14:10     ` Jan Nieuwenhuizen
2008-02-04 14:55       ` Dave Korn
2008-03-21 15:07         ` Jan Nieuwenhuizen
2008-03-21 18:57           ` Brian Dessent
2008-03-22 13:03             ` Jan Nieuwenhuizen
2008-03-22 16:52               ` Dave Korn
2008-03-22 16:52               ` Brian Dessent [this message]
2008-03-22 17:02                 ` Dave Korn
2008-03-22 20:25                   ` Brian Dessent
     [not found]                     ` <1206438594.26012.14.camel@peder.flower>
2008-03-25 13:02                       ` Dave Korn
2008-03-26 11:22                         ` Jan Nieuwenhuizen
2008-03-26 13:38                           ` Dave Korn
2008-03-26 15:20                             ` Jan Nieuwenhuizen
2008-03-26 18:55                               ` Dave Korn
2008-03-27 11:10                                 ` Jan Nieuwenhuizen
2008-03-27 13:04                                   ` Dave Korn
2008-03-27 14:25                                     ` Jan Nieuwenhuizen
2008-05-29  8:44 ` Jan Nieuwenhuizen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47E538D0.D8BC29A4@dessent.net \
    --to=brian@dessent.net \
    --cc=cygwin-apps@cygwin.com \
    --cc=dave.korn@artimi.com \
    --cc=hanwen@xs4all.nl \
    --cc=janneke-list@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).