Hi ports,

Two weeks ago Damien Couderc reported[1] on /r/openbd_gaming that 
games/hedgewars
is broken on 6.0. I did a test on -current back then and found the same thing
planning to test a bit later when I find some time to bump my box to a newer
snapshot.

I finally found some time and behold, it still crashesh with a weird
backtrace[2].

I started digging around and got upstream involved. Together with unC0Rr from
the #hedgewars @ freenode IRC channel we reduced the breaking code to a single
pascal file that fails the same way without any hedgewars code:

$ cat hello.pas
uses GL;
begin
    system.writeln('hello');
end.

Now, the trick is - the failure only occurs if one compiles with:

$ fpc -XLAlua=lua5.1 hello.pas
Free Pascal Compiler version 3.0.0 [2016/12/07] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: OpenBSD for x86-64
Compiling hello.pas
Linking hello
4 lines compiled, 0.3 sec
$ ./hello
An unhandled exception occurred at $0000000223C29C43:
EAccessViolation: Access violation
  $0000000223C29C43

The -XLAlua=lua5.1 line was taken from the build output of our ports system.
There is a way to build a pascal file without passing that flag and it doesn't
lead to broken runtimes, redesigned example:

$ cat code.pas
{$linklib lua5.1}
uses GL;
begin
    system.writeln('hello');
end.
$ fpc code.pas
Free Pascal Compiler version 3.0.0 [2016/12/07] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: OpenBSD for x86-64
Compiling code.pas
Linking code
/usr/local/lib//liblua5.1.so.5.1: warning: warning: rand() may return
deterministic values, is that what you want?
/usr/local/lib//liblua5.1.so.5.1: warning: warning: sprintf() is often misused,
please use snprintf()
/usr/local/lib//liblua5.1.so.5.1: warning: warning: strcat() is almost always
misused, please use strlcat()
/usr/local/lib//liblua5.1.so.5.1: warning: warning: strcpy() is almost always
misused, please use strlcpy()
5 lines compiled, 0.3 sec
$ ./code
hello

Note in this case instead of substituting library name on the command line it's
done in the source code itself with the {$linklib NAME} directive.

I'm roughly looking for some feedback on what might cause such issue.
I think the proper solution is updating the hedgewars CMakeLists.txt in this
case to not use the XLAlua pascal flag and for this port baking it in with
a patch to the source. I am going to work on a diff like that for a separate
email including a hotfix for the -server package but I wanted to share the
actual problem this will remove in case someone can spot a bigger problem.

PS.
While working on the port 2 things happened.

1. Upstream took some of our patches
 http://hg.hedgewars.org/hedgewars/rev/ffc7bb9fde01
2. The -server package didn't build for me and according to hedgewars upstream
it's a ghc bug. FreeBSD ships a workaround patch for it
 
https://svnweb.freebsd.org/ports/head/games/hedgewars/files/patch-CMakeLists.txt?revision=377852&view=markup

This problem manifests itself with the following compile error

[25 of 25] Compiling Main             ( 
/usr/local/pobj/hedgewars-src-0.9.22/hedgewars-src-0.9.22/gameServer/hedgewars-server.hs,
/usr/local/pobj/hedgewars-src-0.9.22/build-amd64/gameServer/Main.o )
*** Core Lint errors : in result of Simplifier ***
<no location info>: Warning:


[1]
https://www.reddit.com/r/openbsd_gaming/comments/5phgho/hedgewars/?st=iyq4oro0&sh=46dea45e
[2]
https://gist.github.com/mulander/b5aa0e825b88910c6d0e446db30dd526t

Reply via email to