---
title: "Assertion failure: thing, at...gc/Marking.cpp:112"
author: "HEXLee"
date: "2014-04-15T22:04:53Z"
tags: []
categories: ["移动开发"]
slug: "assertion-failure-thing-at-gc-marking-cpp-112"
draft: false
lastmod: "2014-04-15T22:04:53Z"
id: 2047092
url: "https://hexlee.iteye.com/blog/2047092"
---

遇到个jsb的bug，全公司的人整整折腾了2天！！

描述：

下面代码，在GC后，程序崩溃，错误log输出如下：

**Assertion failure: thing, at /Users/james/Project/Spidermonkey/js/src/gc/Marking.cpp:112**

**代码：**

```
var FightActionAttack = cc.Class.extend({
    init: function (attacker) {
        var self = this;
        attacker.getAnimation().play("normalAttack");
        attacker.getAnimation().setMovementEventCallFunc(this._movementAttackEvent, this);
    },

    _movementAttackEvent: function (armature, movementType, movementID) {

    },

    _frameAttackEvent: function (bone, evt, originFrameIndex, currentFrameIndex) {

    }
});
```

**原因：**

**cocos2d-x 2.x版本的jsb中，不能使用继承只cc.Class的对象做CallbackFunc的回调target,**

**因为这种直接集成自cc.Class的对象做callback回调的target，会把gc搞崩溃。** 

**解决办法是，集成cc.Node**