Ticket #956: segfaulty.pmc

File segfaulty.pmc, 0.6 KB (added by darbelo, 5 years ago)

Example segfaulty PMC

Line 
1#include <string.h>
2#include "parrot/parrot.h"
3
4static PMC *SegFaulty_PMC = NULL;
5
6pmclass SegFaulty
7    singleton dynpmc {
8
9    ATTR INTVAL i;
10
11    VTABLE void *get_pointer() {
12        return SegFaulty_PMC;
13    }
14
15    VTABLE void set_pointer(void *ptr) {
16        SegFaulty_PMC = (PMC *) ptr;
17    }
18
19    VTABLE void init() {
20        Parrot_SegFaulty_attributes *attr;
21
22        attr = mem_allocate_typed(Parrot_SegFaulty_attributes);
23        PMC_data(SELF) = attr;
24        PObj_active_destroy_SET(SELF);
25    }
26
27    VTABLE void destroy() {
28        mem_sys_free(PMC_data(SELF));
29    }
30
31}