Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old February 19, 2015, 16:32   #61
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,372
AnonymousHero is on a distinguished road
Quote:
Originally Posted by Nick View Post
ssize_t is not C standard (it's POSIX standard), so we should be using int. get.c and get.h are not included in the standard buildsystem build, and will probably go from the codebase altogether.
I would suggest using typedefs on WINDOWS instead. (OK, ssize_t is a bit weird, but for uint8_t, etc. I would still suggest typedefs and using typedefs only on WINDOWS.)

Also, about the pointer bits: See my post about -fsanitize. (Will require a semi-recent GCC/Clang, i.e. something released in the last two years, or thereabouts.)
AnonymousHero is offline   Reply With Quote
Old February 19, 2015, 21:42   #62
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 55
Posts: 8,671
Donated: $60
Nick will become famous soon enough
Quote:
Originally Posted by AnonymousHero View Post
What you want for practical applications is to just add

-fsanitize=undefined
-fsanitize=address

to the clang/gcc command line. It's runtime checking, but the fact that it only points out real errors that you actually hit in the game means that it's actually humanly possible to actually fix all the issues.
Thanks, I had actually seen this in the PosCheng thread and looked into it a little.

The main issue with Windows is just that we don't have any of the dev team compiling on it routinely at the moment, and our autobuilders are nearly all Linux too. On the plus side, the one that isn't is OpenBSD...
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old February 19, 2015, 21:57   #63
chris
PosChengband Maintainer
 
Join Date: Jan 2008
Posts: 702
chris is on a distinguished road
Quote:
Originally Posted by AnonymousHero View Post
What you want for practical applications is to just add

-fsanitize=undefined
-fsanitize=address

to the clang/gcc command line. It's runtime checking, but the fact that it only points out real errors that you actually hit in the game means that it's actually humanly possible to actually fix all the issues.
My gcc does not recognize -fsanitize=undefined? (gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2)

Also, the output is hideous:
Code:
                                                        #3 0x5a57af (/home/chris/Src/poschengband/poschengband+0x5a57af)
                                                                                                                            #4 0x5a904a (/home/chris/Src/poschengband/poschengband+0x5a904a)
                          #5 0x9ed773 (/home/chris/Src/poschengband/poschengband+0x9ed773)
                                                                                              #6 0x7fb93812cec4 (/lib/x86_64-linux-gnu/libc-2.19.so+0x21ec4)
                                                                                                                                                                #7 0x403828 (/home/chris/Src/poschengband/poschengband+0x403828)
                                                          Address 0x7fff0742c4e1 is located at offset 113 in frame <Term_text_gcu> of T0's stack:
You see no visible monsters.                                                                                                                       This frame has 1 object(s): a granite wall blocking your way. <x2>
You have    [32, 113) 'text'.
The Blinking dot blinks awayHINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
Autosaving the game...                                                                                                                     (longjmp and C++ exceptions *are* supported)e surface.
Target Aborted.  Shadow bytes around the buggy address:
                                                         0x100060e7d840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                                                                                                          0x100060e7d850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                     0x100060e7d860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                                                                      0x100060e7d870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                                                                                                                                       0x100060e7d880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1
                                                =>0x100060e7d890: f1 f1 00 00 00 00 00 00 00 00 00 00[01]f4 00 00
                                                                                                                   0x100060e7d8a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
              0x100060e7d8b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                                                               0x100060e7d8c0: 00 00 00 00 f1 f1 f1 f1 01 f4 f4 f4 f2 f2 f2 f2
                                                                                                                                                0x100060e7d8d0: 01 f4 f4 f4 f3 f3 f3 f3 00 00 00 00 00 00 00 00
                                           0x100060e7d8e0: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
                                                                                                          Shadow byte legend (one shadow byte represents 8 application bytes):
          Addressable:           00
                                     Partially addressable: 01 02 03 04 05 06 07 
                                                                                   Heap left redzone:     fa
                                                                                                              Heap righ redzone:     fb
                                                                                                                                         Freed Heap region:     fd
                                                                                                                                                                    Stack left redzone:    f1
                         Stack mid redzone:     f2
                                                    Stack right redzone:   f3
                                                                               Stack partial redzone: f4
                                                                                                          Stack after return:    f5
                                                                                                                                     Stack use after scope: f8
                                                                                                                                                                Global redzone:        f9
                     Global init order:     f6
                                                Poisoned by user:      f7
                                                                           ASan internal:         fe
                                                                                                    ==4654== ABORTING
                                                                                                                     chris@chris-Studio-XPS-1645:~/Src/poschengband >
Any way to clean this up? For my particular issue, simply doing a bt in gdb is much easier, but I have to turn off the -fsanitize=address to actually get a stack dump:
Code:
    *** stack smashing detected ***: /home/chris/Src/poschengband/poschengband terminated

Program received signal SIGABRT, Aborted.
0x00007ffff72c9cc9 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ffff72c9cc9 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff72cd0d8 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff7306f24 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007ffff739e82c in __fortify_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x00007ffff739e7d0 in __stack_chk_fail () from /lib/x86_64-linux-gnu/libc.so.6
#5  0x0000000000672ac1 in Term_text_gcu (x=13, y=48, n=99, a=15 '\017', s=0xa2918d '#' <repeats 99 times>, ' ' <repeats 101 times>...) at main-gcu.c:1125
#6  0x0000000000676069 in Term_fresh_row_text (y=48, x1=0, x2=145) at z-term.c:1052
#7  0x0000000000676804 in Term_fresh () at z-term.c:1422
#8  0x00000000004c1d94 in dungeon (load_game=1 '\001') at dungeon.c:5281
#9  0x00000000004c3535 in play_game (new_game=0 '\000') at dungeon.c:6034
#10 0x000000000067974f in main (argc=1, argv=0x7fffffffdde8) at main.c:779
(gdb)
Help?
chris is offline   Reply With Quote
Old February 19, 2015, 22:59   #64
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,372
AnonymousHero is on a distinguished road
(On a tablet, so forgive the brevity)

Output: there may be an option or env variable you can set to force sanitizer output to a file. If not, I'm pretty sure you can just redirect stderr to a file, eg using "2>1 myfile" as the last part of the command line. (The reason the output is mangled is that ncurses disables newlines on the terminal.)

About the missing "undefined": see the gcc manual, i was workingfrom memory and the option may be a little different, something to do with "undefined behavior". It's possible that the option wasn't available in gcc 4.8.

Generally i'd recommend clang when using the sanitizer since it usually has more recent support. (And is mostly cmdline compatible with gcc.)

EDIT: Sorry, "2>&1 myfile" should obviously have been "2> myfile". Fixed

Last edited by AnonymousHero; February 20, 2015 at 06:26.
AnonymousHero is offline   Reply With Quote
Old February 20, 2015, 00:08   #65
TJS
Swordsman
 
Join Date: May 2008
Posts: 473
TJS is on a distinguished road
Quote:
Originally Posted by Nick View Post
Thanks for picking up all these - I will get to fixing them at some point, but this should keep you going for now.
Great thanks, that's now got me onto the linker errors

I went through the other thread and fixed the linker errors that appeared on there, and changed the names of some functions that were deprecated as recommended:

open to _open
fdopen tp _fdopen
my_mkdir to _mkdir

but I've still got a few linker errors

Error 1 error LNK2019: unresolved external symbol __fopen referenced in function _file_open angband-latest\z-file.obj
Error 2 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup angband-latest\MSVCRTD.lib(crtexew.obj)
TJS is offline   Reply With Quote
Old February 20, 2015, 06:34   #66
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,372
AnonymousHero is on a distinguished road
Quote:
Originally Posted by TJS View Post
Great thanks, that's now got me onto the linker errors

I went through the other thread and fixed the linker errors that appeared on there, and changed the names of some functions that were deprecated as recommended:

open to _open
fdopen tp _fdopen
my_mkdir to _mkdir
Do you mean that you've renamed "open" to "_open" in the .h and .c files? If so, then you've been given bad advice since the C standard reserves all "external" identifiers beginning with an underscore. If you've renamed the other way round, then I'd like to point out that "open" (specifically) is also already taken by POSIX and, as such, your changes could not be accepted upstream (if you're interested in providing pull req's once you get things compiling and running )
AnonymousHero is offline   Reply With Quote
Old February 20, 2015, 19:49   #67
EpicMan
Swordsman
 
Join Date: Dec 2009
Location: Dallas, Texas, USA
Posts: 436
EpicMan is on a distinguished road
Quote:
Originally Posted by TJS View Post
Great thanks, that's now got me onto the linker errors

I went through the other thread and fixed the linker errors that appeared on there, and changed the names of some functions that were deprecated as recommended:

open to _open
fdopen tp _fdopen
my_mkdir to _mkdir

but I've still got a few linker errors

Error 1 error LNK2019: unresolved external symbol __fopen referenced in function _file_open angband-latest\z-file.obj
Error 2 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup angband-latest\MSVCRTD.lib(crtexew.obj)
Error 1 looks like a typo - it looks like you have two underscores in front of fopen. Try changing it to _fopen and see if it works.
EpicMan is offline   Reply With Quote
Old February 23, 2015, 15:14   #68
TJS
Swordsman
 
Join Date: May 2008
Posts: 473
TJS is on a distinguished road
Ok I've managed to get a title screen! Thanks for the help. However the problems documented in this post are still happening in the current version:

http://angband.oook.cz/forum/showpos...&postcount=100

It seems to default to graphical tiles and then screw up in the png_read_info(png_ptr, info_ptr); method.

I can get the game running by changing this line to skip the ReadDIB2_PNG function that crashes:

if (FALSE) { // !ReadDIB2_PNG(data[0].w, buf, &infGraph, NULL, TRUE)) {
plog_fmt("Cannot read file '%s'", name);
return FALSE;
}
The game seems to run, but obviously I've commented out the graphics so you can't see any tiles (is there a way to default to ASCII?).

Also looks like the look rectangle isn't getting deleted when you move it around.

Last edited by TJS; February 23, 2015 at 21:38.
TJS is offline   Reply With Quote
Old February 23, 2015, 20:44   #69
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 55
Posts: 8,671
Donated: $60
Nick will become famous soon enough
Quote:
Originally Posted by TJS View Post
Ok I've managed to get a title screen! Thanks for the help. However the problems documented in this post are still happening in the current version:

http://angband.oook.cz/forum/showpos...&postcount=100
Have you tried the changes to VS settings mentioned later in that thread?
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old February 23, 2015, 21:40   #70
TJS
Swordsman
 
Join Date: May 2008
Posts: 473
TJS is on a distinguished road
Quote:
Originally Posted by Nick View Post
Have you tried the changes to VS settings mentioned later in that thread?
Whoops sorry I suck, I read that whole thread and missed the fix from EpicMan, I've updated the above post to remove stuff that is fixed and left the stuff that's still broken.

Last edited by TJS; February 23, 2015 at 22:47.
TJS is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ladder restructure request OOD Town drunk Vanilla 7 April 4, 2013 17:11
v4 update Magnate v4 10 December 13, 2011 14:40
Ladder Update UglySquirrell Vanilla 2 September 20, 2011 05:50
Quickband update Antoine Variants 11 March 21, 2011 02:26
Help me update PosBand! pampl Development 20 December 27, 2010 19:55


All times are GMT +1. The time now is 16:33.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.