Please check out Aarchon !

Member Discussions

terms



[Previous] [Next] [Post] [Reply] [Topics] [Summary] [Search]


1. Thread problem Sun May 26, 2002 [12:28 PM]
Gimballon
Email not supplied
member since: Apr 2, 2003
Reply
Ok, this one has me stumped. I have done DNS via threading with Jobo's threading snipet, this is for a mud which is FAR removed from Godwars but was still close enough for me to be able to get the threading in with a little work, however now we have a crash that I just can't find.

Here is the GDB session for it, including the BT:
[New Thread 7176 (LWP 20029)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 7176 (LWP 20029)]
0x400e41a7 in malloc () from /lib/libc.so.6
(gdb) bt
#0 0x400e41a7 in malloc () from /lib/libc.so.6
#1 0x400e3f98 in malloc () from /lib/libc.so.6
#2 0x400d59be in fopen () from /lib/libc.so.6
#3 0x40bf0735 in _nss_files_endservent () from /lib/libnss_files.so.2
#4 0x40bf1870 in _nss_files_gethostbyaddr_r () from /lib/libnss_files.so.2
#5 0x40164b99 in gethostbyaddr_r () from /lib/libc.so.6
#6 0x080e963a in lookup_address (darg=0x40c17248) at comm.c:4827
#7 0x40053e24 in pthread_start_thread_event (arg=0xbebffc00) at manager.c:274

The line of code in question is:
gethostbyaddr_r( darg->buf, sizeof(darg->buf), AF_INET, &ent, buf, 16384, &from, &err);

But, more interesting things, it crashes occasionaly in other places where an fopen is called in the code.

My only thought is that I need to do a pthread_mutex_lock and pthread_mutex_unlock before and after all instances where an fopen would be called, but I'm not sure if that's the solution. Any help on this?


2. RE: Thread problem Thu Jun 20, 2002 [5:37 PM]
Echion
Email not supplied
member since: Mar 1, 2000
In Reply To
Reply
Using mutexes could very well solve this problem (if it is caused by the threads).
Do a pthread_mutex_lock before each fopen() and don't unlock it until after the fclose().

Good luck




[Previous] [Next] [Post] [Reply] [Topics] [Summary] [Search]