[split] dll issues



  • Hi

    I have created a dll in win32 in which i have also linked Qt libraries so that I can use both QT & win32 datatypes in this dll.
    I have created one more QT Application in which I am loading this dll dynamically using QLibrary::load().
    After loading I am calling one function in for loop form this dll which takes QStirng as parameter for 1st 10 times the QString value which I am sending from QT app to that dll is recieved correctly in that dll function but exactly from 11th time the QString value sent from QT appp to dll function is showing garbage value?

    How to resolve this?



  • Hi

    The error message which i recieve says something like this

    A buffer overrun has occurred in TEMP.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.

    For more details please see Help topic 'How to debug Buffer Overrun Issues'.



  • Hi Lukas

    I am facing one more problem can you help me to resolve this

    Step 1: I have created a win32 dll with name Temp.dll in which i have linked QT libraries & also added required include files so that i can also use QT datatypes in that dll.
    In Temp.dll has one function with following prototype & definition
    @
    QString Data(QString data)
    {
    return data;
    }
    @

    Step 2: Now I have created one Sample QT Appplication code for same is given below but when I am trying to call the above function in this application in for loop
    after 2-3 iterations of for loop it is crashing & giving following error message

    A buffer overrun has occurred in LoadLibrary.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.

    For more details please see Help topic 'How to debug Buffer Overrun Issues'.

    @Sample App Code:

    #include <QLibrary>
    #include <QString>
    #include <qdebug.h>

    //Function Pointers
    typedef QString (*Data)(QString);

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
    bool bLoaded = false;
    //Load win32 Export Library
    QLibrary lib("Temp.dll");
    bLoaded = lib.load();
    Data data= (Data) lib.resolve("Data");
    if(bLoaded)
    {
    for(int i = 0;i<100; i++)
    {
    QString strName = "Test";
    if(lib.isLoaded())
    QString strTagInfo = data(strName);
    }
    }
    else
    {
    QString str = "Failed to load Temp library";
    }
    bool bUnLoad = lib.unload();

        return a.exec&#40;&#41;; 
    

    } @


  • Moderators

    I just split this out of another thread to make the issue more visible. Hope this helps getting it resolved fast.


  • Moderators

    I would guess that your buffer overrun corrupts the string you pass. Fix the overrun and your problem should go away.





  • How to fix over run.


  • Moderators

    Check http://en.wikipedia.org/wiki/Buffer_overflow for more information on what is going wrong.



  • If I read the code, it is buggy:

    @
    Sample App Code:

    #include <QLibrary>
    #include <QString>
    #include <qdebug.h>
     
    //Function Pointers
    typedef QString (*Data)(QString);
     
    int main(int argc, char *argv[])
    {
            // ...
            Data  data= (Data) lib.resolve("Data");
            if(bLoaded)
            {
                // ....
                  QString strTagInfo = Data(strName);
                  // here you use the type, not the pointer?
            }
            // ...
            return a.exec&#40;&#41;;
    }
    

    @

    I would recommend to rename the pointer data to something like dataFkt or similar, so such things are seen earlier...



  • Hi Gerolf

    I didnt exactly get what you want me to do can you please explain clearly.



  • Hi Gerolf

    That was the typing mistake in actual I was using data() only. But still same problem.



  • Can anyone please help me to resolve this.



  • Well, you might provide a small, compilable example that reproduces your problem, which can be downloaded somewhere.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.