Raised This Month: $ Target: $400
 0% 

[Solved]Help me solve segfault


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 07-02-2014 , 12:17   [Solved]Help me solve segfault
Reply With Quote #1

Quote:
This bit of code is causing a segfault after the FF2_Logger call with this msg: Test 6
PHP Code:
cell_t AddArg(IPluginContext *pContextHandle_t argHvoid** defaultValueFF2_ArgType aType, const chardesc)
{
    
FF2_Logger("Test 1");
    
IBasicTrie *args GetTrie(argH);
    
FF2_Logger("Test 2");
    
Handle_t keyNamesH;
    
FF2_Logger("Test 3");
    
KeyNamesArray *keyNames;
    
FF2_Logger("Test 4");
    if (!
args->Retrieve("keyNames", (void**)keyNamesH))
        return 
pContext->ThrowNativeError("Unable to get keyNames array!");
    
FF2_Logger("Test 5");
    
keyNames GetKeyNamesArray(keyNamesH);
    
FF2_Logger("Test 6");
    
int arraySize keyNames->ArraySize(); //This line right here.
    
FF2_Logger("Test 7");
    
char sSize[5];
    
FF2_Logger("Test 8");
    
smutils->Format(sSizesizeof(sSize), "%d",  arraySize);
    
FF2_Logger("Test 9");
    
Handle_t arg InsertNewChildTrie(argssSize);
    
FF2_Logger("Test 10");
    if (
arg == BAD_HANDLE)
    {
        return 
pContext->ThrowNativeError("Unable to insert arg%s"sSize);
    }
    
FF2_Logger("Test 11");
    
IBasicTrie *argTrie GetTrie(arg);
    
FF2_Logger("Test 12");
    if (!
argTrie->Insert("defaultValue"defaultValue))
        return 
pContext->ThrowNativeError("Unable to add default value.");
    
FF2_Logger("Test 13");
    if (!
argTrie->Insert("type", (void**)aType))
        return 
pContext->ThrowNativeError("Unable to add argType");
    
FF2_Logger("Test 14");
    if (!
argTrie->Insert("desc", (void**)(char*)desc))
        return 
pContext->ThrowNativeError("Unable to add desc of: %s"desc);
    
FF2_Logger("Test 15");
    return 
1;

if you need full code, go here: https://github.com/WildCard65/FF2-Al.../ff2controller
Edit: Note: These files are used at the call that causes fault:
keynamesarray.h //Custom and simple class to bridge CUtlVector with a pointer.
utlvector.h //A valve header.
Edit2: More info: It crashes upon when Count is at 0, but it shouldn't.
Edit3: Below is part of edit2, but I left it out because it's important. Now, somehow the handle recieved apparently causes an error so it returns NULL, need to find out.
Ok, now that I see it, it is indeed attempting to call null, idk why, but it does.
Edit4: Found full issue, in the call to Retrieve of IBasicTrie, I forgot 1 little "&" symbol.

Last edited by WildCard65; 07-02-2014 at 14:46.
WildCard65 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:48.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode