# New Ticket Created by Nick Glencross # Please include the string: [perl #37627] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37627 >
In r9815 I believe there to be a rare problem with the memory allocation during register colouring. e.g. Running t/pmc/freeze_26.pir under valgrind reveals: ==13864== Thread 1: ==13864== Invalid write of size 1 ==13864== at 0x814EFDC: map_colors (reg_alloc.c:811) ==13864== by 0x814EE1A: try_allocate (reg_alloc.c:757) ==13864== by 0x814DE61: graph_coloring_reg_alloc (reg_alloc.c:186) ==13864== by 0x814DCC7: imc_reg_alloc (reg_alloc.c:141) ==13864== by 0x8147A7A: imc_compile_unit (imc.c:72) ==13864== by 0x8147C35: imc_close_unit (imc.c:141) ==13864== by 0x813F226: yyparse (imcc.y:412) ==13864== by 0x8084705: main (main.c:574) ==13864== Address 0x1CBEA23B is 5 bytes after a block of size 6 alloc'd ==13864== at 0x1B903338: malloc (vg_replace_malloc.c:130) ==13864== by 0x80862DC: mem_sys_allocate (memory.c:43) ==13864== by 0x814ED7A: try_allocate (reg_alloc.c:749) ==13864== by 0x814DE61: graph_coloring_reg_alloc (reg_alloc.c:186) ==13864== by 0x814DCC7: imc_reg_alloc (reg_alloc.c:141) ==13864== by 0x8147A7A: imc_compile_unit (imc.c:72) ==13864== by 0x8147C35: imc_close_unit (imc.c:141) ==13864== by 0x813F226: yyparse (imcc.y:412) ==13864== by 0x8084705: main (main.c:574) The code is assuming that a maximum of unit->n_symbols exist, but will step outside this range in rare circumstance. The memory allocation and initially setting the flags is ok, but clearing them stomps memory (I believe). This can also be confirmed by putting prints into imcc/reg_alloc.c. Putting a prints at the allocation and at the flag clearing, you get: Allocate space for 6 register flags Clear flag on register flag 11 Not good, as 11 > 6. I don't currently understand things well enough to submit a fix. Cheers, Nick