public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/5347: implementation is not thread-safe on multi-processor machines
@ 2002-01-15 17:36 ljrittle
  0 siblings, 0 replies; 2+ messages in thread
From: ljrittle @ 2002-01-15 17:36 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, ljrittle, markus.breuer, nobody

Synopsis: implementation is not thread-safe on multi-processor machines

Responsible-Changed-From-To: unassigned->ljrittle
Responsible-Changed-By: ljrittle
Responsible-Changed-When: Tue Jan 15 17:36:08 2002
Responsible-Changed-Why:
    Mine.
State-Changed-From-To: open->closed
State-Changed-By: ljrittle
State-Changed-When: Tue Jan 15 17:36:08 2002
State-Changed-Why:
    Duplicate of libstdc++/5037 (which is closed since it is
    fixed on mainline for 3.1 and, if ever released, 3.0.4+).
    I have tested this case against a patched copy of gcc
    3.0.3 on an MP sparc and it works without crashing.
    I have attached the patch against gcc-3.0.3.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5347


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

* libstdc++/5347: implementation is not thread-safe on multi-processor machines
@ 2002-01-10  4:56 markus.breuer
  0 siblings, 0 replies; 2+ messages in thread
From: markus.breuer @ 2002-01-10  4:56 UTC (permalink / raw)
  To: gcc-gnats; +Cc: markus.breuer


>Number:         5347
>Category:       libstdc++
>Synopsis:       implementation is not thread-safe on multi-processor machines
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 10 04:56:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     markus.breuer@materna.de
>Release:        up to current release
>Organization:
>Environment:
sun solaris 2.7/2.8 (multi-processor machine)
gcc 2.95.3 up to 3.0.x
>Description:
The libstdc++ implementation is not really thread-safe. 
Currently we allocate ostrstreams/ostrstreams with new and free them
immediatelly with delete. There's no access the the objects (except
new and delete), but the application sometimes crashes.

The main problem are static variables within streambuf (and perhaps other classes).
When instantiating an derived object (e.g. filestreambuf), this variables 
are accessed. On a single processor machine these accesses may be atomic (
depending on hardware), but an a real multi-processor environment they are not atomic.
When running our application on a single processor machine, there are no further 
problems, but on multi-processor there are unavoidable system crashes (core dumps).
>How-To-Repeat:
Compile and run the attached program on a (sun!?) multi-processor machine
>Fix:
To fix the problem the access to any global variable must be synchronized. Search
the libstdc++ for any static variable (streambuf/basic_string/etc) and use atomicity
to synchronize any access to it. Any access, read and write, must be synchronized.
The basic_string class uses atmicity to synchronize access to nulRep and Rep. But 
only the write access is synchronized. In a multi-processor environment the write access
of, for example an pointer, is not atomic. So its read-access must be guarded by
atomicity.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="HMSTestApp.cpp"; name="HMSTestApp.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="HMSTestApp.cpp"

Ly8gY21kOiBnKysgSE1TVGVzdEFwcC5jcHAgLWcgLXB0aHJlYWRzCgojaW5jbHVkZSA8c3RyaW5n
PgojaW5jbHVkZSA8ZnN0cmVhbT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3Ryc3Ry
ZWFtPgojaW5jbHVkZSA8dW5pc3RkLmg+CgojaW5jbHVkZSA8cHRocmVhZC5oPgojaW5jbHVkZSA8
dGhyZWFkLmg+Cgpjb25zdCBpbnQgbWF4X3RocmVhZF9jb3VudCA9IDE2Owp2b2xhdGlsZSBpbnQg
cnVubmluZ1RocmVhZHMgPSBtYXhfdGhyZWFkX2NvdW50OwoKcHRocmVhZF90IHRpZFsgbWF4X3Ro
cmVhZF9jb3VudCBdOwoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQqIHRocmVhZF9tYWluKCB2
b2lkICogKQp7CiAgIHN0ZDo6Y291dCA8PCAiRW50ZXJpbmcgdGhyZWFkICMiIDw8IHB0aHJlYWRf
c2VsZigpIDw8ICIuLi4iIDw8IH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ocmVhZHMgKQogICAgICBzbGVlcCgg
MSApOyAgIAogICBzdGQ6OmNvdXQgPDwgIlNodXRkb3duIC4uLiIgPDwgc3RkOjplbmRsOyAgICAg
IAogICAKICAgcmV0dXJuIDA7Cn0KCg==


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

end of thread, other threads:[~2002-01-16  1:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-15 17:36 libstdc++/5347: implementation is not thread-safe on multi-processor machines ljrittle
  -- strict thread matches above, loose matches on Subject: below --
2002-01-10  4:56 markus.breuer

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).