To all experts in GCC memory allocation, Please help me... My thesis is having problems. I have been pain-stakingly building a Civ-like Game Server Platform for online gaming. I have tried a lot of memory debuggers but after weeks of debugging, I have found out that the souce of the Segmentation fault is a return() statement. What could possibly occur in a return statement that would cause a segmentation fault? I used MALLOC_CHECK_=1 flag to try to see if it is related to malloc and it displays malloc(): top chunk corrupt realloc(): not a valid ptr 0xXXXXXX I don't know what could possibly cause an error in my return statement when the return line in a function is return(Return); nothing different with this one since i have been using Return as a return variable by convention. I have attached my Server Files with this email. Please help. Detail: The data structures in the Game Server has become quite complex for an easy explaination but if the tar file will be extracted, all files needed for the Server be there. Just in case you want to see the error for yourself... please, extract the attachment compile it with these options (At least I do). gcc -oGameServer -lm -lncurses -lpthread GameServer.c Execute GameServer and say "Y" to the prompt. and press two returns or ENTER. It will put the server online. It will listen to port 4621. The SIGSEGV will not arise until the third connection. (Why?) To establish a connection: telnet 4621 when connected: (the server will respond with a connection) type N -> must be a single tab as a delimiter -> the carriage return -> any name (max 8 chars) -> any password (max 15 chars) -> any name (max 20 chars) The letter N stands for New Player. It is included. try doing this with different usernames for 3 times. A SIGSEGV will arrise. To help you (and me) locate the source of the problem, every connection task displays the status. The last display before the SIGSEGV is four "+" plusses "++++" which is printed before the return(Return); statement. This function is located in MapQueryRoutines.c under GetSightChunk(). see print("++++"); The function call process starts with: ThreadNewConnection() in file TNewConnection.c calls CreateBase() in file PlayerRoutines.c calls NotifyTileChange in file APlayerRelations.c calls GetSightChunk in file MapQueryRoutines.c ^- where the error occurs. I don't know if the fault is with me. As I think it is. any clue? Thank you very, very much for reading up to this part. Greatest Thanks, Dan Cedric Delima Kranasian Soul X "Articulus Primus Dalestini Conquerum Hex" "Altari Motif Art Tagoni" "Soldevi solembe" _______________________________________________________ Send a cool gift with your E-Card http://www.bluemountain.com/giftcenter/