/[pkgs]/devel/perl/09_fix_memory_debugging
ViewVC logotype

Contents of /devel/perl/09_fix_memory_debugging

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Wed Mar 11 22:01:05 2009 UTC (8 months, 1 week ago) by spot
Branch: MAIN
CVS Tags: F-12-split, perl-5_10_0-63_fc11, perl-5_10_0-61_fc11, perl-5_10_0-80_fc12, perl-5_10_0-81_fc12, perl-5_10_0-84_fc13, perl-5_10_0-82_fc13, perl-5_10_0-77_fc12, perl-5_10_0-83_fc13, perl-5_10_0-71_fc12, perl-5_10_0-75_fc12, perl-5_10_0-73_fc12, perl-5_10_0-68_fc11, perl-5_10_0-67_fc11, perl-5_10_0-64_fc11, perl-5_10_0-72_fc12, F-11-split, perl-5_10_0-62_fc11, perl-5_10_0-69_fc12, perl-5_10_0-79_fc12, perl-5_10_0-78_fc12, perl-5_10_0-70_fc12, perl-5_10_0-74_fc12, perl-5_10_0-66_fc11, perl-5_10_0-65_fc11, perl-5_10_0-76_fc12, HEAD
reorder @INC, fix bz 489204, merge useful debian patches
1 Fix a segmentation fault with 'debugperl -Dm'. Upstream change 33388.
2
3 diff --git a/perl.c b/perl.c
4 index e0bc0e7..c5a2070 100644
5 --- a/perl.c
6 +++ b/perl.c
7 @@ -1364,10 +1364,17 @@ perl_free(pTHXx)
8 */
9 const char * const s = PerlEnv_getenv("PERL_DESTRUCT_LEVEL");
10 if (!s || atoi(s) == 0) {
11 + const U32 old_debug = PL_debug;
12 /* Emulate the PerlHost behaviour of free()ing all memory allocated in this
13 thread at thread exit. */
14 + if (DEBUG_m_TEST) {
15 + PerlIO_puts(Perl_debug_log, "Disabling memory debugging as we "
16 + "free this thread's memory\n");
17 + PL_debug &= ~ DEBUG_m_FLAG;
18 + }
19 while(aTHXx->Imemory_debug_header.next != &(aTHXx->Imemory_debug_header))
20 safesysfree(sTHX + (char *)(aTHXx->Imemory_debug_header.next));
21 + PL_debug = old_debug;
22 }
23 }
24 #endif
25 diff --git a/util.c b/util.c
26 index 62fd7ba..d8796cf 100644
27 --- a/util.c
28 +++ b/util.c
29 @@ -178,11 +178,11 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size)
30 ptr = (Malloc_t)PerlMem_realloc(where,size);
31 PERL_ALLOC_CHECK(ptr);
32
33 - DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05ld) rfree\n",PTR2UV(where),(long)PL_an++));
34 - DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05ld) realloc %ld bytes\n",PTR2UV(ptr),(long)PL_an++,(long)size));
35 -
36 - if (ptr != NULL) {
37 + /* MUST do this fixup first, before doing ANYTHING else, as anything else
38 + might allocate memory/free/move memory, and until we do the fixup, it
39 + may well be chasing (and writing to) free memory. */
40 #ifdef PERL_TRACK_MEMPOOL
41 + if (ptr != NULL) {
42 struct perl_memory_debug_header *const header
43 = (struct perl_memory_debug_header *)ptr;
44
45 @@ -198,7 +198,17 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size)
46 header->prev->next = header;
47
48 ptr = (Malloc_t)((char*)ptr+sTHX);
49 + }
50 #endif
51 +
52 + /* In particular, must do that fixup above before logging anything via
53 + *printf(), as it can reallocate memory, which can cause SEGVs. */
54 +
55 + DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05ld) rfree\n",PTR2UV(where),(long)PL_an++));
56 + DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05ld) realloc %ld bytes\n",PTR2UV(ptr),(long)PL_an++,(long)size));
57 +
58 +
59 + if (ptr != NULL) {
60 return ptr;
61 }
62 else if (PL_nomemok)

admin@fedoraproject.org
ViewVC Help
Powered by ViewVC 1.1.2