This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/31314] New: Segmentation fault when assign std::string to another std::string when using std::vector and inheritance


Short version:
Assigning an index from a vector<string> to a local string works. Assigning to
a private class member of type string fails with a segmentation fault
apparently caused by a delete[].

I've managed to simplify the test case quite substantially for this bug, but
its still quite convoluted. For this I apologize.


Long version:

Here's a summary of the example: its supposed to be a framework for
implementing model-view-controller type applications in C++. The code is a
foundation for a GTKmm application. We have the Database:: interface which is
implemented by Sqlite::. Each model inherits from the Model:: base class which
is modeled very loosely on the ActiveRecord system in Ruby-on-Rails. The User::
class is a model.

Queries on the database are run through Database::exec() which really is
Sqlite::exec(). The findall() function called in main() is purportedly part of
User:: but actually implemented in Model::.



Now, for the bug.

The example causes a SIGSEGV in User::findall() (ie. Model::findall()). But the
shocker is where it happens: line 130 in the example. We've run Sqlite::exec(),
and gotten a vector of strings. We can also loop over the vector and print each
string.

I have no idea why this bug occurs in this specific code. The only thing
remotely unusual is the inheritance pattern (ie. class User: public Model<User>
{} ), but that's not particularly bizarre either.


-- 
           Summary: Segmentation fault when assign std::string to another
                    std::string when using std::vector and inheritance
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wmacura at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31314


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]