* make-regexp error memory leak
@ 2004-07-04 23:51 Kevin Ryde
2004-07-07 17:41 ` Rob Browning
0 siblings, 1 reply; 8+ messages in thread
From: Kevin Ryde @ 2004-07-04 23:51 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
When make-regexp throws an error it leaks memory, eg
(while #t (false-if-exception (make-regexp "[")))
I'm looking at the changes below for the cvs and for 1.6, I think they
get the mallocated counting right.
* regex-posix.c (scm_make_regexp): Free rx on error, to avoid memory
leak.
[-- Attachment #2: regex-posix.c.free-cvs.diff --]
[-- Type: text/plain, Size: 648 bytes --]
--- regex-posix.c.~1.62.~ 2003-04-07 08:05:25.000000000 +1000
+++ regex-posix.c 2004-07-04 18:56:03.000000000 +1000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -188,6 +188,7 @@
cflags & ~REG_NOSUB);
if (status != 0)
{
+ scm_gc_free (rx, sizeof(regex_t), "regex");
scm_error (scm_regexp_error_key,
FUNC_NAME,
scm_regexp_error_msg (status, rx),
[-- Attachment #3: regex-posix.c.free-16.diff --]
[-- Type: text/plain, Size: 677 bytes --]
--- regex-posix.c.~1.53.2.3.~ 2002-03-14 15:26:15.000000000 +1000
+++ regex-posix.c 2004-07-04 18:57:30.000000000 +1000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -210,6 +210,8 @@
cflags & ~REG_NOSUB);
if (status != 0)
{
+ free (rx);
+ scm_done_free (sizeof (regex_t));
scm_error (scm_regexp_error_key,
FUNC_NAME,
scm_regexp_error_msg (status, rx),
[-- Attachment #4: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: make-regexp error memory leak
2004-07-04 23:51 make-regexp error memory leak Kevin Ryde
@ 2004-07-07 17:41 ` Rob Browning
2004-07-08 23:57 ` Kevin Ryde
0 siblings, 1 reply; 8+ messages in thread
From: Rob Browning @ 2004-07-07 17:41 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> writes:
> @@ -210,6 +210,8 @@
> cflags & ~REG_NOSUB);
> if (status != 0)
> {
> + free (rx);
> + scm_done_free (sizeof (regex_t));
> scm_error (scm_regexp_error_key,
> FUNC_NAME,
> scm_regexp_error_msg (status, rx),
Hmm. It seems like you probably need a little more rearrangement
since scm_regexp_error_msg still needs the value.
--
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: make-regexp error memory leak
2004-07-07 17:41 ` Rob Browning
@ 2004-07-08 23:57 ` Kevin Ryde
2004-07-09 18:03 ` Rob Browning
0 siblings, 1 reply; 8+ messages in thread
From: Kevin Ryde @ 2004-07-08 23:57 UTC (permalink / raw)
Cc: guile-devel
Rob Browning <rlb@defaultvalue.org> writes:
>
> It seems like you probably need a little more rearrangement
> since scm_regexp_error_msg still needs the value.
Oops. I ran it, obviously it was happy to look at freed memory :).
I changed to get the error message first.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: make-regexp error memory leak
2004-07-08 23:57 ` Kevin Ryde
@ 2004-07-09 18:03 ` Rob Browning
2004-07-10 0:05 ` Kevin Ryde
0 siblings, 1 reply; 8+ messages in thread
From: Rob Browning @ 2004-07-09 18:03 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> writes:
> Rob Browning <rlb@defaultvalue.org> writes:
>>
>> It seems like you probably need a little more rearrangement
>> since scm_regexp_error_msg still needs the value.
>
> Oops. I ran it, obviously it was happy to look at freed memory :).
> I changed to get the error message first.
OK, once you get it working well, it should probably go into 1.6.
--
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: make-regexp error memory leak
2004-07-09 18:03 ` Rob Browning
@ 2004-07-10 0:05 ` Kevin Ryde
2004-07-11 18:37 ` Rob Browning
0 siblings, 1 reply; 8+ messages in thread
From: Kevin Ryde @ 2004-07-10 0:05 UTC (permalink / raw)
Cc: guile-devel
Rob Browning <rlb@defaultvalue.org> writes:
>
> OK, once you get it working well, it should probably go into 1.6.
Yep. I made some changes.
There's probably enough bits and pieces to have a release from the 1.6
soon. Especially since some of the fixes are actual wrong results for
certain cases (logbit, round, ...).
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: make-regexp error memory leak
2004-07-10 0:05 ` Kevin Ryde
@ 2004-07-11 18:37 ` Rob Browning
2004-07-23 23:06 ` Kevin Ryde
0 siblings, 1 reply; 8+ messages in thread
From: Rob Browning @ 2004-07-11 18:37 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> writes:
> Rob Browning <rlb@defaultvalue.org> writes:
>>
>> OK, once you get it working well, it should probably go into 1.6.
>
> Yep. I made some changes.
>
> There's probably enough bits and pieces to have a release from the 1.6
> soon. Especially since some of the fixes are actual wrong results for
> certain cases (logbit, round, ...).
Definitely. There have been a lot of improvements. I was waiting to
make sure we'd cleared up all the bugs on Marius' release-critical
list. That's done now, so I'll be gearing up for a 1.6.5 release
soon.
However, I want to finish and commit my srfi-4 work first since it
fixes a number of bugs. For example, try storing a large number in a
64-bit vector -- the printed representations are wrong.
--
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: make-regexp error memory leak
2004-07-11 18:37 ` Rob Browning
@ 2004-07-23 23:06 ` Kevin Ryde
2004-07-27 1:56 ` Rob Browning
0 siblings, 1 reply; 8+ messages in thread
From: Kevin Ryde @ 2004-07-23 23:06 UTC (permalink / raw)
Cc: guile-devel
Rob Browning <rlb@defaultvalue.org> writes:
>
> For example, try storing a large number in a
> 64-bit vector -- the printed representations are wrong.
Ah, a bit dodgy that.
If you're hunting dodginess, it looks like make-s16vector may assume a
short is 16-bits when converting the "fill" parameter from an SCM. A
system with a bigger short probably gets values silently truncated
instead of provoking range errors. Similarly u16, and s32 and u32
with "int".
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: make-regexp error memory leak
2004-07-23 23:06 ` Kevin Ryde
@ 2004-07-27 1:56 ` Rob Browning
0 siblings, 0 replies; 8+ messages in thread
From: Rob Browning @ 2004-07-27 1:56 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> writes:
> Ah, a bit dodgy that.
>
> If you're hunting dodginess, it looks like make-s16vector may assume a
> short is 16-bits when converting the "fill" parameter from an SCM. A
> system with a bigger short probably gets values silently truncated
> instead of provoking range errors. Similarly u16, and s32 and u32
> with "int".
Yep, thanks, though I *think*, I've probably already fixed those. I
something similar to this for each one:
SCM_DEFINE (scm_make_s16vector, "make-s16vector", 1, 1, 0,
(SCM n, SCM fill),
"Create a newly allocated homogeneous numeric vector which can\n"
"hold @var{len} elements. If @var{fill} is given, it is used to\n"
"initialize the elements, otherwise the contents of the vector\n"
"is unspecified.")
#define FUNC_NAME s_scm_make_s16vector
{
SCM uvec;
size_t count = scm_num2size (n, 1, s_scm_make_s16vector);
uvec = make_uvec (1, FUNC_NAME, SCM_UVEC_S16, count);
if (SCM_UNBNDP (fill))
memset (SCM_UVEC_BASE (uvec), 0, count * sizeof (int_s16));
else
{
int_s16 * p;
int f = scm_num2int (fill, 2, FUNC_NAME);
#if SIZEOF_INT > 2
SCM_ASSERT_RANGE (2, fill,
(f >= (int_s16) -32768) && (f <= (int_s16) 32767));
#endif
p = (int_s16 *) SCM_UVEC_BASE (uvec);
while (count-- > 0)
*p++ = f;
}
return uvec;
}
#undef FUNC_NAME
--
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-07-27 1:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-04 23:51 make-regexp error memory leak Kevin Ryde
2004-07-07 17:41 ` Rob Browning
2004-07-08 23:57 ` Kevin Ryde
2004-07-09 18:03 ` Rob Browning
2004-07-10 0:05 ` Kevin Ryde
2004-07-11 18:37 ` Rob Browning
2004-07-23 23:06 ` Kevin Ryde
2004-07-27 1:56 ` Rob Browning
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).