# \[0.8-1988-g1b24ed3\] Segfault when sleeping while hallucinating

**URL:** <https://discourse.cataclysmdda.org/t/0-8-1988-g1b24ed3-segfault-when-sleeping-while-hallucinating/3660>\
**Category:** The Garage\
**Created:** [October 25, 2013, 10:30pm UTC](https://discourse.cataclysmdda.org/t/0-8-1988-g1b24ed3-segfault-when-sleeping-while-hallucinating/3660 "2013-10-25T22:30:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Let\_it\_end\_in\_hellfi](https://avatars.discourse-cdn.com/v4/letter/l/a183cd/32.png) [@Let\_it\_end\_in\_hellfi](https://discourse.cataclysmdda.org/u/Let_it_end_in_hellfi)\
**Post date:** [October 25, 2013, 10:30pm UTC](https://discourse.cataclysmdda.org/t/0-8-1988-g1b24ed3-segfault-when-sleeping-while-hallucinating/3660/1 "2013-10-25T22:30:01Z")

</div>

I went into the shelter basement, took LSD, waited until the hallucinations started, took sleeping pills until I was tired and slept.

`Program received signal SIGSEGV, Segmentation fault
0x083d9ffd in monster::monster (this=0xbfffead0, t=0x73676e69)
    at monster.cpp:57
57 moves = type->speed;
(gdb) bt
#0 0x083d9ffd in monster::monster (this=0xbfffead0, t=0x73676e69)
    at monster.cpp:57
#1 0x08156242 in game::spawn_hallucination (this=0xb7a30008) at game.cpp:5776
#2 0x080f80f9 in handle_deliriant (p=..., dis=...) at disease.cpp:2649
#3 0x080eb7f0 in dis_effect (p=..., dis=...) at disease.cpp:1014
#4 0x084a7b38 in player::suffer (this=0xb7a811a0, g=0xb7a30008)
    at player.cpp:4430
#5 0x081319a1 in game::do_turn (this=0xb7a30008) at game.cpp:723
#6 0x08291bd3 in main (argc=0, argv=0xbffff3b8) at main.cpp:102 `

---

<div class="post-metadata">

**Author:** ![Let\_it\_end\_in\_hellfi](https://avatars.discourse-cdn.com/v4/letter/l/a183cd/32.png) [@Let\_it\_end\_in\_hellfi](https://discourse.cataclysmdda.org/u/Let_it_end_in_hellfi)\
**Post date:** [October 26, 2013, 6:05pm UTC](https://discourse.cataclysmdda.org/t/0-8-1988-g1b24ed3-segfault-when-sleeping-while-hallucinating/3660/2 "2013-10-26T18:05:25Z")

</div>

I think the issue here is that in MonsterGenerator::get\_valid\_hallucination()

```auto

```

rng(x,y) is [x,y] so sometimes it will access outside the bounds of the array.

---

<div class="post-metadata">

**Author:** ![Ian\_Strachan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ian_strachan/32/1003_2.png) [@Ian\_Strachan](https://discourse.cataclysmdda.org/u/Ian_Strachan)\
**Post date:** [October 27, 2013, 6:04pm UTC](https://discourse.cataclysmdda.org/t/0-8-1988-g1b24ed3-segfault-when-sleeping-while-hallucinating/3660/3 "2013-10-27T18:04:29Z")

</div>

Inclusive on both ends, right. Accursed off-by-one error!

I’ll admit, that was my mistake. I’ll get it fixed ASAP; thanks for reporting.
