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
Perl_magic_get reqires ridiculous amounts of stack memory #8244
Comments
From perlbug@plan9.deCreated by perlbug@plan9.deWhile tracking down why some of my programs segfaulted with mysterious This is more than what is usually required for that function (<256 bytes), Andrew Suffield tracked it down to this code: On Tue, Dec 13, 2005 at 08:15:38AM +0000, Andrew Suffield <asuffield@debian.org> wrote:
which, aprrently, is used elsewhere. Such a large value of NGROUPS is Perl Info
|
From @smpeters
OK, comparing Linux to OpenBSD, Linux allows 65536 while OpenBSD allows |
The RT System itself - Status changed from 'new' to 'open' |
From nick@ing-simmons.netSteve Peters via RT <perlbug-followup@perl.org> writes:
What is wrong with the idea of asking OS how many groups user has as |
From @jimcSteve Peters via RT wrote:
attached patch calls getgroups 2x, 1st to find number of groups, [jimc@harpo getgroups]$ ./perl -Ilib t/op/groups.t also attched is 2nd version, which avoids the Newx(), and uses an |
From @jimcInline Patchdiff -ruNp -X exclude-diffs ../bleadperl/mg.c getgroups/mg.c
--- ../bleadperl/mg.c 2005-12-21 11:36:25.000000000 -0700
+++ getgroups/mg.c 2005-12-23 12:43:48.000000000 -0700
@@ -1006,10 +1006,13 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
add_groups:
#ifdef HAS_GETGROUPS
{
- Groups_t gary[NGROUPS];
- I32 j = getgroups(NGROUPS,gary);
+ Groups_t *gary;
+ I32 j = getgroups(0,gary);
+ Newx(gary, j, Groups_t);
+ j = getgroups(j,gary);
while (--j >= 0)
Perl_sv_catpvf(aTHX_ sv, " %"Gid_t_f, (long unsigned int)gary[j]);
+ Safefree(gary);
}
#endif
(void)SvIOK_on(sv); /* what a wonderful hack! */ |
From @jimcInline Patchdiff -ruNp -X exclude-diffs ../bleadperl/mg.c getgroups/mg.c
--- ../bleadperl/mg.c 2005-12-21 11:36:25.000000000 -0700
+++ getgroups/mg.c 2005-12-23 13:20:00.000000000 -0700
@@ -1006,10 +1006,14 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
add_groups:
#ifdef HAS_GETGROUPS
{
- Groups_t gary[NGROUPS];
- I32 j = getgroups(NGROUPS,gary);
- while (--j >= 0)
- Perl_sv_catpvf(aTHX_ sv, " %"Gid_t_f, (long unsigned int)gary[j]);
+ Groups_t *gary;
+ I32 j = getgroups(0,gary);
+ {
+ Groups_t gary[j];
+ j = getgroups(j,gary);
+ while (--j >= 0)
+ Perl_sv_catpvf(aTHX_ sv, " %"Gid_t_f, (long unsigned int)gary[j]);
+ }
}
#endif
(void)SvIOK_on(sv); /* what a wonderful hack! */ |
From @smpetersOn Fri, Dec 23, 2005 at 01:24:29PM -0700, Jim Cromie wrote:
Great! I've added the first version as change #26480. I did make one change Thanks! Steve Peters |
@smpeters - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#37907 (status was 'resolved')
Searchable as RT37907$
The text was updated successfully, but these errors were encountered: