Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH]5.005_60 (Thread.xs) Memory leaks #368

Closed
p5pRT opened this issue Aug 10, 1999 · 6 comments
Closed

[PATCH]5.005_60 (Thread.xs) Memory leaks #368

p5pRT opened this issue Aug 10, 1999 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 10, 1999

Migrated from rt.perl.org#1202 (status was 'rejected')

Searchable as RT1202$

@p5pRT
Copy link
Author

p5pRT commented Aug 10, 1999

From The RT System itself

1. When a thread structure is being removed, the SV which contains
it(oursv) needs to be unreferenced.
2. After a thread has been joined the AV which contains the return
values should be made mortal - not just each its member when pushed on
the stack.

*** ext\Thread\Thread.xs~ Tue Aug 10 18​:44​:12 1999
--- ext\Thread\Thread.xs Tue Aug 10 18​:48​:47 1999
***************
*** 31,36 ****
--- 31,37 ----
  PL_nthreads--;
  t->prev->next = t->next;
  t->next->prev = t->prev;
+ SvREFCNT_dec(t->oursv);
  COND_BROADCAST(&PL_nthreads_cond);
  MUTEX_UNLOCK(&PL_threads_mutex);
  #endif
***************
*** 379,388 ****
  }
  JOIN(t, &av);
 
  if (SvTRUE(*av_fetch(av, 0, FALSE))) {
  /* Could easily speed up the following if necessary */
  for (i = 1; i <= AvFILL(av); i++)
! XPUSHs(sv_2mortal(*av_fetch(av, i, FALSE)));
  } else {
  STRLEN n_a;
  char *mess = SvPV(*av_fetch(av, 1, FALSE), n_a);
--- 380,391 ----
  }
  JOIN(t, &av);
 
+ sv_2mortal((SV*)av);
+
  if (SvTRUE(*av_fetch(av, 0, FALSE))) {
  /* Could easily speed up the following if necessary */
  for (i = 1; i <= AvFILL(av); i++)
! XPUSHs(*av_fetch(av, i, FALSE));
  } else {
  STRLEN n_a;
  char *mess = SvPV(*av_fetch(av, 1, FALSE), n_a);

@p5pRT
Copy link
Author

p5pRT commented Aug 11, 1999

From The RT System itself

1. After a thread structure has been removed from the thread list the SV
which contains it(oursv) is never unreferenced.

2. After a thread has been joined the AV with the return values does not
become mortal - just its members when pushed on the stack.

Here is the patch​:

*** ext\Thread\Thread.xs~ Tue Aug 10 18​:44​:12 1999
--- ext\Thread\Thread.xs Tue Aug 10 18​:48​:47 1999
***************
*** 31,36 ****
--- 31,37 ----
  PL_nthreads--;
  t->prev->next = t->next;
  t->next->prev = t->prev;
+ SvREFCNT_dec(t->oursv);
  COND_BROADCAST(&PL_nthreads_cond);
  MUTEX_UNLOCK(&PL_threads_mutex);
  #endif
***************
*** 379,388 ****
  }
  JOIN(t, &av);
 
  if (SvTRUE(*av_fetch(av, 0, FALSE))) {
  /* Could easily speed up the following if necessary */
  for (i = 1; i <= AvFILL(av); i++)
! XPUSHs(sv_2mortal(*av_fetch(av, i, FALSE)));
  } else {
  STRLEN n_a;
  char *mess = SvPV(*av_fetch(av, 1, FALSE), n_a);
--- 380,391 ----
  }
  JOIN(t, &av);
 
+ sv_2mortal((SV*)av);
+
  if (SvTRUE(*av_fetch(av, 0, FALSE))) {
  /* Could easily speed up the following if necessary */
  for (i = 1; i <= AvFILL(av); i++)
! XPUSHs(*av_fetch(av, i, FALSE));
  } else {
  STRLEN n_a;
  char *mess = SvPV(*av_fetch(av, 1, FALSE), n_a);

@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

From @schwern

5.005 style threads are dead and will likely be removed in 5.10. Please
use the new interpreter threads (ithreads).

@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

The RT System itself - Status changed from 'stalled' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

@schwern - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Jul 14, 2005
@p5pRT
Copy link
Author

p5pRT commented Jul 14, 2005

@schwern - Status changed from 'resolved' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant