RE: How to have perl allocate pointers predictably.

[email protected] (bulk 88)
Newsgroups perl.xs
Message-ID <[email protected]>


----------------------------------------
> Date: Thu, 23 Aug 2012 20:33:53 +0300
> From: [email protected]
> To: [email protected]
> Subject: How to have perl allocate pointers predictably.
>
> Hi all,
>
> with the included script below, Devel::Leak keeps outputting different pointers each time for
> the leaked SVs. This makes debugging harder. Can I have perl somehow allocate the same pointers
> each time when an allocation is being requested? I don't mind rebuilding a dedicated perl for that
> using perlbrew or whatever. Note that this also happens if make_trouble() is as simple as
> "my $x; $x = \$x;".
On Windows XP I always get the same SV *s assuming all inputs to the process are the same on each run.
____________________________________________________
C:\Documents and Settings\Owner\Desktop>perl -e "print \\\"perl\""
SCALAR(0x8fe04c)
C:\Documents and Settings\Owner\Desktop>perl -e "print \\\"perl\""
SCALAR(0x8fe04c)
C:\Documents and Settings\Owner\Desktop>perl -e "print \\\"perl\""
SCALAR(0x8fe04c)
C:\Documents and Settings\Owner\Desktop>perl -e "print \\\"perl\""
SCALAR(0x8fe04c)
C:\Documents and Settings\Owner\Desktop>perl -e "print \\\"perl\""
SCALAR(0x8fe04c)
C:\Documents and Settings\Owner\Desktop>perl -e "print \\\"perl\""
SCALAR(0x8fe04c)
C:\Documents and Settings\Owner\Desktop>
____________________________________________________
C:\Documents and Settings\Owner\Desktop>perl -e "print unpack('J', pack('p', \"p
erl\"))"
9468532
C:\Documents and Settings\Owner\Desktop>perl -e "print unpack('J', pack('p', \"p
erl\"))"
9468532
C:\Documents and Settings\Owner\Desktop>perl -e "print unpack('J', pack('p', \"p
erl\"))"
9468532
C:\Documents and Settings\Owner\Desktop>perl -e "print unpack('J', pack('p', \"p
erl\"))"
9468532
C:\Documents and Settings\Owner\Desktop>perl -e "print unpack('J', pack('p', \"p
erl\"))"
9468532
C:\Documents and Settings\Owner\Desktop>
____________________________________________________
Hash number randomization is irrelevant since the width of the hash array is determined by the number of keys/HEKs usually, not the hash number. So the memory allocation sizes and order of them to malloc are the same. Its it quite popular in "modern" OSes to randomize heaps/dlls/stacks/etc per boot or per process nowadays. That is probably what is happening in your case.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.