Christian Stalp | 9 May 2006 19:06
Picon
Picon

IPC-Semaphore

Hello out there,
Im working on a solution to delete a semaphore, which is used by other 
processes.
The semaphore was created by a server-process. It write the semaphore-key into 
a file ( where the clients can read it, and get access to the semaphore )
After that the server proceeds its work. 
When the server finished its work, it destroys the semaphore. And here we have 
quandary. In this very moment the clients still need the semaphore.

In the semctl-manual we have a several arguments, amongst others.
GETZCNT     The  system  call returns the value of semzcnt for the sem-
                   num-th semaphore of the set (i.e. the number  of  processes
                   waiting for semval of the semnum-th semaphore of the set to
                   become 0).  The calling process must have read access priv-
                   ileges on the semaphore set.
or
GETNCNT     The  system  call returns the value of semncnt for the sem-
                   num-th semaphore of the set (i.e. the number  of  processes
                   waiting  for  an  increase  of  semval  for  the  semnum-th
                   semaphore of the set).  The calling process must have  read
                   access privileges on the semaphore set.

based on this I made this function:
/* Loeschen einer Semaphore                                               */
int loesche_semaphore ( int kennung )
{
  union semun mysem;
  int semnum      = 0,
      rueckgabe_1 = 0,
      rueckgabe_2 = 0;
(Continue reading)

Kenneth | 10 May 2006 05:26
Picon

Freie Stelle bei NuMarkets LLC. Zuverlaessiges Personal gesucht

<link rel=Edit-Time-Data href="numarkets-1-Dateien/editdata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>TheTraidingBay 2006</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>os</o:Author>
  <o:LastAuthor>os</o:LastAuthor>
  <o:Revision>5</o:Revision>
  <o:Created>2006-05-09T22:19:00Z</o:Created>
  <o:LastSaved>2006-05-09T22:27:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Words>369</o:Words>
  <o:Characters>2108</o:Characters>
  <o:Lines>17</o:Lines>
  <o:Paragraphs>4</o:Paragraphs>
  <o:CharactersWithSpaces>2473</o:CharactersWithSpaces>
  <o:Version>10.2625</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
(Continue reading)

Shriramana Sharma | 12 May 2006 10:11
Picon

"double free or corruption" - how to solve this?

One of my programs, which was working quite well till now, suddenly
gives me the error:

*** glibc detected *** double free or corruption (top): 0x0808a338 ***
Aborted

It is a pure C program compiled with GCC 4.02 -- I do not understand
why it does not work suddenly. Please tell me what the above error can
be.

Thanks.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

wwp | 12 May 2006 10:19
X-Face
Face
Picon
Favicon

Re: "double free or corruption" - how to solve this?

Hello Shriramana,

On Fri, 12 May 2006 13:41:12 +0530 "Shriramana Sharma" <samjnaa <at> gmail.com> wrote:

> One of my programs, which was working quite well till now, suddenly
> gives me the error:
> 
> *** glibc detected *** double free or corruption (top): 0x0808a338 ***
> Aborted
> 
> It is a pure C program compiled with GCC 4.02 -- I do not understand
> why it does not work suddenly. Please tell me what the above error can
> be.

Would be nice to run it from gdb, in order to get the backtrace when it
crashes. This should help you understand where and why :).

Regards,

--

-- 
wwp
Steve Graegert | 12 May 2006 10:45
Picon

Re: "double free or corruption" - how to solve this?

On 5/12/06, wwp <subscript <at> free.fr> wrote:
> Hello Shriramana,
>
>
> On Fri, 12 May 2006 13:41:12 +0530 "Shriramana Sharma" <samjnaa <at> gmail.com> wrote:
>
> > One of my programs, which was working quite well till now, suddenly
> > gives me the error:
> >
> > *** glibc detected *** double free or corruption (top): 0x0808a338 ***
> > Aborted
> >
> > It is a pure C program compiled with GCC 4.02 -- I do not understand
> > why it does not work suddenly. Please tell me what the above error can
> > be.
>
> Would be nice to run it from gdb, in order to get the backtrace when it
> crashes. This should help you understand where and why :).

Additionally, you can try valgrind, which reports typical programming
errors like calling free() twice on the same object.

	\Steve
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

james-lists | 12 May 2006 14:01

RE: "double free or corruption" - how to solve this?

Hi,

Try linking your program with electric fence. It may already be installed it
comes on most distros now. Add -lefence when linking. It should help you pin
point the problem very quickly when used with a debugger like gdb.

	James

> -----Original Message-----
> From: linux-c-programming-owner <at> vger.kernel.org [mailto:linux-c-
> programming-owner <at> vger.kernel.org] On Behalf Of Shriramana Sharma
> Sent: 12 May 2006 09:11
> To: linux-c-programming <at> vger.kernel.org
> Subject: "double free or corruption" - how to solve this?
> 
> One of my programs, which was working quite well till now, suddenly
> gives me the error:
> 
> *** glibc detected *** double free or corruption (top): 0x0808a338 ***
> Aborted
> 
> It is a pure C program compiled with GCC 4.02 -- I do not understand
> why it does not work suddenly. Please tell me what the above error can
> be.
> 
> Thanks.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-
> programming" in
> the body of a message to majordomo <at> vger.kernel.org
(Continue reading)

