Errors compiling 0.4 on OpenBSD

For all the help you need with Armagetron!
ubuntu_dpg
Posts: 8
Joined: Thu Dec 23, 2010 5:45 pm

Re: Errors compiling 0.4 on OpenBSD

Post by ubuntu_dpg »

I also observed a bug like this lately (crashes instantly), but for me it was fixed with the latest bzr revision from launchpad. Perhaps it works for you as well?
ubuntu_dpg
Posts: 8
Joined: Thu Dec 23, 2010 5:45 pm

Re: Errors compiling 0.4 on OpenBSD

Post by ubuntu_dpg »

I just took a quick look at this, can you test if the following patch fixes the issue?

Code: Select all

=== modified file 'src/tools/tMutex.cpp'
--- src/tools/tMutex.cpp	2011-08-24 21:13:01 +0000
+++ src/tools/tMutex.cpp	2016-06-03 15:38:35 +0000
@@ -73,8 +73,10 @@
         // TODO: error checking
         pthread_mutexattr_t mta;
         
+        pthread_mutexattr_init(&mta);
         pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE);
         pthread_mutex_init(&mutex_, &mta);
+        pthread_mutexattr_destroy(&mta);
 #endif
     }
 }
I think this worked on linux because `pthread_mutexattr_t` is not dynamically allocated on linux, but it is on OpenBSD. Also, you'll only hit this bug if you compile with a headers-only boost library, because otherwise you'll use boost's thread implementation and not this stub.
User avatar
Z-Man
God & Project Admin
Posts: 11585
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: Errors compiling 0.4 on OpenBSD

Post by Z-Man »

That looks like it was written by someone who reads documentation. I integrated it already, even if it does not fix this particular issue, it's clearly more correct.
Following tradition: How do you want to be credited in AUTHORS?
ubuntu_dpg
Posts: 8
Joined: Thu Dec 23, 2010 5:45 pm

Re: Errors compiling 0.4 on OpenBSD

Post by ubuntu_dpg »

Z-Man wrote:Following tradition: How do you want to be credited in AUTHORS?
You can use my alias <|tux for that.
Monkey
Match Winner
Posts: 759
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

It works. It actually works. Ok, deep breaths. I must calm down. Nope, can't calm down :D

Thankyou very, very much! :D

I don't suppose there's a similar fix for when it crashes when I attempt to view the master server browser using the game client? That would really, really be awesome...
Playing since December 2006
ubuntu_dpg
Posts: 8
Joined: Thu Dec 23, 2010 5:45 pm

Re: Errors compiling 0.4 on OpenBSD

Post by ubuntu_dpg »

If you have a stacktrace from a crash, I could take a look.
Monkey
Match Winner
Posts: 759
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

Code: Select all

(gdb) run
Starting program: /usr/local/bin/armagetronad 

Program received signal SIGABRT, Aborted.
[Switching to thread 1031966]
0x00001147e175594a in thrkill () at <stdin>:2
2       <stdin>: No such file or directory.
        in <stdin>
Current language:  auto; currently asm
(gdb) bt
#0  0x00001147e175594a in thrkill () at <stdin>:2
#1  0x00001147e17034d9 in *_libc_abort () at /usr/src/lib/libc/stdlib/abort.c:52
#2  0x0000114830adb675 in *_libpthread_pthread_mutex_unlock (mutexp=Variable "mutexp" is not available.
) at /usr/src/lib/librthread/rthread_sync.c:223
#3  0x00001145c89518f3 in tBackgroundSync::~tBackgroundSync () from /usr/local/bin/armagetronad
#4  0x00001145c88de9b5 in boost::thread::run<tMemberFunctionRunnerTemplate<nDNSResolver> > () from /usr/local/bin/armagetronad
#5  0x0000114830adfeee in _rthread_start (v=Variable "v" is not available.
) at /usr/src/lib/librthread/rthread.c:115
#6  0x00001147e1764ebb in __tfork_thread () at /usr/src/lib/libc/arch/amd64/sys/tfork_thread.S:75
#7  0x0000000000000000 in ?? ()
(gdb) 
Playing since December 2006
User avatar
Lucifer
Project Developer
Posts: 8640
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas
Contact:

Re: Errors compiling 0.4 on OpenBSD

Post by Lucifer »

It's still a threading issue. Isn't there an option to build without multi-threading? I know it was there at some time, but it may have been removed (I also remember that the threading library we used stopped being maintained, and there were changes because of that).
Image

Be the devil's own, Lucifer's my name.
- Iron Maiden
Monkey
Match Winner
Posts: 759
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

I've looked through the configure script's options and the only one that mentions threads is:

Code: Select all

--enable-binreloc-threads Compile binary relocation with threads support (default=yes)
Also, correct me if I'm wrong but doesn't boost provide some multithreading capabilities? If so, I could try compiling without boost although I'm guessing boost is used for more than just multithreading?
Playing since December 2006
User avatar
Z-Man
God & Project Admin
Posts: 11585
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: Errors compiling 0.4 on OpenBSD

