Forum

Page 3 of 5 FirstFirst 12345 LastLast
Results 31 to 45 of 72
  1. #31
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    144
    So back to it...
    Does anyone have an idea what to do with this message
    Code:
    [GER] System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. bei tsapi.assembleGrammar() 
    [ENG] System.NullReferebceException: The Objectreference was not set to the Objectinstance, occured in tsapi.assembleGrammar()
    on this loop

    Code:
    if (resChL == ERROR_ok) {
    	for (int i = 0; sizeof(*channelListPtr) / sizeof(uint64); i++) {
    	char* resultChannelVar;
    	ts3Functions.getChannelVariableAsString(schid, channelListPtr[i], CHANNEL_NAME, &resultChannelVar);
    	String^ resChVarStr = Char::ToString(*resultChannelVar);
    	array<String^>^ resChVarStrArr = resChVarStr->Split(' ');
            /* Exception happens here */
    	for each (String^ a in resChVarStrArr) {
    		channel->Add(a);
    	}
            /* Exception ends here */
    	ts3Functions.freeMemory(resultChannelVar);
    }
    Like, I don't quite understand that error message...
    Any idea?

  2. #32
    Join Date
    February 2017
    Posts
    45
    1) check your } count. In this code above is a } missing. If that is in your real code, too, you got the problem.
    2) your for loop never determine:

    for(int i = 0; sizeof(*channelListPtr) / sizeof(uint64); i++)
    Your condition is an double value > 0, so always true. If you wanna go over the whole channelListPtr array there is a good hint in the example code. Those arrays are NULL terminated. That means the last entry is NULL

    So just use this:
    int i = 0;
    while(channelListPtr[i++] != NULL)
    {
    ...
    }

  3. #33
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    144
    That might very well help, thanks!
    And I didn't C&P my code in here, I just re-typed it. I just missed the }, VS would have told me that it was missing...

  4. #34
    Join Date
    February 2017
    Posts
    45
    ok i thought so

    btw the best way to get help is to share your code in a repository (if you are doing your project open source)
    Because sometimes it is good to know the context to understand the code. And maybe the problem is caused somewhere else.

    Further more you have a backup of your code, you can use different development branches and if something does not work, you simply switch back to an older stable state

  5. #35
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    144
    Good idea, I might try it.

    Well,it didn't quite fix it... Nice idea, but the error is in the
    Code:
    for each (String^ a in resChVarStrArr) {
    	channel->Add(a);
    }
    part.

    Code:
    [GER] System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. bei tsapi.assembleGrammar() 
    [ENG] System.NullReferenceException: The Objectreference was not set to the Objectinstance, occured in tsapi.assembleGrammar()
    is the message.

  6. #36
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    144
    Alright. Appearently the Problem is the
    clients->Add(a)
    channel->Add(a)
    part. This appearently does crash the client. Exactly that line.

    The declaration of those 2 lists is:

    Code:
    List<String^>^ clients = {};
    List<String^>^ channel = {};
    dmp file says:

    The thread has tried to write or read from a virtual address that it does not have permission for.

  7. #37
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    I don't know what your .Net things (to be exactly Char::ToString) are doing, but the memory pointed to in resultChannelVar is owned by the client.

    The thread has tried to write or read from a virtual address that it does not have permission for.
    It sounds like some functions are just using the pointer internally instead of copying the content.

    Furthermore you are not checking the return of getChannelVariableAsString. So resultChannelVar might be a NULL pointer.

  8. #38
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    144
    Code:
    while (channelListPtr[i++] != NULL) {
        char* resultChannelVar;
        int errChVar = ts3Functions.getChannelVariableAsString(schid, channelListPtr[i], CHANNEL_NAME, &resultChannelVar);
        if (errChVar == ERROR_ok) {
            String^ resChVarStr = Char::ToString(*resultChannelVar);
            array<String^>^ resChVarStrArr = resChVarStr->Split(' ');
            for each (String^ a in resChVarStrArr) {
                channel->Add(a);
            }
            // Free allocated memory
            ts3Functions.freeMemory(resultChannelVar);
        }
        else {
            ts3Functions.logMessage("Failed to get Channellist!", LogLevel_ERROR, "TS3VC", schid);
        }
    Even with that error handling it still crashes. Like, it returns ERROR_ok.
    But how do I access the channel name array then, if not with *resultChannelVar?
    Like, I want to get its value, convert it to a string, and work with that then...
    Maybe with resultChannelVar and not *resultChannelVar? But that would not make sense since I am only working with a pointer then, not the actual value...

  9. #39
    Join Date
    February 2017
    Posts
    45
    i know * but what is ^ in c++?? or is it a net thing??

    btw how did you find out what line crashes the plugin?? I had always problems debugging the dll file. Most times i did some print things or system beeps to check where the program actual was while runtime

  10. #40
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    144
    GT, yes I did.

    And the ^ signalized "This element is .NET and not C++" (And I am using C++ CLI, a mixture of .NET and C++)
    It is basically like a pointer to a .NET function...

    Read up the posts, I posted it in some post where it crashes.
    Last edited by Jhhhj_original; March 12th, 2017 at 05:21 PM.

  11. #41
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    If I understand the msdn docs right, Char::ToString will convert to a single character, so basically if it would work, you'll get a string with the first character of the channelname.

    One-shot Googling(!) led me to this thread.

  12. #42
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    144
    Well yea, I looked at that aswell.
    But that does not seem to be the poblem.
    I did that, still crashing...
    It is still the same error message in the Crashdump file though.

    The problem is:
    If I interpret that error message right, I do not have the permissions to read from the variable resultChannelVar.
    But how does that variable (and that function) help me at all? And the narrowing-down of the error shows me that it lies somewhere in the
    Code:
    for each (String^ a in resChVarStrArr) {
        channel->Add(a) // It crashes RIGHT HERE
    }

  13. #43
    Join Date
    September 2012
    Posts
    6,079
    Quote Originally Posted by Jhhhj_original View Post
    Code:
    if (resChL == ERROR_ok) {
    	for (int i = 0; sizeof(*channelListPtr) / sizeof(uint64); i++) {
    	char* resultChannelVar;
    	ts3Functions.getChannelVariableAsString(schid, channelListPtr[i], CHANNEL_NAME, &resultChannelVar);
    	String^ resChVarStr = Char::ToString(*resultChannelVar);
    	array<String^>^ resChVarStrArr = resChVarStr->Split(' ');
    	for each (String^ a in resChVarStrArr) {
    		channel->Add(a);
    	}
    	ts3Functions.freeMemory(resultChannelVar);
    }
    Maybe I'm missing something here, but you're dereferencing a pointer to memory that is being deleted (or at least should be), so you may end up holding a reference to stuff that doesn't exist anymore.

    When you use Char::ToString the way I see it you'd also only get the very first character. Why not just do
    Code:
    String^ resChVarStr = gcnew String(resultChannelVar);
    as indicated in the SO that Thomas linked? That should give you the full string.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  14. #44
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    144
    I did that. And I don't quite see where I delete the pointer...

    I only delete the resultChannelVar after I am done using it, but that shouldn't affect the variable, since it does exist when I use it...

    Or different: Where does the variable get deleted that you are talking about?
    Last edited by Jhhhj_original; March 13th, 2017 at 12:43 PM.

  15. #45
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Quote Originally Posted by Thomas View Post
    It sounds like some functions are just using the pointer internally instead of copying the content.
    If your wrapped string uses only a reference of the c string, the string is freed after calling freeMemory. So in this case, the client won't crash at the point channel->Add(a), but because of that.

    I guess you are using this container at some point later in your code. And there, the pointer is a NULL pointer. If you comment out channel->Add(a), it might not crash anymore, because the container channel has a size of 0 and iterating over it does not do anything.

    Try copying the string resultChannelVar first and add this string to your container (ofc the memory allocated has to be freed too, but it's less complex, if you can free it with delete/free and such).

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. ts3Functions.requestChannelGroupClientList
    By Bluscream in forum Suggestions and Feedback
    Replies: 1
    Last Post: October 26th, 2016, 06:44 AM
  2. Problem with ts3Functions.getClientID()
    By Dione in forum Client Plugins / Lua Scripts
    Replies: 2
    Last Post: August 30th, 2014, 11:40 AM
  3. Replies: 1
    Last Post: March 14th, 2013, 10:06 AM
  4. ts3Functions.createIdentity - where the heck is it?
    By sea212 in forum Client Plugins / Lua Scripts
    Replies: 7
    Last Post: March 1st, 2010, 07:14 PM
  5. [Solved] ts3Functions.requestClientMove
    By tomix in forum Client Plugins / Lua Scripts
    Replies: 2
    Last Post: February 22nd, 2010, 10:31 AM

Posting Permissions

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