Jedenastik, Günther | 12 May 2006 22:40
Picon

AW: "double free or corruption" - how to solve this?


>Hello Shriramana,

>On Fri, 12 May 2006 13:41:12 +0530 "Shriramana Sharma" <samjnaa <at> gmail.com> >wrote:

>> One of my programs, which was working quite well till now, suddenly
>> gives me the error:
>> 
>> *** glibc detected *** double free or corruption (top): 0x0808a338 ***
>> Aborted
>> 
>> It is a pure C program compiled with GCC 4.02 -- I do not understand
>> why it does not work suddenly. Please tell me what the above error can
>> be.

>Would be nice to run it from gdb, in order to get the backtrace when it
>crashes. This should help you understand where and why :).

>Regards,

>-- 
>wwp

I have a similar problem, but i don't know how gdb can help with this?
I tried with gdb (btw: I have one process forked (and a few threads) and I think this process creates the
problem) but I only get the problem during exit handlers (e.g. SIGINT)

To get back to my question: how can I trace the problem with gdb, if I have forked processes and threads?

Cause it seems, that glibc only prints the line "*** glibc detected *** double free or corruption" and then continues
(Continue reading)

Nate Jenkins | 12 May 2006 23:06

Re: "double free or corruption" - how to solve this?


>> Hello Shriramana,
>>
>>
>> On Fri, 12 May 2006 13:41:12 +0530 "Shriramana Sharma" 
>> <samjnaa <at> gmail.com> wrote:
>>
>> > One of my programs, which was working quite well till now, suddenly
>> > gives me the error:
>> >
>> > *** glibc detected *** double free or corruption (top): 0x0808a338 ***
>> > Aborted
>> >
>> > It is a pure C program compiled with GCC 4.02 -- I do not understand
>> > why it does not work suddenly. Please tell me what the above error can
>> > be.
>>
>> Would be nice to run it from gdb, in order to get the backtrace when it
>> crashes. This should help you understand where and why :).
>
> Additionally, you can try valgrind, which reports typical programming
> errors like calling free() twice on the same object.
>
> \Steve
> -

Steve,

I just saw that utility the other day.  It looks interesting.  How do you 
typically use it?  or grindcall-grindval?  Do you know of a good tutorial 
(Continue reading)

Steve Graegert | 12 May 2006 23:35
Picon

Re: "double free or corruption" - how to solve this?

On 5/12/06, Nate Jenkins <nate <at> uniwest.com> wrote:
>
> >> Hello Shriramana,
> >>
> >>
> >> On Fri, 12 May 2006 13:41:12 +0530 "Shriramana Sharma"
> >> <samjnaa <at> gmail.com> wrote:
> >>
> >> > One of my programs, which was working quite well till now, suddenly
> >> > gives me the error:
> >> >
> >> > *** glibc detected *** double free or corruption (top): 0x0808a338 ***
> >> > Aborted
> >> >
> >> > It is a pure C program compiled with GCC 4.02 -- I do not understand
> >> > why it does not work suddenly. Please tell me what the above error can
> >> > be.
> >>
> >> Would be nice to run it from gdb, in order to get the backtrace when it
> >> crashes. This should help you understand where and why :).
> >
> > Additionally, you can try valgrind, which reports typical programming
> > errors like calling free() twice on the same object.
> >
> > \Steve
> > -
>
> Steve,
>
> I just saw that utility the other day.  It looks interesting.  How do you
(Continue reading)

Nate Jenkins | 12 May 2006 23:46

Re: "double free or corruption" - how to solve this?


>> >> Hello Shriramana,
>> >>
>> >>
>> >> On Fri, 12 May 2006 13:41:12 +0530 "Shriramana Sharma"
>> >> <samjnaa <at> gmail.com> wrote:
>> >>
>> >> > One of my programs, which was working quite well till now, suddenly
>> >> > gives me the error:
>> >> >
>> >> > *** glibc detected *** double free or corruption (top): 0x0808a338 
>> >> > ***
>> >> > Aborted
>> >> >
>> >> > It is a pure C program compiled with GCC 4.02 -- I do not understand
>> >> > why it does not work suddenly. Please tell me what the above error 
>> >> > can
>> >> > be.
>> >>
>> >> Would be nice to run it from gdb, in order to get the backtrace when 
>> >> it
>> >> crashes. This should help you understand where and why :).
>> >
>> > Additionally, you can try valgrind, which reports typical programming
>> > errors like calling free() twice on the same object.
>> >
>> > \Steve
>> > -
>>
>> Steve,
(Continue reading)


Gmane