Post by Z-Man »

You won't be able to compile arma completely without boost, some of its libraries are required (shared_ptr and any are the ones I remember). boost-threads is opional; the code tux fixed was in the fallback part that is only active if you don't have boost-threads installed.

So: Uninstalling boost entirely: bad idea.
But installing boost-threads in a development version (then running arma's configure script again): That may fix your problems. It won't fix our apparently still broken fallback code, but that's our problem.
Monkey
Match Winner
Posts: 759
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

I've just tried to compile the latest 0.4 (bzr revno 1603) on OpenBSD and it fails. Details of the error(s):

Code: Select all

g++ -DHAVE_CONFIG_H -I. -I..   -I/usr/local/include/libxml2 -I/usr/local/include -I/usr/local/include -I/usr/local/include/SDL2 -I/usr/X11R6/include -D_REENTRANT -I/usr/X11R6/include -I/usr/local/include/libpng16 -I/usr/local/include -I/usr/local/include/FTGL -I/usr/X11R6/include/freetype2 -I/usr/X11R6/include/freetype2   -I./tools -I./resource -I./thirdparty/mathexpr -I./thirdparty/utf8 -I./protobuf -Iprotobuf  -I./network -O2 -I/usr/X11R6/include -MT network/libnetwork_a-nAuthentication.o -MD -MP -MF network/.deps/libnetwork_a-nAuthentication.Tpo -c -o network/libnetwork_a-nAuthentication.o `test -f 'network/nAuthentication.cpp' || echo './'`network/nAuthentication.cpp
In file included from network/nAuthentication.cpp:35:
network/nNetwork.h:833: error: expected constructor, destructor, or type conversion before '<' token
In file included from network/nAuthentication.cpp:38:
network/nServerInfo.h:104: error: ISO C++ forbids declaration of 'unique_ptr' with no type
network/nServerInfo.h:104: error: invalid use of '::'
network/nServerInfo.h:104: error: expected ';' before '<' token
gmake[3]: *** [Makefile:2188: network/libnetwork_a-nAuthentication.o] Error 1
gmake[3]: Leaving directory '/root/archive/armagetronad/0.4/src'
gmake[2]: *** [Makefile:4145: all-recursive] Error 1
gmake[2]: Leaving directory '/root/archive/armagetronad/0.4/src'
gmake[1]: *** [Makefile:768: all-recursive] Error 1
gmake[1]: Leaving directory '/root/archive/armagetronad/0.4'
gmake: *** [Makefile:560: all] Error 2
A fix would be appreciated :)
Playing since December 2006
User avatar
vov
Match Winner
Posts: 568
Joined: Thu Feb 17, 2011 8:40 pm

Re: Errors compiling 0.4 on OpenBSD

Post by vov »

Maybe the compiler doesn't eat the "std::unique_ptr< type > variable" declaration with the spaces there; could be confusing it with the < and > operators. Before the last code change it used std::auto_ptr there which doesn't seem to have </> operators at all.
User avatar
Z-Man
God & Project Admin
Posts: 11585
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: Errors compiling 0.4 on OpenBSD

Post by Z-Man »

No, whitespace can't be the issue. It's unique_ptr is new in the C++11 standard, and gcc assumes we're using an earlier one. Odd. There should be a -std=c++11 command line switch indicating our preference there, configure is supposed to add it. And configure is supposed to automatially get rerun if it changes...
Can you manually rerun configure and see if that fixes things? If not, please post configure.log.

Background: auto_ptr had really unintuitive semantics; it's copy operator had a non-const-reference source argument and invalidated the source. Therefore was deprecated in C++11 now that move semantics are awailable. GCC 6 now uses C++11 as default standard, that's what raised the issue in the form of a torrent of warnings. Plus, C++11 is an awesome step forward and should be supported everywhere by now.

By the way, code::blocks compilation on windows 0.4 should fail right now with the same error. I need to adapt the project settings still.
User avatar
vov
Match Winner
Posts: 568
Joined: Thu Feb 17, 2011 8:40 pm

Re: Errors compiling 0.4 on OpenBSD

Post by vov »

Ah, nice to know. Always good to learn stuff like that. :D
Monkey
Match Winner
Posts: 759
Joined: Thu May 22, 2008 12:36 am
Location: England, UK

Re: Errors compiling 0.4 on OpenBSD

Post by Monkey »

Ok, so still no joy but I think I've found the (or at least a) problem. OpenBSD uses gcc/g++ version 4.2.1 by default which seems to date from 2007 (too early for C++11). I'll install the newest g++ from OpenBSD's packages repository and see if that supports C++11.

Just for you to chew over while I'm doing that, here is config.log, which I've called config.txt because "the extension log is not allowed" :P
config.txt
(92.88 KiB) Downloaded 182 times
Playing since December 2006
Post Reply