dougmencken / HeadOverHeels

The free and open source remake of the game “Head over Heels”
GNU General Public License v3.0
33 stars 10 forks source link

chat about old and new segmentation faults, and other stuff (: #25

Closed attuska closed 6 years ago

attuska commented 6 years ago

tor1 tor2

The game now always ends in segmentation faults

Play 1.

> playing Ogg music/blacktooth.ogg
[Thread 0xcdb38b40 (LWP 20104) exited]
creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=80 y=15 z=48 with orientation "nowhere"
creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=80 y=63 z=48 with orientation "nowhere"
creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=130 y=61 z=72 with orientation "nowhere"
terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_M_create
>
>Thread 28 "headoverheels" received signal SIGABRT, Aborted.
[Switching to Thread 0xd282fb40 (LWP 20103)]
0xf7fd9a62 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
(gdb) bt
#0  0xf7fd9a62 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1  0xf7156dc0 in raise () from /lib/libc.so.6
#2  0xf7158287 in abort () from /lib/libc.so.6
#3  0xf744351f in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/../lib/libstdc++.so.6
#4  0xf74410d4 in __cxxabiv1::__terminate(void (*)()) () from /usr/lib/../lib/libstdc++.so.6
#5  0xf744114d in std::terminate() () from /usr/lib/../lib/libstdc++.so.6
#6  0xf7441401 in __cxa_throw () from /usr/lib/../lib/libstdc++.so.6
#7  0xf746beb6 in std::__throw_length_error(char const*) () from /usr/lib/../lib/libstdc++.so.6
#8  0xf74d8f10 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int) ()
   from /usr/lib/../lib/libstdc++.so.6

Play 2.

>   copy of character "heels" with behavior "behavior of Heels" is created to rebuild this room
[New Thread 0xd282fb40 (LWP 20244)]
>
>Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault.
0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4
(gdb) bt
#0  0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4
#1  0x0805584c in ?? ()

Play 3.

>character "head" is yet in room "blacktooth/blacktooth09.xml"
copy of character "head" with behavior "behavior of Head" is created to rebuild this room
[New Thread 0xd282fb40 (LWP 20315)]
creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=80 y=15 z=48 with orientation "nowhere"
creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=80 y=63 z=48 with orientation "nowhere"
creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=130 y=61 z=72 with orientation "nowhere"
creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=80 y=63 z=24 with orientation "nowhere"
>
>Thread 34 "headoverheels" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xd282fb40 (LWP 20315)]
0xf7253fb0 in __memcpy_ssse3 () from /lib/libc.so.6
(gdb) bt
#0  0xf7253fb0 in __memcpy_ssse3 () from /lib/libc.so.6
dougmencken commented 6 years ago

I know about current problems with sequence of drawing, yet I re~factor some parts of code dealing with it

iso_overlap

dougmencken commented 6 years ago

As for segfaulting, may you build at https://github.com/dougmencken/HeadOverHeels/commit/64e099a08a91af44d5a14008b9ef74a80451d636 ( git checkout 64e099a08a91af44d5a14008b9ef74a80451d636 && autoreconf -f -i && ..... ) ?

To look if that’s new mistake being introduced by latest two commits

attuska commented 6 years ago

It is not good. https://github.com/dougmencken/HeadOverHeels/commit/64e099a08a91af44d5a14008b9ef74a80451d636

character "heels" is now in room "blacktooth/blacktooth23.xml" copy of character "heels" with behavior "behavior of Heels" is created to rebuild this room [New Thread 0xd282fb40 (LWP 14797)] play new game [New Thread 0xd3030b40 (LWP 14798)] playing Ogg music/begin.ogg

Thread 2 "headoverheels" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xf6e40b40 (LWP 14790)] 0xf7f2d159 in _mix_some_samples () from /usr/lib/../lib/liballeg.so.4.4 (gdb) bt

0 0xf7f2d159 in _mix_some_samples () from /usr/lib/../lib/liballeg.so.4.4

1 0xf7a7eb4d in alsa_update () from /usr/lib/allegro/4.4.2/alleg-alsadigi.so

2 0xf7f71102 in bg_man_pthreads_threadfunc ()

from /usr/lib/../lib/liballeg.so.4.4

3 0xf736223a in start_thread () from /lib/libpthread.so.0

4 0xf7212ee6 in clone () from /lib/libc.so.6

(gdb)

attuska commented 6 years ago

The https://github.com/dougmencken/HeadOverHeels/commit/af452f5d4775ffdd896e3e76ff8ffefdd97abdf8 is still fine, without segmentations fault

attuska commented 6 years ago

https://github.com/dougmencken/HeadOverHeels/commit/6e4eaba19d45877e348e2b1aa7db26138eae4386

creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=80 y=63 z=48 with orientation "nowhere"

Thread 27 "headoverheels" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xd282fb40 (LWP 27893)] 0xf7253fb0 in __memcpy_ssse3 () from /lib/libc.so.6

attuska commented 6 years ago

https://github.com/dougmencken/HeadOverHeels/commit/670db1eba2645f74c2adba1a139258a81d4c874b

character "head" is now in room "blacktooth/blacktooth06.xml" copy of character "head" with behavior "behavior of Head" is created to rebuild this room [New Thread 0xd282fb40 (LWP 16547)] [New Thread 0xcfb3cb40 (LWP 16548)] playing Ogg music/blacktooth.ogg [Thread 0xcfb3cb40 (LWP 16548) exited] toggled switch in room blacktooth/blacktooth06.xml

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4 (gdb) bt

0 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4

attuska commented 6 years ago

https://github.com/dougmencken/HeadOverHeels/commit/db9b7ac109ffae0c6401665aff689faa3332fad9

player "head" is now in room "blacktooth/blacktooth09.xml" copy of player "head" with behavior "behavior of Head" is created to rebuild this room [New Thread 0xd282fb40 (LWP 29753)] [New Thread 0xcdb38b40 (LWP 29754)] playing Ogg music/blacktooth.ogg [Thread 0xcdb38b40 (LWP 29754) exited] creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=80 y=15 z=48 with orientation "nowhere" creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=80 y=63 z=48 with orientation "nowhere" creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=130 y=61 z=72 with orientation "nowhere" creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=80 y=63 z=24 with orientation "nowhere"

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4 (gdb) bt

0 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4

The previous commit is fine. https://github.com/dougmencken/HeadOverHeels/commit/af452f5d4775ffdd896e3e76ff8ffefdd97abdf8

That's what I could help...

attuska commented 6 years ago

OOhh nooo! https://github.com/dougmencken/HeadOverHeels/commit/af452f5d4775ffdd896e3e76ff8ffefdd97abdf8

[Thread 0xc55a6b40 (LWP 12328) exited] creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=16 y=79 z=0 with orientation "nowhere" creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=2 y=77 z=72 with orientation "nowhere" [Thread 0xd282fb40 (LWP 12327) exited] here’s existing screen for action " CreateListOfSavedGames " parse "/home/attila/.headoverheels/savegame/save1.xml" parse "/home/attila/.headoverheels/savegame/save2.xml" parse "/home/attila/.headoverheels/savegame/save3.xml" save "/home/attila/.headoverheels/savegame/save4.xml" is yet free save "/home/attila/.headoverheels/savegame/save5.xml" is yet free save "/home/attila/.headoverheels/savegame/save6.xml" is yet free save "/home/attila/.headoverheels/savegame/save7.xml" is yet free save "/home/attila/.headoverheels/savegame/save8.xml" is yet free save "/home/attila/.headoverheels/savegame/save9.xml" is yet free save "/home/attila/.headoverheels/savegame/save10.xml" is yet free ~~ done with action ContinueGame

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0x080a1cba in ?? () (gdb) bt

dougmencken commented 6 years ago

I moved my dealing with new ways of drawing ‘n’ sorting into another branch

May you build current master with ./configure --enable-debug and test it ?

attuska commented 6 years ago

Bad.

  1. New game.

playing Ogg music/begin.ogg

Thread 2 "headoverheels" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xf6e40b40 (LWP 11933)] 0xf7f2d159 in _mix_some_samples () from /usr/lib/../lib/liballeg.so.4.4

  1. restart in gdb, and load old game.

Thread 9 "headoverheels" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xd23e1b40 (LWP 11955)] 0xf7253fb0 in __memcpy_ssse3 () from /lib/libc.so.6

dougmencken commented 6 years ago

got it, that’s problem inside allegro4 library, somewhy it doesn’t want to play begin.ogg at the first time

when you load some old game and exit it, then the new one would be okay

but this surely is a big bug, and I don’t yet know how to work around it

and I can’t reproduce that in __memcpy_ssse3 () from /lib/libc.so.6 here on my platform, maybe some more lines of backtracing, down to headoverheels’ code?

attuska commented 6 years ago

No, and no. The allegro4 library is the same, not changed. In the coding of the game something has now been changed that causes that.

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4 (gdb) bt

dougmencken commented 6 years ago

well, may you do git bisect ?

find commit when game was okay on your side, then git bisect start, git bisect bad, git bisect good %sha of that working commit%

attuska commented 6 years ago

I have with git the repos, with various commits download, packaged from it, installed and tried. I made the stable packet for UHU-Linux from git: //github.com/dougmencken/HeadOverHeels.git@d9ed8ab. That works well. Now I have tried to make a newer, but I did not succeed. I started with the master, and then I tried all the ones I mentioned above.

dougmencken commented 6 years ago

I have on my side

play new game
playing Ogg music/begin.ogg

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
[Switching to process 76266 thread 0xfa03]
0x00394060 in mix_hq2_16x2_samples ()
(gdb) bt
#0  0x00394060 in mix_hq2_16x2_samples ()
#1  0x00395834 in _mix_some_samples ()
#2  0x003dcb84 in render_callback ()
#3  0x26e3a7c8 in dyld_stub_strlen ()
#4  0x26e39da8 in dyld_stub_strlen ()
#5  0x26e38f64 in dyld_stub_strlen ()
#6  0x97455c10 in AudioConverterChain::CallInputProc ()
#7  0x974557d4 in AudioConverterChain::FillBufferFromInputProc ()
#8  0x97455718 in BufferedAudioConverter::GetInputBytes ()
#9  0x9745556c in CBRConverter::RenderOutput ()
#10 0x974552f4 in BufferedAudioConverter::FillBuffer ()
#11 0x97455464 in AudioConverterChain::RenderOutput ()
#12 0x974552f4 in BufferedAudioConverter::FillBuffer ()
#13 0x9746ad48 in AudioConverterFillComplexBuffer ()
#14 0x26e38ad0 in dyld_stub_strlen ()
#15 0x26e31d04 in dyld_stub_strlen ()
#16 0x26e66478 in SystemOutputAUEntry ()
#17 0x26e3a74c in dyld_stub_strlen ()
#18 0x26e39da8 in dyld_stub_strlen ()
#19 0x26e38f64 in dyld_stub_strlen ()
#20 0x97455c10 in AudioConverterChain::CallInputProc ()
#21 0x974557d4 in AudioConverterChain::FillBufferFromInputProc ()
#22 0x97455718 in BufferedAudioConverter::GetInputBytes ()
#23 0x974a8b88 in BlockCopyConverter::RenderOutput ()
#24 0x974552f4 in BufferedAudioConverter::FillBuffer ()
#25 0x97455464 in AudioConverterChain::RenderOutput ()
#26 0x974552f4 in BufferedAudioConverter::FillBuffer ()
#27 0x9746ad48 in AudioConverterFillComplexBuffer ()
#28 0x26e38ad0 in dyld_stub_strlen ()
#29 0x26e31d04 in dyld_stub_strlen ()
#30 0x26e3d40c in AUGenericOutputEntry ()
#31 0x97d0e624 in HP_IOProc::Call ()
#32 0x97d0e2b0 in IOA_Device::CallIOProcs ()
#33 0x97d0e164 in HP_IOThread::PerformIO ()
#34 0x97d0cb34 in HP_IOThread::WorkLoop ()
#35 0x97d0c7f4 in HP_IOThread::ThreadEntry ()
#36 0x97cfade8 in CAPThread::Entry ()
#37 0x933f3f74 in _pthread_start ()
(gdb)
attuska commented 6 years ago

Tomorrow.

dougmencken commented 6 years ago

by teh way, removing that file rm ./game/share/headoverheels/music/begin.ogg helps

maybe it’s too... too somewhat for allegro library to play it

attuska commented 6 years ago

Emptying the sounds and music folders will not help, the segmentation error exists.

I tried again and https://github.com/dougmencken/HeadOverHeels/commit/af452f5d4775ffdd896e3e76ff8ffefdd97abdf8 seems good. I opened the other issue with this.

Not good. Mégis rossz!

Segfault again.

03.20 a9d79bc bad (new game)

character "head" is now in room "blacktooth/blacktooth09.xml" copy of character "head" with behavior "behavior of Head" is created to rebuild this room [New Thread 0xd282fb40 (LWP 30773)] [New Thread 0xcdb38b40 (LWP 30774)] playing Ogg music/blacktooth.ogg [Thread 0xcdb38b40 (LWP 30774) exited] creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=80 y=15 z=48 with orientation "nowhere"

Thread 27 "headoverheels" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xd282fb40 (LWP 30773)] 0xf7255e0e in __memcpy_ssse3 () from /lib/libc.so.6

03.18 64e099a bad 03.12 6e4eaba bad 03.11 4fa536d ?? 03.11 62a9013 ?? 03.11 e5f4c92 ?? 03.11 670db1e bad

03.08 db9b7ac bad (new game) entry coordinates are x=1 y=69 z=48 player "head" is now in room "blacktooth/blacktooth09.xml" copy of player "head" with behavior "behavior of Head" is created to rebuild this room [New Thread 0xd282fb40 (LWP 11855)] [New Thread 0xce339b40 (LWP 11856)] playing Ogg music/blacktooth.ogg

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4

(empty sound and music folders, new game)

player "head" is now in room "blacktooth/blacktooth06.xml" copy of player "head" with behavior "behavior of Head" is created to rebuild this room [New Thread 0xd30e3b40 (LWP 11961)] can’t play Ogg music/blacktooth.ogg

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.

03.07 af452f5 bad (in savegame)

creation of behavior "behavior of disappearance in time" for free item "bubbles" at x=2 y=13 z=24 with orientation "nowhere" [Thread 0xd282fb40 (LWP 25446) exited] here’s existing screen for action " CreateListOfSavedGames " Screen::loadAnimation( "head.gif" ) got 18 frames Screen::loadAnimation( "heels.gif" ) got 16 frames parse "/home/attila/.headoverheels/savegame/save1.xml" parse "/home/attila/.headoverheels/savegame/save2.xml" parse "/home/attila/.headoverheels/savegame/save3.xml" parse "/home/attila/.headoverheels/savegame/save4.xml" parse "/home/attila/.headoverheels/savegame/save5.xml" parse "/home/attila/.headoverheels/savegame/save6.xml" save "/home/attila/.headoverheels/savegame/save7.xml" is yet free save "/home/attila/.headoverheels/savegame/save8.xml" is yet free save "/home/attila/.headoverheels/savegame/save9.xml" is yet free save "/home/attila/.headoverheels/savegame/save10.xml" is yet free ~~ done with action ContinueGame

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0x080a214a in ?? ()

attuska commented 6 years ago

https://github.com/dougmencken/HeadOverHeels/commit/67e90ae46d80213b56d4a2b0ac152190474ec8bd Looks good.

dougmencken commented 6 years ago

crash in _linear_draw_sprite32 is randomly reproducible

Thread 1 Crashed:
0   liballeg.4.4.dylib              0x01cf2c50 _linear_draw_sprite32 + 480
1   headoverheels                   0x0000c554 draw_sprite + 128 (parsing.txx:337)
2   headoverheels                   0x0000c554 draw_sprite + 128 (parsing.txx:337)
3   headoverheels                   0x0000caec isomot::FloorTile::draw(BITMAP*) + 84 (stl_tree.h:660)
4   headoverheels                   0x000756d0 isomot::Room::draw(BITMAP*) + 508
5   headoverheels                   0x00055540 isomot::Room::drawRoom() + 60
6   headoverheels                   0x00051be4 isomot::Isomot::update() + 5128
attuska commented 6 years ago

liballeg.so.4.4.2 https://github.com/liballeg/allegro5/releases/4.4.2/ (SiegeLord released this on Apr 30 2017) https://sourceforge.net/projects/alleg/files/allegro/4.4.2/ Similar: https://bugzilla.redhat.com/show_bug.cgi?id=1528109

dougmencken commented 6 years ago

It looks like game draws already finalized shady image of tile. May you build “ introduce wrappers for functions of allegro library ”? https://github.com/dougmencken/HeadOverHeels/commit/7261f38af997417ef35e1f786ba49e9273c2d31d

( allegro::drawSprite ) raw image of floor tile at cx=2 cy=3
( allegro::drawSprite ) shady image of floor tile at cx=2 cy=4
( allegro::drawSprite ) shady image of floor tile at cx=2 cy=5

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x430a0000
[Switching to process 57965 thread 0x3803]
0x0000d094 in draw_sprite (bmp=0x2990ec00, sprite=0x2793b3e0, x=225, y=288) at inline/draw.inl:238
238 AL_INLINE(void, draw_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y),
(gdb) bt
#0  0x0000d094 in draw_sprite (bmp=0x2990ec00, sprite=0x2793b3e0, x=225, y=288) at inline/draw.inl:238
#1  0x0000e2ec in allegro::drawSprite (view=0x2990ec00, sprite=0x2793b3e0, x=225, y=288, printMe=@0xf007ffa4) at WrappersAllegro.hpp:32
#2  0x0000dcac in isomot::FloorTile::draw (this=0x2795cf20, where=0x2990ec00) at FloorTile.cpp:45
#3  0x00078b78 in isomot::Room::draw (this=0x27928770, where=0x2990ec00) at Room.cpp:783
#4  0x00057a34 in isomot::Room::drawRoom (this=0x27928770) at Room.hpp:90
#5  0x000550e8 in isomot::Isomot::update (this=0x27936200) at Isomot.cpp:372
dougmencken commented 6 years ago

As I see running updated https://github.com/dougmencken/HeadOverHeels/commit/27e9822b5a6b74842ba20e6b0bbbd968459f89d0 , game draws previously destroyed image, and then destroys it again

( allegro::drawSprite ) raw image of floor tile at cx=1 cy=3 via FloorTile::draw
( allegro::drawSprite ) raw image of floor tile at cx=1 cy=4 via FloorTile::draw
( allegro::drawSprite ) raw image of floor tile at cx=1 cy=5 via FloorTile::draw
( allegro::destroyBitmap ) shady image of floor tile at cx=1 cy=6 via FloorTile::setShadyImage
( allegro::drawSprite ) shady image of floor tile at cx=1 cy=6 via FloorTile::draw
( allegro::destroyBitmap ) shady image of floor tile at cx=1 cy=6 via FloorTile::setShadyImage
( allegro::drawSprite ) raw image of floor tile at cx=2 cy=3 via FloorTile::draw
( allegro::drawSprite ) raw image of floor tile at cx=2 cy=4 via FloorTile::draw
( allegro::destroyBitmap ) shady image of floor tile at cx=2 cy=5 via FloorTile::setShadyImage
( allegro::drawSprite ) shady image of floor tile at cx=2 cy=5 via FloorTile::draw
( allegro::destroyBitmap ) shady image of floor tile at cx=2 cy=6 via FloorTile::setShadyImage
( allegro::drawSprite ) shady image of floor tile at cx=2 cy=6 via FloorTile::draw
( allegro::destroyBitmap ) shady image of floor tile at cx=2 cy=5 via FloorTile::setShadyImage
( allegro::destroyBitmap ) shady image of floor tile at cx=2 cy=6 via FloorTile::setShadyImage
attuska commented 6 years ago

https://github.com/dougmencken/HeadOverHeels/commit/7261f38af997417ef35e1f786ba49e9273c2d31d

( allegro::drawSprite ) shady image of floor tile at cx=3 cy=5 ( allegro::drawSprite ) raw image of floor tile at cx=4 cy=0 ( allegro::drawSprite ) raw image of floor tile at cx=4 cy=1 ( allegro::drawSprite ) raw image of floor tile at cx=4 cy=2 ( allegro::drawSprite ) raw image of floor tile at cx=4 cy=3 ( allegro::drawSprite ) shady image of floor tile at cx=4 cy=4

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0x00007ffff7b6ae50 in _linear_draw_sprite32 () from /usr/lib/liballeg.so.4.4 (gdb) bt

0 0x00007ffff7b6ae50 in _linear_draw_sprite32 ()

from /usr/lib/liballeg.so.4.4

attuska commented 6 years ago

https://github.com/dougmencken/HeadOverHeels/commit/27e9822b5a6b74842ba20e6b0bbbd968459f89d0

( allegro::drawSprite ) raw image of floor tile at cx=6 cy=1 via FloorTile::draw ( allegro::drawSprite ) raw image of floor tile at cx=6 cy=2 via FloorTile::draw ( allegro::destroyBitmap ) shady image of floor tile at cx=6 cy=3 via FloorTile::setShadyImage ( allegro::drawSprite ) shady image of floor tile at cx=6 cy=3 via FloorTile::draw ( allegro::destroyBitmap ) shady image of floor tile at cx=6 cy=3 via FloorTile::setShadyImage

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0x00007ffff7b6ae50 in _linear_draw_sprite32 () from /usr/lib/liballeg.so.4.4

dougmencken commented 6 years ago

does it crash yet on _drawsprite with updated wrappers https://github.com/dougmencken/HeadOverHeels/commit/5b825a23adecd9c189e6fadf834d20462e9dfa7b or not?

--- a/src/WrappersAllegro.hpp
+++ b/src/WrappersAllegro.hpp
@@ -28,7 +28,10 @@
  */
 inline void drawSprite( BITMAP* view, BITMAP* sprite, int x, int y, const std::string& printMe = "" )
 {
+        if ( sprite == NULL ) return ;
+
         if ( ! printMe.empty() ) std::cout << "( allegro::drawSprite ) " << printMe << std::endl ;
+
         draw_sprite( view, sprite, x, y );
 }

@@ -38,8 +41,12 @@
  */
 inline void destroyBitmap( BITMAP*& bitmap, const std::string& printMe = "" )
 {
+        if ( bitmap == NULL ) return ;
+
         if ( ! printMe.empty() ) std::cout << "( allegro::destroyBitmap ) " << printMe << std::endl ;
+
         destroy_bitmap( bitmap );
+        bitmap = NULL ;
 }

 }
dougmencken commented 6 years ago

uhmmm

( allegro::drawSprite ) raw image of floor tile at cx=2 cy=2 via FloorTile::draw
( allegro::drawSprite ) raw image of floor tile at cx=2 cy=3 via FloorTile::draw
( allegro::drawSprite ) raw image of floor tile at cx=2 cy=4 via FloorTile::draw
( allegro::drawSprite ) shady image of floor tile at cx=2 cy=5 via FloorTile::draw
( allegro::destroyBitmap ) shady image of floor tile at cx=2 cy=5 via FloorTile::setShadyImage
Bus error

Thread 1 Crashed:
0   headoverheels   0x0000d3d0 draw_sprite + 44
1   headoverheels   0x0000e350 allegro::drawSprite(BITMAP*, BITMAP*, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 156
2   headoverheels   0x0000de18 isomot::FloorTile::draw(BITMAP*) + 160
3   headoverheels   0x00078868 isomot::Room::draw(BITMAP*) + 508
4   headoverheels   0x00058390 isomot::Room::drawRoom() + 60
5   headoverheels   0x000549e8 isomot::Isomot::update() + 5128
attuska commented 6 years ago

https://github.com/dougmencken/HeadOverHeels/commit/5b825a23adecd9c189e6fadf834d20462e9dfa7b

( allegro::drawSprite ) raw image of floor tile at cx=2 cy=3 via FloorTile::draw ( allegro::drawSprite ) shady image of floor tile at cx=2 cy=4 via FloorTile::draw ( allegro::destroyBitmap ) shady image of floor tile at cx=2 cy=4 via FloorTile::setShadyImage ( allegro::destroyBitmap ) shady image of floor tile at cx=2 cy=5 via FloorTile::setShadyImage ( allegro::destroyBitmap ) shady image of floor tile at cx=3 cy=4 via FloorTile::setShadyImage ( allegro::destroyBitmap ) shady image of floor tile at cx=3 cy=5 via FloorTile::setShadyImage

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4 (gdb) bt

0 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4

attuska commented 6 years ago

With this patch there is no segmentation error. I've played it until penetrary. These commit is patched: https://github.com/dougmencken/HeadOverHeels/commit/af452f5d4775ffdd896e3e76ff8ffefdd97abdf8 good.diff.zip

attuska commented 6 years ago

Brrrrr.... With the patch this: https://github.com/dougmencken/HeadOverHeels/commit/5b825a23adecd9c189e6fadf834d20462e9dfa7b is not good, again segmentation fault. In fact, this is not good either: https://github.com/dougmencken/HeadOverHeels/commit/db9b7ac109ffae0c6401665aff689faa3332fad9

Aberration... What I thought good was not good. Again is segmentation fault with patched https://github.com/dougmencken/HeadOverHeels/commit/af452f5d4775ffdd896e3e76ff8ffefdd97abdf8

parse "/home/attila/.headoverheels/savegame/save7.xml" save "/home/attila/.headoverheels/savegame/save8.xml" is yet free save "/home/attila/.headoverheels/savegame/save9.xml" is yet free save "/home/attila/.headoverheels/savegame/save10.xml" is yet free ~~ done with action ContinueGame

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0x080a20ca in ?? ()

dougmencken commented 6 years ago

I can’t repeat segfault on load ( on save? ) of game on my side. And 0x080a20ca in ?? () says nothing to me, I need names of functions, and some deeper lines of backtrace too

attuska commented 6 years ago

I do not know how to make such a more accurate debuginfo, but I really need to do that. Yours are much deeper than mine. I'm just desperate.

dougmencken commented 6 years ago

Configure with --enable-debug, make, and then gdb’s bt would print the whole stack of call chain. And what are you doing before that crash? Eating fish to save game? Using “escape” key on screen with saved games? Looks like the latter, but on my side it’s okay

here’s existing screen for action " CreateListOfSavedGames "
Screen::loadAnimation( "head.gif" ) got 18 frames
Screen::loadAnimation( "heels.gif" ) got 16 frames
parse "/Users/me/.headoverheels/savegame/save1.xml"
parse "/Users/me/.headoverheels/savegame/save2.xml"
parse "/Users/me/.headoverheels/savegame/save3.xml"
parse "/Users/me/.headoverheels/savegame/save4.xml"
parse "/Users/me/.headoverheels/savegame/save5.xml"
parse "/Users/me/.headoverheels/savegame/save6.xml"
parse "/Users/me/.headoverheels/savegame/save7.xml"
parse "/Users/me/.headoverheels/savegame/save8.xml"
parse "/Users/me/.headoverheels/savegame/save9.xml"
parse "/Users/me/.headoverheels/savegame/save10.xml"
escape action ContinueGame ~~
GameManager::resume ()
( allegro::drawSprite ) raw image of floor tile at cx=0 cy=1 via FloorTile::draw
( allegro::drawSprite ) raw image of floor tile at cx=0 cy=2 via FloorTile::draw

As for crash on drawing+destroying images of floor tiles, take this patch

--- a/src/Mediator.cpp
+++ b/src/Mediator.cpp
@@ -291,7 +291,7 @@ void Mediator::reshadeWithGridItem( GridItem* item )
         // shade floor in this column, if any
         if ( room->floor[ column ] != nilPointer )
         {
-                room->floor[ column ]->binShadyImage();
+////////                room->floor[ column ]->binShadyImage();
                 room->floor[ column ]->setWantShadow( true );
         }
 }
@@ -328,7 +328,7 @@ void Mediator::reshadeWithFreeItem( FreeItem* item )
                         // shade floor in this column, if any
                         if ( room->floor[ column ] != nilPointer )
                         {
-                                room->floor[ column ]->binShadyImage();
+////////                                room->floor[ column ]->binShadyImage();
                                 room->floor[ column ]->setWantShadow( true );
                         }
                 }
dougmencken commented 6 years ago

I updated master too https://github.com/dougmencken/HeadOverHeels/commit/b2fc6b1854ed33c38997fd0c13ce2dfd866dbccf

dougmencken commented 6 years ago

But this introduced some lack of update of tiles’ shadows, see #29

tints after disappear

attuska commented 6 years ago

I tried the master. The --enable-debug option has already written the alsa error. There was a segmentation error with the master in a new game.

( allegro::drawSprite ) raw image of floor tile at cx=6 cy=7 via FloorTile::draw

Thread 2 "headoverheels" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xf6e40b40 (LWP 27764)] 0xf7f2d159 in _mix_some_samples () from /usr/lib/../lib/liballeg.so.4.4 (gdb) bt

0 0xf7f2d159 in _mix_some_samples () from /usr/lib/../lib/liballeg.so.4.4

1 0xf7a7eb4d in alsa_update () from /usr/lib/allegro/4.4.2/alleg-alsadigi.so

2 0xf7f71102 in bg_man_pthreads_threadfunc () from /usr/lib/../lib/liballeg.so.4.4

3 0xf736223a in start_thread () from /lib/libpthread.so.0

4 0xf7212ee6 in clone () from /lib/libc.so.6

(gdb)

And surprise! After renaming the Sounds folder, it was good and then renamed the folder to the old one, with a newer game there was nothing wrong with the sound and the game.

dougmencken commented 6 years ago

And besides fail on playing music ( let’s deal with it later )? There’s no magic button or magic line which would fix any and all of segfaults at once. Is floor tile drawing crash fixed on your side? How’s bout error after ~~ done with action ContinueGame?

attuska commented 6 years ago

I have no idea. Sometimes it is good, sometimes not. But the whole thing is not stable, I can not reconstruct the errors every time. I let the whole thing rest a little bit.

dougmencken commented 6 years ago

Sometimes it is good, sometimes not. But the whole thing is not stable, I can not reconstruct the errors every time.

Yeah, that’s what I name “randomly reproducible”

dougmencken commented 6 years ago

yet I hope that freshShadyImage solved all problems with drawing tiles of floor

attuska commented 6 years ago

Recently the segmentation faults have also disappeared.

dougmencken commented 6 years ago

I’m going to improve wrapper

--- a/src/WrappersAllegro.hpp
+++ b/src/WrappersAllegro.hpp
@@ -48,8 +48,13 @@ inline void destroyBitmap( BITMAP*& bitmap /*~ , const std::string& printMe = ""

         /*~ if ( ! printMe.empty() ) std::cout << "( allegro::destroyBitmap ) " << printMe << std::endl; ~*/

-        destroy_bitmap( bitmap );
+        // nullify it first, then invoke destroy_bitmap
+        // to avoid drawing of being-destroyed thing when there’re many threads
+
+        BITMAP* toBin = bitmap;
         bitmap = NULL ;
+
+        destroy_bitmap( toBin );
 }

 }
attuska commented 6 years ago

And again...

exit coordinates are x=41 y=11 z=0 entry coordinates are x=57 y=159 z=24 character "headoverheels" is yet in room "safari/safari02.xml" copy of character "headoverheels" with behavior "behavior of Head over Heels" is created to rebuild this room [New Thread 0xd1278b40 (LWP 1685)]

Thread 2 "headoverheels" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xf6e40b40 (LWP 1573)] 0xf7f2dde5 in _mix_some_samples () from /usr/lib/../lib/liballeg.so.4.4 (gdb) bt

0 0xf7f2dde5 in _mix_some_samples () from /usr/lib/../lib/liballeg.so.4.4

1 0xf7a7eb4d in alsa_update () from /usr/lib/allegro/4.4.2/alleg-alsadigi.so

2 0xf7f71102 in bg_man_pthreads_threadfunc () from /usr/lib/../lib/liballeg.so.4.4

3 0xf736223a in start_thread () from /lib/libpthread.so.0

4 0xf7212ee6 in clone () from /lib/libc.so.6

(gdb) safari

dougmencken commented 6 years ago

I haven’t yet another solution for crash with ogg playing on begin new game than

--- a/src/Isomot.cpp
+++ b/src/Isomot.cpp
@@ -55,7 +55,7 @@ void Isomot::beginNewGame ()
         mapManager->getActiveRoom()->activate ();

         std::cout << "play new game" << std::endl ;
-        SoundManager::getInstance()->playOgg ( "music/begin.ogg", /* loop */ false );
+        ///////SoundManager::getInstance()->playOgg ( "music/begin.ogg", /* loop */ false );
 }

 void Isomot::continueSavedGame ( const sgxml::players::player_sequence& playerSequence )
attuska commented 6 years ago

patched https://github.com/dougmencken/HeadOverHeels/commit/4637ddc36bcbc201962730726c0cbd6b3cb36f27 new game:

character "head" is yet active in room "blacktooth/blacktooth20.xml" copy of character "head" with behavior "behavior of Head" is created to rebuild this room [New Thread 0xd282fb40 (LWP 14725)] [New Thread 0xc7dabb40 (LWP 14726)] playing Ogg music/blacktooth.ogg [Thread 0xc7dabb40 (LWP 14726) exited]

Thread 1 "headoverheels" received signal SIGSEGV, Segmentation fault. 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4 (gdb) bt

0 0xf7f61340 in _linear_draw_sprite32 () from /usr/lib/../lib/liballeg.so.4.4

1 0x08056f3c in ?? ()

old, loaded game:

character "heels" is yet active in room "blacktooth/blacktooth60.xml" [New Thread 0xd23e1b40 (LWP 14883)] [New Thread 0xd0a77b40 (LWP 14884)] playing Ogg music/blacktooth.ogg

Thread 16 "headoverheels" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xd23e1b40 (LWP 14883)] 0x0809f198 in ?? ()

dougmencken commented 6 years ago

As for playing Oggs... This one

[New Thread 0xc7dabb40 (LWP 14726)]
playing Ogg music/blacktooth.ogg
[Thread 0xc7dabb40 (LWP 14726) exited]

is okay, player’s thread was created and exited

But this

[New Thread 0xd0a77b40 (LWP 14884)]
playing Ogg music/blacktooth.ogg

Thread 16 "headoverheels" received signal SIGSEGV

means it cannot finish by whatever reason. Interesting is that previous one https://github.com/dougmencken/HeadOverHeels/issues/25#issuecomment-375959427 didn’t print “ playing Ogg ”, so it may be something wrong between oggThread = alogg_create_thread( this->oggStream ); and std::cout << " Ogg " << fileName << std::endl ; inside src/SoundManager.cpp

As for another crash on _drawsprite... Maybe dealing just with floor tiles ignoring other elements weren’t enough... Can’t repeat it on my side yet

dougmencken commented 6 years ago

@attuska may you reproduce these fails with current master?

attuska commented 6 years ago

I needed to compile a new package: tinyxml2. (https://github.com/leethomason/tinyxml2/archive/6.0.0.tar.gz) I can not do anything, the game is unobtrusively fast.

dougmencken commented 6 years ago

Yeah, I’m replacing monstrous xerces-c with little tinyxml2

What do you mean as “unobtrusively fast”? Like that timers don’t work? That’s probably due to parsing of floating-point values like speed="0.030", which is in seconds, via atof. And this may rise a problem with decimal separators, I dunno which is used in magyar’s locale, maybe not “.” but “,” or whatever. I think about converting that to milliseconds, as example speed="30"

Plus I renamed files of game’s rooms, so previous saves don’t work anymore

dougmencken commented 6 years ago

Yep, it is the problem

atof and strtod are locale dependant

on systems where locale defines comma as decimal separator, atof function ignores period and whole fraction part

Patch

--- a/src/ItemDataManager.cpp
+++ b/src/ItemDataManager.cpp
@@ -62,15 +62,24 @@ void ItemDataManager::loadItems ()

                 // how long, in milliseconds, it falls
                 tinyxml2::XMLElement* weight = item->FirstChildElement( "weight" ) ;
-                newItem->weight = std::atof( weight->FirstChild()->ToText()->Value() ) ;
+                if ( weight != nilPointer )
+                        newItem->weight = static_cast< double >( std::atoi( weight->FirstChild()->ToText()->Value() ) ) / 1000.0 ;
+                else
+                        newItem->weight = 0.0 ;

                 // delay, in milliseconds, between frames in animation sequence
                 tinyxml2::XMLElement* framesDelay = item->FirstChildElement( "framesDelay" ) ;
-                newItem->delayBetweenFrames = std::atof( framesDelay->FirstChild()->ToText()->Value() ) ;
+                if ( framesDelay != nilPointer )
+                        newItem->delayBetweenFrames = static_cast< double >( std::atoi( framesDelay->FirstChild()->ToText()->Value() ) ) / 1000.0 ;
+                else
+                        newItem->delayBetweenFrames = 0.0 ;

                 // how many milliseconds this item moves one single isometric unit
                 tinyxml2::XMLElement* speed = item->FirstChildElement( "speed" ) ;
-                newItem->speed = std::atof( speed->FirstChild()->ToText()->Value() ) ;
+                if ( speed != nilPointer )
+                        newItem->speed = static_cast< double >( std::atoi( speed->FirstChild()->ToText()->Value() ) ) / 1000.0 ;
+                else
+                        newItem->speed = 0.0 ;

                 {
                         tinyxml2::XMLElement* picture = item->FirstChildElement( "picture" ) ;