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

stack smashing detected; terminated #5

Closed
jws-ghb opened this issue Dec 15, 2021 · 11 comments
Closed

stack smashing detected; terminated #5

jws-ghb opened this issue Dec 15, 2021 · 11 comments

Comments

@jws-ghb
Copy link

jws-ghb commented Dec 15, 2021

After some challenges building from the github repo (which may admittedly be the source of my problem here) on pop_os 21.10 I've managed to get to a complete build, but now the xu4 binary aborts with

$ ./src/xu4 
*** stack smashing detected ***: terminated
Aborted (core dumped)

The build is mostly clean with a few warnings of the type:

warning: format not a string literal and no format arguments

but no other errors.

Dependencies were satisfied as follows:

From system packages:
libsdl2-2.0-0
libsdl2-dev
libxml2
libxml2-dev
liballegro5.2
liballegro5-dev

From sourceforge:
libboron https://sourceforge.net/p/urlan/boron/code/ci/master/tree/

any suggestions would be much appreciated

@WickedSmoke
Copy link
Contributor

WickedSmoke commented Dec 16, 2021 via email

@jws-ghb
Copy link
Author

jws-ghb commented Dec 16, 2021

The compiler is gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2)

No configure options.

The binary from .net does not crash with the same error, but complains:
u4: error: Unable to initialize Allegro

@WickedSmoke
Copy link
Contributor

WickedSmoke commented Dec 16, 2021 via email

@jws-ghb
Copy link
Author

jws-ghb commented Dec 16, 2021

These are the liballegro packages installed:

liballegro-acodec5-dev/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-acodec5.2/impish,now 2:5.2.6.0-3 amd64 [installed]
liballegro-audio5-dev/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-audio5.2/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-dialog5-dev/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-dialog5.2/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-image5-dev/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-image5.2/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-physfs5-dev/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-physfs5.2/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-ttf5-dev/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-ttf5.2/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-video5-dev/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro-video5.2/impish,now 2:5.2.6.0-3 amd64 [installed,automatic]
liballegro4-dev/impish 2:4.4.3.1-2 amd64
liballegro4.4/impish 2:4.4.3.1-2 amd64
liballegro5-dev/impish,now 2:5.2.6.0-3 amd64 [installed]
liballegro5.2/impish,now 2:5.2.6.0-3 amd64 [installed]

$xu4 -h provides normal output (from both my repo build and the downloaded version), but the other options still core:

xu4: Ultima IV Recreated
v1.1svn (Dec 16 2021)

Options:
      --filter <string>   Specify display filtering options.
  -f, --fullscreen        Run in fullscreen mode.
  -h, --help              Print this message and quit.
  -i, --skip-intro        Skip the intro. and load the last saved game.
  -p, --profile <string>  Use another set of settings and save files.
  -q, --quiet             Disable audio.
  -s, --scale <int>       Specify scaling factor (1-5).
  -v, --verbose           Enable verbose console output.

Filters: point, 2xBi, 2xSaI, Scale2x

Homepage: http://xu4.sourceforge.com

$ ./xu4 
*** stack smashing detected ***: terminated
Aborted (core dumped)

xu4 -v finds/opens it's dependencies before crashing, fwiw.

Thanks for walking me through this.

@WickedSmoke
Copy link
Contributor

WickedSmoke commented Dec 16, 2021 via email

@jws-ghb
Copy link
Author

jws-ghb commented Dec 16, 2021

I'll try building Allegro 5.2.7 from source, the base repo doesn't have that build yet, and the PPA from Allegro doesn't have impish builds.

The -v output is:

$ ./xu4 -v
u4upgrad.zip successfully found
trying to open ././ultima4-1.01.zip
trying to open ./u4/ultima4-1.01.zip
trying to open ./ultima4/./ultima4-1.01.zip
trying to open ./ultima4/u4/ultima4-1.01.zip
trying to open /usr/lib/u4/./ultima4-1.01.zip
trying to open /usr/lib/u4/u4/ultima4-1.01.zip
trying to open /usr/local/lib/u4/./ultima4-1.01.zip
trying to open /usr/local/lib/u4/u4/ultima4-1.01.zip
ultima4-1.01.zip not found
ultima4.zip successfully found
looking for AVATAR.EXE
AVATAR.EXE found in ultima4.zip
looking for u4vga.pal
u4vga.pal found in u4upgrad.zip
looking for ega.drv
ega.drv found in ultima4.zip
*** stack smashing detected ***: terminated
Aborted (core dumped)

@WickedSmoke
Copy link
Contributor

WickedSmoke commented Dec 16, 2021 via email

@WickedSmoke
Copy link
Contributor

If you can't debug the program here's a patch to narrow down the point of failure. Based upon the verbose log, configInit() is probably failing.

diff --git a/src/xu4.cpp b/src/xu4.cpp
index 89d2decc..ed3e5242 100644
--- a/src/xu4.cpp
+++ b/src/xu4.cpp
@@ -194,13 +194,19 @@ void servicesInit(XU4GameServices* gs, Options* opt) {
 
     Debug::initGlobal("debug/global.txt");
 
+    if (verbose) printf("service: config\n");
     gs->config = configInit();
+
+    if (verbose) printf("service: screen\n");
     screenInit();
     Tile::initSymbols(gs->config);
 
-    if (! (opt->flags & OPT_NO_AUDIO))
+    if (! (opt->flags & OPT_NO_AUDIO)) {
+        if (verbose) printf("service: sound\n");
         soundInit();
+    }
 
+    if (verbose) printf("service: EventHandler\n");
     gs->eventHandler = new EventHandler(1000/gs->settings->gameCyclesPerSecond,
                             1000/gs->settings->screenAnimationFramesPerSecond);

@jws-ghb
Copy link
Author

jws-ghb commented Dec 16, 2021

Confirmed your suspicion about configInit():

$ ./xu4 -v
u4upgrad.zip successfully found
trying to open ././ultima4-1.01.zip
trying to open ./u4/ultima4-1.01.zip
trying to open ./ultima4/./ultima4-1.01.zip
trying to open ./ultima4/u4/ultima4-1.01.zip
trying to open /usr/lib/u4/./ultima4-1.01.zip
trying to open /usr/lib/u4/u4/ultima4-1.01.zip
trying to open /usr/local/lib/u4/./ultima4-1.01.zip
trying to open /usr/local/lib/u4/u4/ultima4-1.01.zip
ultima4-1.01.zip not found
ultima4.zip successfully found
looking for AVATAR.EXE
AVATAR.EXE found in ultima4.zip
looking for u4vga.pal
u4vga.pal found in u4upgrad.zip
looking for ega.drv
ega.drv found in ultima4.zip
service: config
*** stack smashing detected ***: terminated
Aborted (core dumped)

I have made some progress (of a sort). Muddling my way around gdb (in over my head, in case it wasn't obvious) it looked like init was stepping through some libboron "stuff". I had also seen in the makefiles that some of that was avoided if I used the ./configure --xml flag, so I gave that a shot against a clean clone from github. There was a build failure with line 5 of src/xu4.h looking for a "notify.h" file that appeared to be in the support directory, so I changed it to #include "support/notify.h" and the build succeeded. The resulting build succeeded and runs, but crashes out after character generation with an xml validation error several pages of (probably expected?) "No declaration for " messages :

$ ./src/xu4 
xu4: warning: xml validation error:
No declaration for element armors
No declaration for element armor
...<SNIP>...
No declaration for attribute damage of element weapon
No declaration for attribute magic of element weapon

party.cpp:tileForClass:488: assertion `klass < 8' failed. invalid class 255 in tileForClass

Stack trace:
./src/xu4(_ZN11PartyMember12tileForClassEi+0xb8) [0x5562ab3293f6]
./src/xu4(_ZN11PartyMemberC1EP5PartyP20SaveGamePlayerRecord+0x43) [0x5562ab327e45]
./src/xu4(_ZN5PartyC1EP8SaveGame+0x121) [0x5562ab32963b]
./src/xu4(_ZN14GameController11initContextEv+0x311) [0x5562ab2e9935]
./src/xu4(_ZN14GameController7presentEv+0x70) [0x5562ab2e9510]
./src/xu4(_ZN12EventHandler13runControllerEP10Controller+0x2b) [0x5562ab2e2979]
./src/xu4(main+0x1db) [0x5562ab35654e]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dfd0) [0x7fea124c2fd0]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x7d) [0x7fea124c307d]
Aborted (core dumped)

That seems to be a detour from the original issue, but thought it might help narrow things down at least to know that cutting out boron changes things significantly. Happy to provide more specific gdb output (or the core file) if that's helpful.

@WickedSmoke
Copy link
Contributor

I installed a Pop!_OS VM and tracked down the issue. This is a Boron bug which I have just pushed a fix for. The Makefile was also broken on Pop! and a shared library (the default) got installed into the wrong directory. Thanks for your report.

I have also asked @SiegeLord to update the PPA for Ubuntu 21.10.

@jws-ghb
Copy link
Author

jws-ghb commented Dec 16, 2021

Thanks for your guidance and for tracking the bug down. I look forward to some classic Ultima nostalgia!

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

No branches or pull requests

2 participants