Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game crash when using yield(): Segmentation fault. 0x08c5484f in NodePath::unref() #1236

Closed
ScyDev opened this issue Jan 16, 2015 · 14 comments
Closed

Comments

@ScyDev
Copy link
Contributor

ScyDev commented Jan 16, 2015

Program received signal SIGSEGV, Segmentation fault.
0x08c5484f in NodePath::unref() ()
(gdb) backtrace
#0  0x08c5484f in NodePath::unref() ()
#1  0x08cb5e7b in Variant::clear() ()
#2  0x08097011 in GDFunction::call(GDInstance*, Variant const**, int, Variant::CallError&, GDFunction::CallState*) ()
#3  0x0809d904 in GDFunctionState::_signal_callback(Variant const**, int, Variant::CallError&) ()
#4  0x080a21f0 in MethodBindNative<GDFunctionState>::call(Object*, Variant const**, int, Variant::CallError&) ()
#5  0x08d19ec3 in Object::call(StringName const&, Variant const**, int, Variant::CallError&) ()
#6  0x08d19282 in Object::call(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) ()
#7  0x08d1ea5f in Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) ()
#8  0x088734b2 in AnimationPlayer::_animation_process(float) ()
#9  0x0887382f in AnimationPlayer::_notification(int) ()
#10 0x0887ee18 in AnimationPlayer::_notificationv(int, bool) ()
#11 0x08d171a2 in Object::notification(int, bool) ()
#12 0x085f8548 in SceneTree::_notify_group_pause(StringName const&, int) ()
#13 0x085f937f in SceneTree::idle(float) ()
#14 0x08058d75 in Main::iteration() ()
#15 0x08055f05 in OS_X11::run() ()
#16 0x0805213c in main ()
(gdb) 
@reduz
Copy link
Member

reduz commented Jan 16, 2015

hmm can't really do much with the backtraces by looking at them, nothing
seems out of the ordinary, could you make a testcase that fails so i can
check what's going on?

On Fri, Jan 16, 2015 at 2:53 PM, ScyDev notifications@github.com wrote:

Program received signal SIGSEGV, Segmentation fault.
0x08c5484f in NodePath::unref() ()
(gdb) backtrace
#0 0x08c5484f in NodePath::unref() ()
#1 #1 0x08cb5e7b in
Variant::clear() ()
#2 #2 0x08097011 in
GDFunction::call(GDInstance_, Variant const__, int, Variant::CallError&,
GDFunction::CallState_) ()
#3 #3 0x0809d904 in
GDFunctionState::signal_callback(Variant const
, int, Variant::CallError&) () #4
#4 0x080a21f0 in
MethodBindNative::call(Object
, Variant const
, int, Variant::CallError&)
()
#5 #5 0x08d19ec3 in
Object::call(StringName const&, Variant const_*, int, Variant::CallError&)
()
#6 #6 0x08d19282 in
Object::call(StringName const&, Variant const&, Variant const&, Variant
const&, Variant const&, Variant const&) ()
#7 #7 0x08d1ea5f in
Object::emit_signal(StringName const&, Variant const&, Variant const&,
Variant const&, Variant const&, Variant const&) ()
#8 #8 0x088734b2 in
AnimationPlayer::_animation_process(float) ()
#9 #9 0x0887382f in
AnimationPlayer::_notification(int) ()
#10 #10 0x0887ee18 in
AnimationPlayer::_notificationv(int, bool) ()
#11 #11 0x08d171a2 in
Object::notification(int, bool) ()
#12 #12 0x085f8548 in
SceneTree::_notify_group_pause(StringName const&, int) ()
#13 #13 0x085f937f in
SceneTree::idle(float) ()
#14 #14 0x08058d75 in
Main::iteration() ()
#15 #15 0x08055f05 in
OS_X11::run() ()
#16 #16 0x0805213c in main ()
(gdb)


Reply to this email directly or view it on GitHub
#1236.

@ScyDev
Copy link
Contributor Author

ScyDev commented Jan 16, 2015

No, unfortunately I can't, because this happens during complex interaction of enemies, enemy projectiles and player projectiles. I don't know why and when it happens.

I could however send you my project through a private channel if you agree to keep it safe and confidential and give you instructions how to provoke the crashes, so you can debug it.

I'll contact you by email.

@reduz
Copy link
Member

reduz commented Jan 16, 2015

from the backtrace and from what i can tell, though, maybe you are using an
animation to delete an instance of something, but you are using .free()
instead of queue_free() ? These kind of errors are usually catched by the
editor, but maybe since it comes from an animation it fails?

On Fri, Jan 16, 2015 at 3:12 PM, ScyDev notifications@github.com wrote:

No, unfortunately I can't, because this happens during complex interaction
of enemies, enemy projectiles and player projectiles. I don't know why and
when it happens.

I could however send you my project through a private channel if you agree
to keep it safe and confidential and give you instructions how to provoke
the crashes, so you can debug it.

I'll contact you by email.


Reply to this email directly or view it on GitHub
#1236 (comment).

@ScyDev
Copy link
Contributor Author

ScyDev commented Jan 16, 2015

Here's an idea: how about an abstaction layer between script and internal Godot Engine calls (kinda like form validation and input sanitization on the web) which checks all function calls and their parameters in order to make it impossible for scripts to crash the game?

@godotengine
Copy link
Collaborator

that layer already exists (it's only active when you run in the debugger
though), and it makes really difficult to crash it, while showing the
errors. But i haven't though specifically the situation of the animation
deleting the object, not sure if that is what is going on,
do you think it might be the case I mentioned?

On Fri, Jan 16, 2015 at 3:28 PM, Juan Linietsky notifications@github.com
wrote:

from the backtrace and from what i can tell, though, maybe you are using
an
animation to delete an instance of something, but you are using .free()
instead of queue_free() ? These kind of errors are usually catched by the
editor, but maybe since it comes from an animation it fails?

On Fri, Jan 16, 2015 at 3:12 PM, ScyDev notifications@github.com wrote:

No, unfortunately I can't, because this happens during complex
interaction
of enemies, enemy projectiles and player projectiles. I don't know why
and
when it happens.

I could however send you my project through a private channel if you
agree
to keep it safe and confidential and give you instructions how to
provoke
the crashes, so you can debug it.

I'll contact you by email.


Reply to this email directly or view it on GitHub
#1236 (comment).


Reply to this email directly or view it on GitHub
#1236 (comment).

OkamStudio

@ScyDev
Copy link
Contributor Author

ScyDev commented Jan 16, 2015

I already have 3 separate (that I can identify) segfault crashes in my simple game.
It doesn't seem so difficulty to crash... :)

No, I am not calling any functions at all from animations. The only thing I do besides keyframes on spritesheets is playing sounds from the animation.

And I always use queue_free().

@ScyDev
Copy link
Contributor Author

ScyDev commented Jan 17, 2015

Found a way to prevent this. I added an if to check whether the projectile has already collided. If that check is inactive (as in the code below) then the error happens. If it is active, then I can't provoke it.

So this means the projectile collides more than once and collider.takeHit(self.damage, true) and self.queue_free() are called more than once.

I don't think that should crash the game though. Does this make sense to you?

extends RigidBody

var NOREST_TYPE = "projectile"

var velocity = null
var damage = 0
var reach = 0

var collided = false

func _init():
    # passing value in constructor doesn't seem to work. must have no params or won't be called at all.

    pass

func _ready():
    set_fixed_process(true)

    # for collisions with rigid bodies
    set_contact_monitor (true)
    set_max_contacts_reported(5)


func _fixed_process(delta):
    if (velocity != null):
        self.set_linear_velocity(velocity)


func setVelocity(newVelocity):
    self.velocity = newVelocity


func setDamage(newDamage):
    self.damage = newDamage


func setReach(newReach):
    self.reach = newReach


func _on_Projectile_Pistol_body_enter(collider):
        if (collider.get("NOREST_TYPE") != "hero" && collider.get("NOREST_TYPE") != "projectile"):
            #if (!collided):
                collided = true

                #print("projectile collided!")

                if (collider.get("NOREST_TYPE") == "zombie"):
                    collider.takeHit(self.damage, true)

                self.queue_free()

@ScyDev
Copy link
Contributor Author

ScyDev commented Jan 17, 2015

Refering to your earlier question about function calls from animation:

Could it be that yield() bound to signal "finished" on an animation is causing this?

    get_node("AnimationPlayer").play("splatter")
    var playingAnim = yield(get_node("AnimationPlayer"), "finished")

    self.queue_free()

Internally this could cause the scenario you described, no? Like, the remainder of the function that is yielding is called from the animation at its end.

What do you think?

@ScyDev
Copy link
Contributor Author

ScyDev commented Jan 17, 2015

Removed all the yield() calls in the game and its stable now even under massive load.

Btw. the crash also happens on yields other than on animations. For example:

    get_node("SpatialSamplePlayer").play("gib_splatter")
    get_node("Timer").start()
    var olo = yield(get_node("Timer"), "timeout")
    get_node("Timer").stop()

@ScyDev ScyDev changed the title Game crash: Segmentation fault. 0x08c5484f in NodePath::unref() Game crash when using yield(): Segmentation fault. 0x08c5484f in NodePath::unref() Jan 17, 2015
@reduz
Copy link
Member

reduz commented Jan 17, 2015

by the way, collider.get("NOREST_TYPE") should also work as collider.NOREST_TYPE

do you think you can make a small example of yield() failing? This feature has never been tested much and it's quite complex, so maybe it fails in some cases that were not tested

@ScyDev
Copy link
Contributor Author

ScyDev commented Jan 17, 2015

Thanks for the hint :) But I'm doing it like this because not all the objects/scripts have this var, and therefore collider.NOREST_TYPE would throw an error.

@akien-mga
Copy link
Member

In this comment [1], @reduz mentions having fixed yield issues around Jan 17. Would this issue happen to be fixed then?

[1] #1234 (comment)

@akien-mga
Copy link
Member

And if it is fixed, what about the apparently related #1235?

@akien-mga
Copy link
Member

No activity in a while, and #1234 is apparently related and was fixed at some time, so closing this one too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants