# Go.get causing silent crash(#4286)(SOLVED)

**URL:** <https://forum.defold.com/t/go-get-causing-silent-crash-4286-solved/51727>\
**Category:** Bugs\
**Created:** [May 10, 2019, 11:24am UTC](https://forum.defold.com/t/go-get-causing-silent-crash-4286-solved/51727 "2019-05-10T11:24:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcardellg](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/m/ce73a5/32.png) [@mcardellg](https://forum.defold.com/u/mcardellg)\
**Post date:** [May 10, 2019, 11:24am UTC](https://forum.defold.com/t/go-get-causing-silent-crash-4286-solved/51727/1 "2019-05-10T11:24:31Z")

</div>

[Source](https://1drv.ms/u/s!Aup_NDH7UAIvg4xFm_WY8gff7_Rohw)

Hi, I am trying to use go.get() to fetch a property into a factory created object from another factory created object using a url stored in a list. With the go.get() line in place it causes a silent crash with nothing returned to the console, not even any previous print statements.

The attached code should demonstrate this, line 22 of sp.script is the culprit.

I hope you can recreate the issue, if not let me know and I`ll try the code on some other systems.

Cheers,  
Giles

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [May 10, 2019, 12:21pm UTC](https://forum.defold.com/t/go-get-causing-silent-crash-4286-solved/51727/2 "2019-05-10T12:21:42Z")

</div>

You never attached any file!

---

<div class="post-metadata">

**Author:** ![mcardellg](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/m/ce73a5/32.png) [@mcardellg](https://forum.defold.com/u/mcardellg)\
**Post date:** [May 10, 2019, 3:32pm UTC](https://forum.defold.com/t/go-get-causing-silent-crash-4286-solved/51727/3 "2019-05-10T15:32:22Z")

</div>

Click on “Source”.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [May 10, 2019, 4:14pm UTC](https://forum.defold.com/t/go-get-causing-silent-crash-4286-solved/51727/4 "2019-05-10T16:14:31Z")

</div>

Ah. I took a look. It’s bad that we crash but there is a reason. This line crashes:

```
print(go.get(list[math.random(0,listpos-1)], "parentid"))

```

First some comments:

- `list` and `listpos` are global. It’s usually not recommended to use global variables as it can result in a lot of unwanted side effects etc. In this case it’s not the cause of the problem though.

- I usually recommend that you break-up hard to read lines of code into several shorter easier to read lines. Like this:

Now, in the `init()` function you do:

```
go.property("parentid", hash(""))

function init(self)
	spawntimer = 0.1
	list[listpos] = go.get_id()
	listpos = listpos + 1
end

```

So, on the current script you have a script property called `parentid`. And you’re trying to look that up in your `update()` function where the crash happens. The thing is though that in init you store:

```
	list[listpos] = go.get_id()

```

Where it really should be:

```
	list[listpos] = go.get_id("#") -- the property is on this script

```

You could also do like this in init() and store the url:

```
list[listpos] = msg.url()

```

---

<div class="post-metadata">

**Author:** ![mcardellg](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/m/ce73a5/32.png) [@mcardellg](https://forum.defold.com/u/mcardellg)\
**Post date:** [May 10, 2019, 4:27pm UTC](https://forum.defold.com/t/go-get-causing-silent-crash-4286-solved/51727/5 "2019-05-10T16:27:26Z")

</div>

Ah, thank you.

The only reason for the one liner is this was quickly put together code to demonstrate the problem.

So, Defold should not crash but the crash is actually being caused by my doing something unexpected.

Is it only go.get\_id() that needs the “#” if referring to the same script or does that also apply to the other get\_… methods as well?

Thanks for the help, I can move forward now 🙂

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [May 10, 2019, 4:29pm UTC](https://forum.defold.com/t/go-get-causing-silent-crash-4286-solved/51727/6 "2019-05-10T16:29:40Z")

</div>

> [@mcardellg](#):
>
> Is it only go.get\_id() that needs the “#” if referring to the same script or does that also apply to the other get\_… methods as well?

It’s for go.get and go.set only since they need to know which component you’re trying to get a property from.

---

<div class="post-metadata">

**Author:** ![AGulev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/agulev/32/4541_2.png) [@AGulev](https://forum.defold.com/u/AGulev)\
**Post date:** [August 19, 2019, 12:52pm UTC](https://forum.defold.com/t/go-get-causing-silent-crash-4286-solved/51727/7 "2019-08-19T12:52:48Z")

</div>

Solved in [Defold 1.2.160 has been released](https://forum.defold.com/t/defold-1-2-160-has-been-released/60637)
