[Gambas-devel] bug in object creation, or in my pcre component?
Benoit Minisini
gambas at ...1...
Tue Jan 25 16:59:54 CET 2005
On Friday 21 January 2005 19:15, Rob wrote:
> Using the latest version of pcre I posted to the list, I noticed
> some crashing behavior.
>
> r = new Regexp("foo", "(foo)")
> print r.submatches[1].text
> ...
> r = new Regexp("bar", "(bar)")
> print r.submatches[1].text
>
> causes a segmentation fault in gbx2 on the last line, but this
> code:
>
> r = new Regexp("foo", "(foo)")
> print r.submatches[1].text
> ...
> r = NULL
> r = new Regexp("bar", "(bar)")
> print r.submatches[1].text
>
> does not. Near as I can figure from sticking a bunch of
> fprintf(stderr, ...)'s in my pcre component is that the Gambas
> interpreter somehow instantiates the new component before
> freeing the old one, resulting in r containing a null pointer
> (on the C side), and forcing it to be done in two steps gets
> around the problem.
>
> So is there a problem in my component's cleanup code or is it an
> interpreter thing?
>
> Rob
>
In REGEXP_new, you allocate an array in a static variable named 'smcache'.
Then, if you create two regular expressions, the same static variable is
used. I see a problem there... :-)
--
Benoit Minisini
mailto:gambas at ...1...
More information about the Devel
mailing list