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

Update POD for Newx/Renew/Safefree vs libc analogs about heap corruption #22682

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pod/perlclib.pod
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ should use C<sv_gets> instead:
p = realloc(p, n) Renew(p, n, t)

It is not portable to try to allocate 0 bytes; allocating 1 or more is
portable.
portable. Never pass pointers between C<Newx>, C<Renew>, C<Safefree> and
I<libc> equivalents C<malloc>, C<realloc>, C<free>. They are not from the
same memory pool or allocator. Either an instant or delayed I<SEGV> will
occur, or subtle memory leaks or subtle heap corruption.

memcpy(dst, src, n) Copy(src, dst, n, t)
memmove(dst, src, n) Move(src, dst, n, t)
Expand Down
11 changes: 8 additions & 3 deletions pod/perldelta.pod
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,20 @@ XXX Changes which significantly change existing files in F<pod/> go here.
However, any changes to F<pod/perldiag.pod> should go in the L</Diagnostics>
section.



Additionally, the following selected changes have been made:

=head3 L<XXX>
=head3 F<pod/perlguts.pod> and F<pod/perlclib.pod>

=over 4

=item *
=item Memory Allocation in C/XS

XXX Description of the change here
Documentation was updated to reflect that mixing C<Newx>, C<Renew>, and
C<Safefree> vs C<malloc>, C<realloc>, and C<free> not allowed, and mixing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing the verb are here

pointers between the 2 classes of APIs is not allowed. Updates made in
F<pod/perlguts.pod> and F<pod/perlclib.pod>.

=back

Expand Down
5 changes: 4 additions & 1 deletion pod/perlguts.pod
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,10 @@ marked with correct flags.
All memory meant to be used with the Perl API functions should be manipulated
using the macros described in this section. The macros provide the necessary
transparency between differences in the actual malloc implementation that is
used within perl.
used within perl. Never pass pointers between C<Newx>, C<Renew>, C<Safefree>
and I<libc> equivalents C<malloc>, C<realloc>, C<free>. They are not from the
same memory pool or allocator. Either an instant or delayed I<SEGV> will
occur, or subtle memory leaks or subtle heap corruption.

The following three macros are used to initially allocate memory :

Expand Down
Loading