* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
@ 2007-03-26 21:11 ` pcarlini at suse dot de
2007-03-26 21:28 ` gregoryk at edifecs dot com
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2007-03-26 21:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pcarlini at suse dot de 2007-03-26 22:10 -------
Seems the same as libstdc++/25956. Can you try whether instantiating the string
class at global scope works for you too:
http://gcc.gnu.org/ml/libstdc++/2006-01/msg00162.html
???
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
2007-03-26 21:11 ` [Bug libstdc++/31368] " pcarlini at suse dot de
@ 2007-03-26 21:28 ` gregoryk at edifecs dot com
2007-03-26 21:52 ` pcarlini at suse dot de
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gregoryk at edifecs dot com @ 2007-03-26 21:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from gregoryk at edifecs dot com 2007-03-26 22:28 -------
Though the problem from bug 25956 looks same the instantiating didn't help.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
2007-03-26 21:11 ` [Bug libstdc++/31368] " pcarlini at suse dot de
2007-03-26 21:28 ` gregoryk at edifecs dot com
@ 2007-03-26 21:52 ` pcarlini at suse dot de
2007-03-26 22:14 ` gregoryk at edifecs dot com
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2007-03-26 21:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pcarlini at suse dot de 2007-03-26 22:52 -------
Ok, but before we take any further action we badly need a better reproduce: on
any up to date x86 and x86-64 linux machine I tried, your testcase segfault
immediately both for unsigned short and for char (and the workaround doesn't
work)
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (2 preceding siblings ...)
2007-03-26 21:52 ` pcarlini at suse dot de
@ 2007-03-26 22:14 ` gregoryk at edifecs dot com
2007-03-26 22:25 ` pcarlini at suse dot de
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gregoryk at edifecs dot com @ 2007-03-26 22:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from gregoryk at edifecs dot com 2007-03-26 23:13 -------
Ok. Can I help you somehow?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (3 preceding siblings ...)
2007-03-26 22:14 ` gregoryk at edifecs dot com
@ 2007-03-26 22:25 ` pcarlini at suse dot de
2007-03-27 17:07 ` pcarlini at suse dot de
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2007-03-26 22:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pcarlini at suse dot de 2007-03-26 23:24 -------
Yes, as I said, we need a better reproducer, that is a testcase that on most of
the current x86-linux or x86-64-linux machines behaves as you are reporting: if
you want to help you should look for a recent machine (e.g., glibc2.4 / 2.5,
system compiler gcc 4.1.x) and refine your testcase to behave as you expect.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (4 preceding siblings ...)
2007-03-26 22:25 ` pcarlini at suse dot de
@ 2007-03-27 17:07 ` pcarlini at suse dot de
2007-03-27 17:20 ` gregoryk at edifecs dot com
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2007-03-27 17:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pcarlini at suse dot de 2007-03-27 18:07 -------
To restate my point: if, with a recent compiler, I change the testcase to use
<ext/vstring.h>, which has completely different memory management, instead of
<string>, even for plain char I get an immediate Segmentation Fault without any
debugging information available. Thus, I strongly suspect the testcase is
somehow broken and must be fixed first: I can do that eventually, but feedback
from the original submitter is strongly encouraged, of course.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (5 preceding siblings ...)
2007-03-27 17:07 ` pcarlini at suse dot de
@ 2007-03-27 17:20 ` gregoryk at edifecs dot com
2007-03-27 17:24 ` pcarlini at suse dot de
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gregoryk at edifecs dot com @ 2007-03-27 17:20 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 396 bytes --]
------- Comment #7 from gregoryk at edifecs dot com 2007-03-27 18:20 -------
Unfortunately I do not have possibility to run my test case using latest GCC
compiler. Im limited in hardware and software choice. Besides Im not sure
what do you mean to fix testcase. If you could fix it then it will be
accepted in any way by me.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (6 preceding siblings ...)
2007-03-27 17:20 ` gregoryk at edifecs dot com
@ 2007-03-27 17:24 ` pcarlini at suse dot de
2007-03-27 17:37 ` pcarlini at suse dot de
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2007-03-27 17:24 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 824 bytes --]
------- Comment #8 from pcarlini at suse dot de 2007-03-27 18:24 -------
(In reply to comment #7)
> Unfortunately I do not have possibility to run my test case using latest GCC
> compiler. Im limited in hardware and software choice. Besides Im not sure
> what do you mean to fix testcase.
As I said, the testcase Segfaults badly on any recent machine, for <string> but
also for <ext/vstring.h> and also for plain char. This is unfortunate, this is
not the behavior you expected when you submitted the PR, and if we cannot
reproduce the issue that you are maintaining to see we cannot understand it and
we cannot take any further action. Can you please double check you are building
the so, dlopening, etc, in your testcase in the correct, portable way?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (7 preceding siblings ...)
2007-03-27 17:24 ` pcarlini at suse dot de
@ 2007-03-27 17:37 ` pcarlini at suse dot de
2007-03-27 17:39 ` gregoryk at edifecs dot com
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2007-03-27 17:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pcarlini at suse dot de 2007-03-27 18:36 -------
I get an immediate Segmentation fault even if I change read_string to do
nothing..
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (8 preceding siblings ...)
2007-03-27 17:37 ` pcarlini at suse dot de
@ 2007-03-27 17:39 ` gregoryk at edifecs dot com
2007-03-27 17:40 ` gregoryk at edifecs dot com
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gregoryk at edifecs dot com @ 2007-03-27 17:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from gregoryk at edifecs dot com 2007-03-27 18:39 -------
Got it, thanks. In may original test I was relaying on LD_LIBRARY_PATH to have
current folder in the values. And there was no checking of dlopen result for
simplicity. Here is updated code. It will search for libloader.so in current
folder.
#include <dlfcn.h>
#include <string>
#include "loader.h"
typedef void *pfLoader(std::ustring&);
int main(int argc, char* argv[])
{
void * libHandle = dlopen("./libloader.so", RTLD_NOW|RTLD_GLOBAL);
if (0 == libHandle)
{
printf("Can not load \"./libloader.so\".\n");
return 1;
}
pfLoader* pF = (pfLoader*)dlsym(libHandle, "read_string");
if (0 == pF)
{
printf("Can not find function \"read_string\" in
libloader.so\n");
return 2;
}
std::ustring s;
// s.reserve(1); // uncomment this line to prevent abort
pF(s);
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (9 preceding siblings ...)
2007-03-27 17:39 ` gregoryk at edifecs dot com
@ 2007-03-27 17:40 ` gregoryk at edifecs dot com
2007-03-27 18:22 ` pcarlini at suse dot de
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gregoryk at edifecs dot com @ 2007-03-27 17:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from gregoryk at edifecs dot com 2007-03-27 18:40 -------
Forgot to mention, that was main.cpp code.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (10 preceding siblings ...)
2007-03-27 17:40 ` gregoryk at edifecs dot com
@ 2007-03-27 18:22 ` pcarlini at suse dot de
2007-03-27 18:25 ` pcarlini at suse dot de
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2007-03-27 18:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from pcarlini at suse dot de 2007-03-27 19:22 -------
Ok, now I see. The kind of issue is unfortunately known, akin to 24196 for
example, and ultimately due to the special, optimized way we are dealing with
empty strings, not allocating dynamic memory at all. I don't think we can
really solve the problem without breaking the binary compatibility of the
entire library, therefore we suggest various options:
1- Make sure to never deal with empty strings (which means a string not holding
a memory buffer, that's why reserve(1) works, for example)
2- Rebuild the library passing --enable-fully-dynamic-string, the option has
been added exactly to help users in this case.
3- Switch to a different implementation of the string class: in recent releases
we are offering one under <ext/vstring.h> (will become standard when we decide
to break binary compatibility)
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pcarlini at suse dot de
|dot org |
Status|WAITING |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-03-27 19:22:05
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (11 preceding siblings ...)
2007-03-27 18:22 ` pcarlini at suse dot de
@ 2007-03-27 18:25 ` pcarlini at suse dot de
2007-03-27 18:25 ` pcarlini at suse dot de
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2007-03-27 18:25 UTC (permalink / raw)
To: gcc-bugs
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|pcarlini at suse dot de |unassigned at gcc dot gnu
| |dot org
Status|ASSIGNED |NEW
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (12 preceding siblings ...)
2007-03-27 18:25 ` pcarlini at suse dot de
@ 2007-03-27 18:25 ` pcarlini at suse dot de
2007-03-27 18:51 ` gregoryk at edifecs dot com
2007-03-27 18:53 ` pcarlini at suse dot de
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2007-03-27 18:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from pcarlini at suse dot de 2007-03-27 19:25 -------
By the way, as a matter of portability, isn't a good idea to use the string
class with anything != char and wchar_t: things usually work in rather recent
releases of GCC only because we are delivering a "generic" implementation of
char_traits, which cannot be assumed, in general (and that's why probably your
specific issue with empty strings has not been reported earlier).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (13 preceding siblings ...)
2007-03-27 18:25 ` pcarlini at suse dot de
@ 2007-03-27 18:51 ` gregoryk at edifecs dot com
2007-03-27 18:53 ` pcarlini at suse dot de
15 siblings, 0 replies; 17+ messages in thread
From: gregoryk at edifecs dot com @ 2007-03-27 18:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from gregoryk at edifecs dot com 2007-03-27 19:51 -------
Thank you for info. The sample is working now with
_GLIBCXX_FULLY_DYNAMIC_STRING turned on. What is the next procedure with bug
status? For me bug can be marked as FIXED.
Regarding portability. We use unsigned short strings on more then 6 platforms
and would like to continue this way. We use custom implementation of
char_traits<unsigned short> where it is not available. And looking on migration
on Xerces STL as a common solution for all platforms (yes, it is not easy but
worth to try).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
2007-03-26 20:51 [Bug libstdc++/31368] New: basic_string and unsigned short leads to memory fault gregoryk at edifecs dot com
` (14 preceding siblings ...)
2007-03-27 18:51 ` gregoryk at edifecs dot com
@ 2007-03-27 18:53 ` pcarlini at suse dot de
15 siblings, 0 replies; 17+ messages in thread
From: pcarlini at suse dot de @ 2007-03-27 18:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #15 from pcarlini at suse dot de 2007-03-27 19:53 -------
Ok, I will mark it as suspended, because when we break the binary compatibility
things will always work fine.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |SUSPENDED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
^ permalink raw reply [flat|nested] 17+ messages in thread