-
Notifications
You must be signed in to change notification settings - Fork 550
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
Misleading output for calloc while -Dm in effect #16653
Comments
From @eserteThis is a bug report for perl from slaven@rezic.de, If -Dm is used then calloc() calls are logged like this: 0x2cbf90930: (2217022366) calloc 32808 x 32808 bytes It looks like approximately 1GB is allocated here. But the actual DEBUG_m DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%" UVxf ": (%05ld) calloc %ld x %ld bytes\n",PTR2UV(ptr),(long)PL_an++,(long)count,(long)total_size)); so the last number is not the single element size, but the total size Probably the output should look different here, for example calloc %ld elements totalling %ld bytes or calloc %ld x %ld = %ld bytes", ... count, size, total_size or so. Flags: Site configuration information for perl 5.28.0: Configured by eserte at Sat Jun 23 08:28:02 CEST 2018. Summary of my perl5 (revision 5 version 28 subversion 0) configuration: @INC for perl 5.28.0: Environment for perl 5.28.0: |
From @tonycozOn Fri, 10 Aug 2018 06:50:56 -0700, slaven@rezic.de wrote:
Something like the attached? Tony |
From @tonycoz0001-perl-133439-fix-Dm-reporting-for-calloc.patchFrom 75b5f4074fce363842f2171e79c1b39b330b6ea4 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Thu, 6 Sep 2018 14:05:20 +1000
Subject: (perl #133439) fix -Dm reporting for calloc()
a) report both the size and count, and the total allocated rather than
just the count and total allocated, which was displayed in a
misleading fashion
b) use %zu formatting to match the original types (size_t) and remove
the casts to long, which can lose information on Win32, where
long is 32-bits on x64 builds.
---
util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util.c b/util.c
index ff88a54bf6..a9bf9b8609 100644
--- a/util.c
+++ b/util.c
@@ -439,7 +439,7 @@ Perl_safesyscalloc(MEM_SIZE count, MEM_SIZE size)
ptr = (Malloc_t)PerlMem_calloc(count ? count : 1, size ? size : 1);
#endif
PERL_ALLOC_CHECK(ptr);
- DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%" UVxf ": (%05ld) calloc %ld x %ld bytes\n",PTR2UV(ptr),(long)PL_an++,(long)count,(long)total_size));
+ DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%" UVxf ": (%05ld) calloc %zu x %zu = %zu bytes\n",PTR2UV(ptr),(long)PL_an++, count, size, total_size));
if (ptr != NULL) {
#ifdef USE_MDH
{
--
2.11.0
|
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Wed, 05 Sep 2018 21:06:12 -0700, tonyc wrote:
Applied as 2273039. Tony |
@tonycoz - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release today of Perl 5.30.0, this and 160 other issues have been Perl 5.30.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#133439 (status was 'resolved')
Searchable as RT133439$
The text was updated successfully, but these errors were encountered: