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 libstdc++/31368] basic_string and unsigned short leads to memory fault



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


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