* malloc mutex and exceptions
@ 2004-03-21 21:42 Ignasi Villagrasa
2004-03-22 16:32 ` Dave Korn
0 siblings, 1 reply; 2+ messages in thread
From: Ignasi Villagrasa @ 2004-03-21 21:42 UTC (permalink / raw)
To: gcc
Hi everyone,
I have been migrating to gcc a server C/C++ based software and I' like to
control SIGSEGV signal exceptions. So I use sigaction and the corresponding
handlers to accomplish this target.
The problem arises when a SIGSEGV happens inside a new operator. I have many
users connected to the program and the clients suddenly hang. That's because
of pthread mutex the malloc and free routines use. The SIGSEGV occurs after
pthread_mutex_lock call and before pthread_mutex_unlock.
So, every time a user tries to use this semaphore the program hangs. New and
delete uses malloc and free with reentrant features. And I'm interested in
that because of pthread program use, but I have this problem for the
exception control.
When I have a problem using one of my mutex I can control lock and unlock
properly, but new and delete mutex relies on library variables.
Is there any way I can control this internal mutex ?
Is there any compiler option to change this behaviour ?
Thanks in advance,
Ignasi Villagrasa.
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: malloc mutex and exceptions
2004-03-21 21:42 malloc mutex and exceptions Ignasi Villagrasa
@ 2004-03-22 16:32 ` Dave Korn
0 siblings, 0 replies; 2+ messages in thread
From: Dave Korn @ 2004-03-22 16:32 UTC (permalink / raw)
To: gcc
> -----Original Message-----
> From: gcc-owner On Behalf Of Ignasi Villagrasa
> Sent: 21 March 2004 19:31
> Hi everyone,
>
> I have been migrating to gcc a server C/C++ based software
> and I' like to control SIGSEGV signal exceptions. So I use
> sigaction and the corresponding handlers to accomplish this target.
>
> The problem arises when a SIGSEGV happens inside a new
> operator.
Fix the bug in your program that trashes the heap. SEGV inside the malloc
handler is basically not a recoverable situation.
> I have many users connected to the program and the
> clients suddenly hang. That's because of pthread mutex the
> malloc and free routines use. The SIGSEGV occurs after
> pthread_mutex_lock call and before pthread_mutex_unlock.
Fix the bug in your program that trashes the heap.
> So, every time a user tries to use this semaphore the program
> hangs.
Fix the bug in your program that trashes the heap.
> New and delete uses malloc and free with reentrant
> features. And I'm interested in that because of pthread
> program use, but I have this problem for the exception control.
>
> When I have a problem using one of my mutex I can control
> lock and unlock properly, but new and delete mutex relies on
> library variables.
>
> Is there any way I can control this internal mutex ?
By not trashing the heap, the new and delete handlers will complete
successfully instead of crashing and get a chance to release the mutex.
> Is there any compiler option to change this behaviour ?
Unfortunately there's no "-fcorrect-stray-pointer-bugs". You'll just have
to fix your bug.
cheers,
DaveK
--
Can't think of a witty .sigline today....
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-03-22 12:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-21 21:42 malloc mutex and exceptions Ignasi Villagrasa
2004-03-22 16:32 ` Dave Korn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).