Discussion:
HELP OpenServer socket + threads
(too old to reply)
Gabriel Biberian
2004-05-26 10:26:40 UTC
Permalink
Hello,

I recently had to compile a C++ program on SCO OpenServer (5.0.7). The
software runs fine on linux, bsd, osx, aix, solaris, but OpenServer
seems to cause troubles.

I installed the gnutools from ftp.sco.com and as i need Posix Threads, i
also installed FSU-Threads v3.9 from SKUNKWARE.

There are many read/write/select calls on sockets and the program always
randomly segfaults and dumps core.

gdb backtrace:
Program terminated with signal 11, Segmentation fault.
#0 0x080e92f4 in kill ()
(gdb) bt
#0 0x080e92f4 in kill ()
#1 0x08093038 in default_action ()
#2 0x08093256 in handle_thread_signal ()
#3 0x080938ed in handle_one_signal ()
#4 0x08093acf in pthread_handle_one_process_signal ()
#5 0x0809f080 in pthread_signal_sched ()
#6 0x0809e852 in pthread_sched_wrapper ()
#7 0x08093de0 in sighandler ()
#8 0x08099ea1 in pthread_sigaction ()
#9 0x080e6810 in malloc ()
#10 0x080d6018 in __builtin_new ()

another backtrace:
Program terminated with signal 11, Segmentation fault.
#0 0x080e9348 in kill ()
(gdb) bt
#0 0x080e9348 in kill ()
#1 0x08093034 in default_action ()
#2 0x08093252 in handle_thread_signal ()
#3 0x080938e9 in handle_one_signal ()
#4 0x08093acb in pthread_handle_one_process_signal ()
#5 0x0809f07c in pthread_signal_sched ()
#6 0x0809e84e in pthread_sched_wrapper ()
#7 0x08093ddc in sighandler ()
#8 0x08099e9d in pthread_sigaction ()
#9 0x080e7434 in _real_free ()
#10 0x080e73e2 in free ()
#11 0x080d5faf in __builtin_delete ()

Apparently there seems to be a problem in memory alloc/free...

Here is how i link the program
g++ -L/usr/local/lib -lmalloc -lgthreads -lsocket -lgthreads

I read something in the MySQl documentation that to get pthreads to run
well with sockets, you must link with gnu malloc, but i don't think i
understand how to do that. I tried:
g++ -L/usr/local/lib -L/usr/local/lib/libmalloc.a -lgthreads -lsocket
-lgthreads
but it doesn't help at all.
I also tried installing a more recent version of FSU-threads (3.14), but
the problem persists.

Anyone out there encounter this problem???
Is there a solution?

Another problem:
I encountered a weirdness in the select call on OpenServer: select
(according to the man page) is supposed to return the #of file
descriptors that respond, -1 in case of error and 0 if there were no
descriptors ready after timeval. Yet select sometimes returns 0
immediately without having waited timeval. Is this normal??? My
solution is to call select again if it has returned 0 without waiting
timeval, but that's an ugly hack.

Thanks in advance,

Gabriel Biberian
Beemo Technologie
Bela Lubkin
2004-05-26 10:55:40 UTC
Permalink
Post by Gabriel Biberian
Hello,
I recently had to compile a C++ program on SCO OpenServer (5.0.7). The
software runs fine on linux, bsd, osx, aix, solaris, but OpenServer
seems to cause troubles.
I installed the gnutools from ftp.sco.com and as i need Posix Threads, i
also installed FSU-Threads v3.9 from SKUNKWARE.
There are many read/write/select calls on sockets and the program always
randomly segfaults and dumps core.
Program terminated with signal 11, Segmentation fault.
#0 0x080e92f4 in kill ()
(gdb) bt
#0 0x080e92f4 in kill ()
#1 0x08093038 in default_action ()
#2 0x08093256 in handle_thread_signal ()
#3 0x080938ed in handle_one_signal ()
#4 0x08093acf in pthread_handle_one_process_signal ()
#5 0x0809f080 in pthread_signal_sched ()
#6 0x0809e852 in pthread_sched_wrapper ()
#7 0x08093de0 in sighandler ()
#8 0x08099ea1 in pthread_sigaction ()
#9 0x080e6810 in malloc ()
#10 0x080d6018 in __builtin_new ()
Program terminated with signal 11, Segmentation fault.
#0 0x080e9348 in kill ()
(gdb) bt
#0 0x080e9348 in kill ()
#1 0x08093034 in default_action ()
#2 0x08093252 in handle_thread_signal ()
#3 0x080938e9 in handle_one_signal ()
#4 0x08093acb in pthread_handle_one_process_signal ()
#5 0x0809f07c in pthread_signal_sched ()
#6 0x0809e84e in pthread_sched_wrapper ()
#7 0x08093ddc in sighandler ()
#8 0x08099e9d in pthread_sigaction ()
#9 0x080e7434 in _real_free ()
#10 0x080e73e2 in free ()
#11 0x080d5faf in __builtin_delete ()
Apparently there seems to be a problem in memory alloc/free...
Here is how i link the program
g++ -L/usr/local/lib -lmalloc -lgthreads -lsocket -lgthreads
I read something in the MySQl documentation that to get pthreads to run
well with sockets, you must link with gnu malloc, but i don't think i
g++ -L/usr/local/lib -L/usr/local/lib/libmalloc.a -lgthreads -lsocket
-lgthreads
but it doesn't help at all.
I also tried installing a more recent version of FSU-threads (3.14), but
the problem persists.
Anyone out there encounter this problem???
Is there a solution?
The stack traces show SIGSEGV in malloc() and free(). This suggests
that something is trashing the malloc arena. This is almost certainly a
bug somewhere other than the malloc implementation. Link with one of
the various debug malloc packages, it will show you where you are
double-freeing a memory chunk, accessing a chunk after having freed it,
running off the end (or beginning) of an allocated chunk, or some other
such fun.
Post by Gabriel Biberian
I encountered a weirdness in the select call on OpenServer: select
(according to the man page) is supposed to return the #of file
descriptors that respond, -1 in case of error and 0 if there were no
descriptors ready after timeval. Yet select sometimes returns 0
immediately without having waited timeval. Is this normal??? My
solution is to call select again if it has returned 0 without waiting
timeval, but that's an ugly hack.
I've never seen that and don't think it's possible in the kernel.
However, your threads library will have wrapped select() and could be
perturbing the picture. If you want to figure this one out, start by
studying the select() wrapper.
Post by Gabriel Biberian
Bela<
J. L. Schilling
2004-05-27 02:22:55 UTC
Permalink
Post by Gabriel Biberian
I recently had to compile a C++ program on SCO OpenServer (5.0.7). The
software runs fine on linux, bsd, osx, aix, solaris, but OpenServer
seems to cause troubles.
I installed the gnutools from ftp.sco.com and as i need Posix Threads, i
also installed FSU-Threads v3.9 from SKUNKWARE.
There are many read/write/select calls on sockets and the program always
randomly segfaults and dumps core. [...]
It doesn't help you at the moment, but one of the main goals of the
upcoming "Legend" release of SCO OpenServer is to provide a real system
threads library and real kernel threads, so that applications such
as MySQL and anything else that relies on threads will be much easier
to build and much faster and more reliable to execute.

Jonathan Schilling

Loading...