Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Results 1 to 4 of 4
  1. #1
    Join Date
    September 2015
    Posts
    2

    onUpdateClientEvent crashes Client

    Hello,

    I am developing a plugin in C++ using the Teamspeak PluginSDK. I want to use the onUpdateClientEvent to react to a user changing its username and it works just fine but when I kick a client (whether with the SDK or manually using the GUI) my client crashes with this error in log:
    Code:
    2015-09-01 15:50:00.104221|CRITICAL|              |   |Assertion "item->getChildCount() == 0" failed at c:\jenkins\workspace\clientwindows_gyp\src\ui_qt\treemodel.cpp:580;
    I am using the following code for testing:
    Code:
    void logmsg(string msg) {
        ts3Functions.logMessage(msg.c_str(), LogLevel_DEBUG, "TestPlugin", 0);
    }
    
    void ts3plugin_onUpdateClientEvent(UINT64 scHandlerID, anyID clientID, anyID invokerID, const char *invokerName, const char *invokerUniqueIdentifier) {
        logmsg("updateClient" + to_string(scHandlerID) + ";" + to_string(clientID) + ";" + to_string(invokerID));
        anyID* selfID;
        ts3Functions.getClientID(scHandlerID, selfID);
        logmsg("selfID=" + to_string(*selfID) + ";clientID=" + to_string(clientID) + ";invokerID=" + to_string(invokerID));
    }
    The weird thing is that its not even printing the first log message even though its called before the getClientID but the crash is definitly caused by the getClientID call because when removing the getClientID call it does not crash.


    I hope somebody can help me
    Thanks in advance

    Schuwi

  2. #2
    Join Date
    October 2012
    Location
    Germany
    Posts
    553
    Let's see if that changes anything.
    Code:
    unsigned int error;
    anyID selfID;
    if((error = ts3Functions.getClientID(scHandlerID,&selfID)) != ERROR_ok)
    { logmsg("nay"); } else {
    logmsg("selfID=" + to_string(selfID) + ";clientID=" + to_string(clientID) + ";invokerID=" + to_string(invokerID)); //yay }
    I guess the client uses asynchronous Qt-based logging. We don't wanna slow down our function execution by waiting for logs to be written, do we

    Edith: However from the error message and the kick requirement I'd have bet the clientID to cause havoc. After all, we're for some reason handling an event for a client that may or may not exist at all anymore (channel/server kick?). But given that you just print it, I dunno.
    Last edited by Philosound; September 1st, 2015 at 11:27 PM.

  3. #3
    Join Date
    September 2012
    Posts
    6,079
    You're asking the client to write data to an uninitialized variable, this variable being a pointer for which no memory has been allocated. You either have to allocate (and de-allocate) it explicitly
    Code:
    anyID *selfID = (anyID*) malloc(sizeof(anyID));
    ts3Functions.getClientID(scHandlerID, selfID);
    // use selfID
    free(selfID);
    or use local variables and provide the function call with a pointer to that variable like Philosound does in his answer.
    Code:
    anyID selfID;
    ts3Functions.getClientID(scHandlerID, &selfID);
    With your code you may end up overwriting some random memory to which you have access to and that isn't needed anymore (no crash) or you overwrite stuff that's still needed or even some memory you don't have access to (crash in both cases).
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  4. #4
    Join Date
    September 2015
    Posts
    2
    Ok I see... I'm very new to C and was only into Java before.
    I already worked around the issue with using onClientDisplayNameChanged(saw that a bit late...) but I fixed that with the pointer, looks like I was lucky not overwriting something when using onClientDisplayNameChanged.
    Thank you very much for your help

    Schuwi

    P.S.: Is there any function to schedule a repetitive task or should I just do it in a thread?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Confusing behavior - onUpdateClientEvent
    By Greyze in forum General Questions
    Replies: 3
    Last Post: July 1st, 2014, 11:24 AM
  2. [Resolved] Client crashes!
    By Heikki in forum Client Support
    Replies: 2
    Last Post: May 15th, 2014, 08:28 AM
  3. Client Crashes
    By Jakeofwar in forum Windows
    Replies: 3
    Last Post: July 16th, 2013, 04:55 PM
  4. Client crash - Starting up voice activation test crashes client
    By GeneralCookie in forum Client Support
    Replies: 1
    Last Post: April 30th, 2013, 01:45 PM
  5. Client Constantly Crashes
    By Cloakedfury in forum Windows
    Replies: 0
    Last Post: June 1st, 2011, 10:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •