Bug in SmartEiffel's GC?

4 messages Options
Embed this post
Permalink
Phil Malin-3

Bug in SmartEiffel's GC?

Reply Threaded More More options
Print post
Permalink
Hi all.

I think there might be a bug in SmartEiffel's GC (revision 9354).  Specifically, I've come across a case where the gc_lib.c variable 'rsocfl' has a cycle, thus iterating over it causes it to loop forever.

I don't know enough about the gc_lib code to figure out how it happened - when I came across this issue I just put in print debug statements into gc_lib.c to try and determine where the problem was occurring.  The actual loop is in 'rsocfl_best_fit' and the second while loop, the one in the block starting 'if ((best_size - size) > acceptable_loss)'.

The program I wrote that caused this seemes simple enough (although I tried to write a smaller one to capture the issue but couldn't reproduce it): I had written a class which wraps up a C structure.  I inherited from DISPOSABLE and had the dispose class 'free' the external reference if it hadn't been freed already.  The test program was just an infinite loop where I created an instance of this class (I just wanted to monitor the memory usage to make sure I was mopping up correctly).

Has anyone else encountered this?  Are there some pointers as to what I could try to get more information?

Thanks in advance for any help.

Phil.

Phil Malin-3

Re: Bug in SmartEiffel's GC?

Reply Threaded More More options
Print post
Permalink
Hi all.

As I was checking out the GC code I realised that I was also printing
statements from the dispose routine of some of my Eiffel classes.  Now,
I vaguely recall someone once mentioning that this was a no-no.  Is this
something I shouldn't be doing?  I removed these print statements and
suddenly the cycle in the rsocfl refused to appear.  To the GC experts
here - does this sound reasonable to you?  As in, would print statements
within a dispose cause wacky behaviour like this?

Cheers,
Phil.

Phil Malin wrote:

> Hi all.
>
> I think there might be a bug in SmartEiffel's GC (revision 9354).  
> Specifically, I've come across a case where the gc_lib.c variable
> 'rsocfl' has a cycle, thus iterating over it causes it to loop forever.
>
> I don't know enough about the gc_lib code to figure out how it
> happened - when I came across this issue I just put in print debug
> statements into gc_lib.c to try and determine where the problem was
> occurring.  The actual loop is in 'rsocfl_best_fit' and the second
> while loop, the one in the block starting 'if ((best_size - size) >
> acceptable_loss)'.
>
> The program I wrote that caused this seemes simple enough (although I
> tried to write a smaller one to capture the issue but couldn't
> reproduce it): I had written a class which wraps up a C structure.  I
> inherited from DISPOSABLE and had the dispose class 'free' the
> external reference if it hadn't been freed already.  The test program
> was just an infinite loop where I created an instance of this class (I
> just wanted to monitor the memory usage to make sure I was mopping up
> correctly).
>
> Has anyone else encountered this?  Are there some pointers as to what
> I could try to get more information?
>
> Thanks in advance for any help.
>
> Phil.
>

Cyril ADRIAN

Re: Bug in SmartEiffel's GC?

Reply Threaded More More options
Print post
Permalink
Hi Phil,

On Tue, Mar 10, 2009 at 7:20 AM, Phil Malin <[hidden email]> wrote:
As I was checking out the GC code I realised that I was also printing statements from the dispose routine of some of my Eiffel classes.  Now, I vaguely recall someone once mentioning that this was a no-no.  Is this something I shouldn't be doing?  I removed these print statements and suddenly the cycle in the rsocfl refused to appear.  To the GC experts here - does this sound reasonable to you?  As in, would print statements within a dispose cause wacky behaviour like this?

AFAIR it's a really bad idea to allocate memory in dispose.

For example, try some prints using once (and constant!) strings only.

Best regards,
--
Cyril ADRIAN

http://www.cadrian.net/~cyril
Phil Malin-3

Re: Bug in SmartEiffel's GC?

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hi Cyril.

The funny thing is that I went to the trouble of updating the gc_lib.c file to pretty print out a trace of calls, trying to find where the loop was being introduced.  Not that I'm complaining - it was quite interesting going through the code.  :-)  In fact it would be really nice to be able to spend some time getting to know it better.  It was only after I realised that some of the print statements were coming from a dispose routine that my memory kicked into gear and I remembered someone mentioning this trap before.

Cheers,
Phil.

Cyril ADRIAN wrote:
Hi Phil,

On Tue, Mar 10, 2009 at 7:20 AM, Phil Malin <[hidden email]> wrote:
As I was checking out the GC code I realised that I was also printing statements from the dispose routine of some of my Eiffel classes.  Now, I vaguely recall someone once mentioning that this was a no-no.  Is this something I shouldn't be doing?  I removed these print statements and suddenly the cycle in the rsocfl refused to appear.  To the GC experts here - does this sound reasonable to you?  As in, would print statements within a dispose cause wacky behaviour like this?

AFAIR it's a really bad idea to allocate memory in dispose.

For example, try some prints using once (and constant!) strings only.

Best regards,
--
Cyril ADRIAN

http://www.cadrian.net/~cyril