raven-ie / cleancodequake2

Automatically exported from code.google.com/p/cleancodequake2
0 stars 0 forks source link

SIntermissionState::~Changemap() segfaulting #18

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Compile on linux x86_64
2. Start a server with the dll
3. Killserver, quit, Control+C

What is the expected output? What do you see instead?
No segfault, I find actually a segfault caused by the destructor 
SIntermissionState::~ChangeMap()

r462, on Gentoo Linux x86_64 (gcc version 4.3.4) 

Additional information:
I managed to fix it by changing some stuff.
SImtermissionState::ChangeMap to char*
in cc_target_entities,  
if (Level.Intermission.ChangeMap.find_first_of("*") != std::string::npos) //...
to 
if (strstr(Level.Intermission.ChangeMap, "*")) //...

and adding the function at the top of cc_target_entities.cpp
char* mydup(const char* const str)
{
    char* retval = QNew (TAG_GAME) char[strlen(str)];
    strcpy(retval, str);
    return retval;
}

and changing

Level.Intermission.ChangeMap = targ->Map;

to

Level.Intermission.ChangeMap = mydup(targ->Map.c_str());

I also think that ChangeMap.clear() at ExitLevel() might be causing the 
problem, but I don't know why, so I did those changes.

Original issue reported on code.google.com by forsaken...@gmail.com on 17 Jul 2010 at 7:48

GoogleCodeExporter commented 8 years ago
Okay, just a slight mistake, ExitLevel might be completely unrelated.

Original comment by forsaken...@gmail.com on 17 Jul 2010 at 7:53

GoogleCodeExporter commented 8 years ago
Well, I wanted to change most strings in the game to std::string, since it's a 
much easier class to manipulate and avoids using pointers which generally cause 
more problems in the long run.

Also the memory system already has a strdup function (Mem_PoolStrDup).

Trying to make it work with std::string would be a better idea; I'll look into 
it and see if it causes problems on Windows as well.

Original comment by Jonno.5000 on 26 Jul 2010 at 12:09

GoogleCodeExporter commented 8 years ago
I think it's a glibc++ issue, not a cleancode issue, the code seems perfect to 
me as well.

Thanks!

Also, I discovered something else. Entity related, a cast that is not working. 
I'll open an issue later.

Original comment by forsaken...@gmail.com on 26 Jul 2010 at 11:13