unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* scm_must_realloc mallocated count in 1.6
@ 2006-03-19 22:46 Kevin Ryde
  2006-03-25 22:56 ` Marius Vollmer
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Ryde @ 2006-03-19 22:46 UTC (permalink / raw)


There's a bit of a bug in scm_must_realloc and its scm_mallocated
counting in 1.6.

If you tell scm_must_realloc to decrease the size of a block, it
doesn't change scm_mallocated count, so when you later report the new
size in the free, the final scm_mallocated is off by the difference
(ie. bigger than it should be).

This occurs in the core with bignums when scm_i_adjbig trims off
excess digits from the end of a block.  It might happen with
applications, though perhaps realloc to decrease isn't too common.

A little loop that shows the problem is

    (while #t
      (ash 1 256)
      (gc)
      (pk (assq-ref (gc-stats) 'bytes-malloced)))

The count printed keeps going up.


I'm inclined to remove the short-circuit

	if (size <= old_size)
	  return where;

from scm_must_realloc, ie. if you ask to decrease a block then
actually do it, which is what 1.8 has now.

The alternative would be to leave no realloc() on decrease, but do
adjust scm_mallocated.  That would mean scm_mallocated doesn't reflect
the amount of malloc actually in use, which wouldn't be a good thing
for the mtrigger stuff.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: scm_must_realloc mallocated count in 1.6
  2006-03-19 22:46 scm_must_realloc mallocated count in 1.6 Kevin Ryde
@ 2006-03-25 22:56 ` Marius Vollmer
  0 siblings, 0 replies; 2+ messages in thread
From: Marius Vollmer @ 2006-03-25 22:56 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> writes:

> I'm inclined to remove the short-circuit
> 
> 	if (size <= old_size)
> 	  return where;
> 
> from scm_must_realloc, ie. if you ask to decrease a block then
> actually do it, which is what 1.8 has now.

Sounds good to me.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-25 22:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-19 22:46 scm_must_realloc mallocated count in 1.6 Kevin Ryde
2006-03-25 22:56 ` Marius Vollmer

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).