Skip to content

Commit

Permalink
[GC] fix GC segfault with --optimize
Browse files Browse the repository at this point in the history
A wrong PARROT_CANNOT_RETURN_NULL in Parrot_pf_get_current_code_segment
(unchecked return of inter->code, which can be null) causes GC segfaults
when inter->code == NULL.

Fixes GH #1186.
This wrong PARROT_CANNOT_RETURN_NULL was added with 3.6.0
in 7dc0e22 at Wed Jun 29 20:52:24 2011
but started being fatal after the new packfile refactor with 7.0,
when the cc optimizer started optimizing away the bc != NULL check
in mark_code_segment()
  • Loading branch information
Reini Urban committed Jan 22, 2015
1 parent 4d173db commit 966da74
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/parrot/packfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ PMC * Parrot_pf_annotations_lookup(PARROT_INTERP,
__attribute__nonnull__(2);

PARROT_PURE_FUNCTION
PARROT_CANNOT_RETURN_NULL
PARROT_CAN_RETURN_NULL
PackFile_ByteCode * Parrot_pf_get_current_code_segment(PARROT_INTERP)
__attribute__nonnull__(1);

Expand Down
4 changes: 2 additions & 2 deletions src/gc/mark_sweep.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ mark_code_segment(PARROT_INTERP)
{
ASSERT_ARGS(mark_code_segment)
int i;
PackFile_ByteCode *bc = Parrot_pf_get_current_code_segment(interp);
PackFile_ByteCode *bc = Parrot_pf_get_current_code_segment(interp);

if (bc != NULL) {
if (bc) {
PackFile_ConstTable *ct = bc->const_table;

for (i = 0; i < ct->pmc.const_count; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/packfile/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ Get's the interpreter's currently active bytecode segment
*/

PARROT_PURE_FUNCTION
PARROT_CANNOT_RETURN_NULL
PARROT_CAN_RETURN_NULL
PackFile_ByteCode *
Parrot_pf_get_current_code_segment(PARROT_INTERP)
{
Expand Down

0 comments on commit 966da74

Please sign in to comment.