[Gc] Re: Re[3]: GC_is_disabled returns false when GC_enable() is called too many times

Kjetil Matheussen k.s.matheussen at notam02.no
Sun Dec 9 07:42:07 PST 2012


Hi Ivan,

Let's say the default behavior in a program is to disable the GC.
Then you might have functions looking like this:

{
   GC_enable();
   <do something>
   GC_disable();
}

And in case <do something> calls a function which calls GC_enable() 
another time,
the garbage collector will be disabled (!), since GC_dont_gc then gets 
the value -1.



On 09.12.2012 15:51, Ivan Maidanski wrote:
> Hi Kjetil,
>
> According to the current design, GC_disable/enable usage is as:
>
> GC_disable();
> /// do something critical
> GC_enable();
>
> Thus unbalanced disable/enable should be a client bug.
>
> What are you reason to request a change?
>
> Regards,
> Ivan
>
> 9 Dec 2012, 14:55 Kjetil Matheussen :
>
>> On 09.12.2012 14:24, Kjetil Matheussen wrote:
>> > On 09.12.2012 14:21, Kjetil Matheussen wrote:
>> >> ...which is quite confusing. Perhaps GC_is_disabled should be
>> >> changed
>> >> like this?
>> >>
>> >>
>> >> [kjetil at ttlush gc-7.2]$ diff -u misc_bu.c misc.c
>> >> --- misc_bu.c 2012-12-09 14:18:53.185065422 +0100
>> >> +++ misc.c 2012-12-09 14:20:33.955746560 +0100
>> >> @@ -1472,7 +1472,7 @@
>> >>
>> >> GC_API int GC_CALL GC_is_disabled(void)
>> >> {
>> >> - return GC_dont_gc != 0;
>> >> + return GC_dont_gc >= 0;
>> >> }
>> >>
>> >> /* Helper procedures for new kind creation. */
>> >
>> >
>> > Ouch. I ment:
>> >
>> >
>> > [kjetil at ttlush gc-7.2]$ diff -u misc_bu.c misc.c
>> > --- misc_bu.c 2012-12-09 14:18:53.185065422 +0100
>> > +++ misc.c 2012-12-09 14:23:55.108103240 +0100
>> > @@ -1472,7 +1472,7 @@
>> >
>> > GC_API int GC_CALL GC_is_disabled(void)
>> > {
>> > - return GC_dont_gc != 0;
>> > + return GC_dont_gc > 0;
>> > }
>> >
>> > /* Helper procedures for new kind creation. */
>> >
>>
>> Hmm, I see now that the current behaviour is
>> correct according to documentation, and that this would
>> be an API change. Sorry for the noise.
>>
>> Perhaps the API for enable/disable should be changed in the next
>> major version?
>>
>> _______________________________________________
>> Gc mailing list
>> Gc at linux.hpl.hp.com [1]
>> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/ [2]
>
>
>
> Links:
> ------
> [1] 
> http://www.eposttjener.no/sentmsg?compose|+|amp|+|To=Gc@linux.hpl.hp.com
> [2] http://www.hpl.hp.com/hosted/linux/mail-archives/gc/


More information about the Gc mailing list