Compiling UOX3 on Raspberry Pi

Found a bug in UOX3? Or experienced a server crash? Perhaps you've noticed a broken feature? Post the details here!
Post Reply
superking144
UOX3 Newbie
Posts: 2
Joined: Fri Jan 15, 2021 2:14 am
Has thanked: 0
Been thanked: 0

Compiling UOX3 on Raspberry Pi

Post by superking144 »

Hi all. First, thanks to all for any help!
I decided to try getting a UOX3 server running on my RPi3 as a pet project. I followed the instructions for compiling the executable from source but I get this error when building SpiderMonkey.

Just like the guide says, I run this command:
make -f Makefile.ref DEFINES=-DHAVE_VA_LIST_AS_ARRAY CC=gcc

Error:
jsprf.c: In function ‘BuildArgArray’:
jsprf.c:62:44: error: subscripted value is neither array nor pointer nor vector
#define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
^
jsprf.c:644:9: note: in expansion of macro ‘VARARGS_ASSIGN’
VARARGS_ASSIGN(nas[cn].ap, ap);
^~~~~~~~~~~~~~
jsprf.c:62:53: error: subscripted value is neither array nor pointer nor vector
#define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
^
jsprf.c:644:9: note: in expansion of macro ‘VARARGS_ASSIGN’
VARARGS_ASSIGN(nas[cn].ap, ap);
^~~~~~~~~~~~~~
make[1]: *** [rules.mk:78: Linux_All_DBG.OBJ/jsprf.o] Error 1
make[1]: Leaving directory '/home/pi/UO/UOX3/spidermonkey'
make: *** [rules.mk:66: all] Error 2


Here's the version I have of GCC and GNUMake:

GCC:

pi@raspberrypi:~/UO/UOX3/spidermonkey $ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/8/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Raspbian 8.3.0-6+rpi1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --prograAnd m-suffix=-8 --program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 8.3.0 (Raspbian 8.3.0-6+rpi1)


Make:

pi@raspberrypi:~/UO/UOX3/spidermonkey $ make --v
GNU Make 4.2.1
Built for arm-unknown-linux-gnueabihf
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


And here's the info on my Linux distro:

pi@raspberrypi:~/UO/UOX3/spidermonkey $ cat /etc/*-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"


Thanks so much!
superking144
UOX3 Newbie
Posts: 2
Joined: Fri Jan 15, 2021 2:14 am
Has thanked: 0
Been thanked: 0

Post by superking144 »

Oh! I also had to make a quick fix to get the compilation that far. Was getting this error before:


jsapi.c: In function ‘JS_ConvertArgumentsVA’:
jsapi.c:267:39: error: cannot convert to a pointer type
JS_ADDRESSOF_VA_LIST(ap))) {
^~~~~~~~~~~~~~~~~~~~
jsapi.c: In function ‘JS_PushArgumentsVA’:
jsapi.c:370:39: error: cannot convert to a pointer type
JS_ADDRESSOF_VA_LIST(ap))) {
^~~~~~~~~~~~~~~~~~~~
make[1]: *** [rules.mk:78: Linux_All_DBG.OBJ/jsapi.o] Error 1
make[1]: Leaving directory '/home/pi/UO/UOX3/spidermonkey'
make: *** [rules.mk:66: all] Error 2


The fix was changing this line:
#define JS_ADDRESSOF_VA_LIST(ap) ((va_list *)(ap))

to

#define JS_ADDRESSOF_VA_LIST(ap) ((va_list *)&(ap))
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Sounds like a cool pet project! Unfortunately, I have no experience with Raspberry Pi myself, so can't tell you for sure why it's failing to compile, but... did some searching, and I saw posts that indicated that Spidermonkey 1.8.5 and below (we use 1.7) doesn't compile for ARM64v8? Not sure if that's relevant in this case ^^; Sorry I can't be of more help... hope you get it working, though!
-= Ho Eyo He Hum =-
Hughesbuddy
UOX3 Newbie
Posts: 21
Joined: Fri Apr 22, 2022 3:07 am
Has thanked: 0
Been thanked: 2 times

Post by Hughesbuddy »

So i'm running down the same rabbit hole as the OP and I managed to get a little further, but still having problems. I'm not terribly Linux-savvy but here's where i'm at.

1. Had same problem as superking, had to run his example in his second post modifying the JS_ConvertArgumentsVA and that fixed the issue of compiling spidermonkey. So got past that step.
2. Ran into the same issue in superkings first post, i was able to get past this by simply clearing out the "DEFINES=-DHAVE_VA_LIST_AS_ARRAY" part out of the make command, so i ran "make -f Makefile.ref CC=gcc" and i was able to get past that error
3. Next i ran into an error about Segmentation Fault: Malloc.c no such file or directory. I chased this one down and actually ended up having to upgrade my version of raspbian from Buster to bulleseye following the instructions here: https://www.tomshardware.com/how-to/upg ... rom-buster Had to do this i think because there was some issue with GCC version and something something.. but updating Raspbian updated GCC which seemed to handle this Segmentation Fault issue..
4. Now after successfully compiling all components manually following your instructions on the UOX3 guide, i was able to run the uox3 application and it errors out. So i ran gdb ./uox3 to get some details, and it actually partially gets through startup but is erroring out on "Loading JS Scripts" I'm getting:

| Loading JS Scripts
Assertion failure: !OBJ_GET_PROTO(cx, ctor), at jsapi.c:2219

I've tried what i can think of to troubleshoot from here, but i can't get passed this. I can't stack trace any helpful details, i can't download the latest spidermonkey since the latest is not supported only 1.7 is. I'm really running out of ideas and hoping someone can chime in and possibly either know why it's failing or maybe just give me some ideas on how to troubleshoot more myself? Hopefully posting my steps and several workarounds/fixes buys me some karma points for a little help : P Let me know if any logs or additional information would be helpful as well, thanks in advance! Super stoked to get this far and hoping getting a PI-UO server is right around the corner.
Hughesbuddy
UOX3 Newbie
Posts: 21
Joined: Fri Apr 22, 2022 3:07 am
Has thanked: 0
Been thanked: 2 times

Post by Hughesbuddy »

after a ridiculous amount of stumbling around and dredging old posts for help i managed to get UOX3 to compile and load on a raspberry pi 4!! So i'm not entirely sure that i didn't inadvertently break something else but following up to my previous post i made, here were my steps.

1. My last error was
| Loading JS Scripts
Assertion failure: !OBJ_GET_PROTO(cx, ctor), at jsapi.c:2219

To clear this, i found an old bugfix log for Mozilla, and in spidermonkey 1.8 they ended up simply removing this assertion line, so i removed line 2219 above from the jsapi.c file and it cleared passed that error.

2. I then compiled and got a similar but different error barking about an assertion error with JS_ASSERT(!OBJ_GET_PARENT(cx, obj)); inside the jsobj.c file. So this one i could find no change logs or fixes from mozilla, so i did what any good programmer does and simply commented this line out. After recompiling and running uox3 completed! so far i've been able to run it, login, and prebuild the world, no issues yet. If something comes up i'll update, but just wanted to leave this out in the world for all the steps i needed to get UOX3 to work on Raspberry Pi. Thanks for all the nostalgia! It's not Renaissance OSI Pub 15 with a packed Brit bank, but it'll do.
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Wow, good stuff! Could be interesting to see what (if anything) could break from commenting out that line, but maybe that's a worry for future you to fix! ** Congrats on getting it to run on your Raspberry Pi! Good job
-= Ho Eyo He Hum =-
Hughesbuddy
UOX3 Newbie
Posts: 21
Joined: Fri Apr 22, 2022 3:07 am
Has thanked: 0
Been thanked: 2 times

Post by Hughesbuddy »

Already hit a few snags, First world save threw another assertion error for JS_ASSERT(JS_FALSE) in some file, so as before i simply commented and rebuilt, then world saves "fixed". First thing i did was generate a banker at Glow bank (Default world build only generated a tinker there??), first "Bank" call worked, and then threw an error

ERROR: JS script failure: Script Number (3201) Message (out of memory)
| ERROR: Filename: ./js/npc/ai/banker.js
| Line Number: 192
| ERROR: Erroneous Line: (null)
| Token Ptr: (null)


I tried increasing the jsenginesize option in the ini in case it actually was a lack of memory for something, but no dice. I can manually click the banker to open the box, but the call out of "bank" no longer works after throwing the error once. The line #192 seemed to be an innocuous line of code i wouldn't think would throw an error?

stones = stones.toFixed( 2 );

I have a couple other issues/questions, should they be posted elsewhere? Or on Discord perhaps?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Found a fix done to the first assert you commented out (regarding loading of scripts) for SpiderMonkey 1.8.branch. Could try to include those changes and see if it makes any difference in your case?
https://bugzilla.mozilla.org/attachment ... ction=diff

I think for additional issues around specifically running/compiling UOX3 on Raspberry Pi, it would be great to just keep using this thread. For issues/questions not related to that, feel free to open other threads or to throw them out in Discord :)
-= Ho Eyo He Hum =-
Hughesbuddy
UOX3 Newbie
Posts: 21
Joined: Fri Apr 22, 2022 3:07 am
Has thanked: 0
Been thanked: 2 times

Post by Hughesbuddy »

Yep, that's exactly the article i found as well, i just went into the 1.8 and looked at the new .c file and they removed that assert line entirely, so i commented it out. So i guess i didn't realize what those "Attachments" were, seems they show there are other lines to modify, i had just done the final removal of the JS_ASSERT line.. maybe i should properly apply the entire fix.. haha

So i'm tinkering with the Banker.js problem now, we'll see where i get.. Next issue may not be Raspberry Pi related, i don't know. But i wanted to test an externalIP since i have this PI also running an Emby media server, so i bought a Domain and SSL cert and all that. I wanted to use my domain name when connecting through ClassicUO (Or any possible future players). So i added a firewall Port Forward for 2593, i updated uox.ini to include my public IP, i can connect and it gets to the "Loading Shard" screen and hangs. There were other posts regarding this, and they just tweaked the ExternalIP setting, but i've checked through the UOX3 terminal and the Public/Wan IP matches the IP it says my client is connecting from, could there be something else i need to update to get an external connection to work?
- No firewall issues (Gets connected in the first place so it shouldn't be a port redirecting issue)
- Expected IP matches incoming client IP
That was about the extent of possible causes i could find on Forums/Discord. Any thoughts on either of these two?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Hughesbuddy wrote: Sat Apr 30, 2022 4:01 pm [snip}...but i've checked through the UOX3 terminal and the Public/Wan IP matches the IP it says my client is connecting from...[snip}
Just to potentially head off any misunderstanding here... did you put the public IP of your server (correct) in EXTERNALIP setting in the ini file, or the IP of the client (wrong)? Thought I'd ask, just in case.

If that's not the issue, then not sure what could be the reason. You could try having a third party connect and log on, and see if they encounter the same issue?
-= Ho Eyo He Hum =-
Hughesbuddy
UOX3 Newbie
Posts: 21
Joined: Fri Apr 22, 2022 3:07 am
Has thanked: 0
Been thanked: 2 times

Post by Hughesbuddy »

Correct, the public IP of the UO Server. I just said client cause in the UOX terminal you can see the IP of incoming connecting (Which is the public IP of my Router, but they match so not sure what's going on. I AM running the client on a separate box though, i'm running on a laptop that is on the same subnet, so i'll try a different connection (I'll just hookup wifi to the hotspot on my phone quick). I'll see if that has the same results. Is there any sort of debugging or review i can do to see what the program is trying to do? Like a stack trace of if (ExternalIP = IncomingClientIP) or something? or is all that just buried in the app itself?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Hmm. If your laptop is on the same subnet, are you attempting to connect to the public/WAN IP, or the internal LAN IP of your server within the subnet? If it's the former, please try the latter instead? Shard should be accepting incoming connections from LAN already with no further setup changes needed.
-= Ho Eyo He Hum =-
Hughesbuddy
UOX3 Newbie
Posts: 21
Joined: Fri Apr 22, 2022 3:07 am
Has thanked: 0
Been thanked: 2 times

Post by Hughesbuddy »

Yep, connecting via the internal IP 192.168.0.10 works fine as is. The hanging happens on using the public IP of the server.

Huh.. That worked. Connected and went right in when i connected to my hotspot Wifi, and used my public IP for ExternalIP setting in uox.ini and public Domain name for the Server with ClassicUO Launcher (IP works as well). Must be something goofy going on with being on the same network? I guess i see weird stuff like that at work when working with DMZ's, connections from the DMZ to itself won't work, but from other computers they do.. I dunno.. I'll roll with it. Thanks for the suggestion!
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

No worries! Yeah, I think there are sometimes issues in general with attempting to connect to public IP from within the same network. Not sure about the exact reasons (I'm no network engineer) XD; Glad you managed to get it working though.
-= Ho Eyo He Hum =-
Hughesbuddy
UOX3 Newbie
Posts: 21
Joined: Fri Apr 22, 2022 3:07 am
Has thanked: 0
Been thanked: 2 times

Post by Hughesbuddy »

Also fixed the banker issue, changed
stones = stones.toFixed( 2 );
to
stones = stones.toString();

Don't know why the error, but shouldn't be an issue in this instance since stones is filled with a parseInt method, so that drops the decimal anyways, so don't need to add them back in (seems to just allow it to parrot the bank item and stone count)
These users thanked the author Hughesbuddy for the post:
Xuri
punt
VIP
Posts: 244
Joined: Wed Mar 24, 2004 7:46 pm
Has thanked: 0
Been thanked: 9 times

Post by punt »

I think there is misunderstanding of the External ip setting. External ip in UOX3 means the Wan ip. The code looks at the connection and tries to return the closest match to your ip. So if on the same Lan one should connect to the lan ip. I don’t know how you are using the term Public IP, but in Uox3 terms ExternalIp means the wan ip. Any of the ips that Uox3 listens on (which are all of the machine). One should connect to the IP “closest” to the machine you are on
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

I think the name of the setting could be contributing to the confusion, but not sure how else it could be named to address that.
-= Ho Eyo He Hum =-
Hughesbuddy
UOX3 Newbie
Posts: 21
Joined: Fri Apr 22, 2022 3:07 am
Has thanked: 0
Been thanked: 2 times

Post by Hughesbuddy »

No, i don't think the setting is named incorrectly or anything. I guess i just use the term "Public IP", it really is your WAN IP. coming from a software company that has to deal with IT departments for various cities and private businesses, i guess i just hear Public IP more often than WAN IP. The setting makes sense, i guess i was just running into some kind of weird issue with trying to access UOX via a WAN IP when a "Closer" IP would have been available (LAN IP). Here's essentially what i'm doing.

Forgive me if this doesn't work, trying to link a diagram. https://viewer.diagrams.net/?tags=%7B%7 ... 2FAw%3D%3D
Hughesbuddy
UOX3 Newbie
Posts: 21
Joined: Fri Apr 22, 2022 3:07 am
Has thanked: 0
Been thanked: 2 times

Post by Hughesbuddy »

Just throwing in a TL;DR Recap post in here since the steps and fixes are kind of scattered around in the posts above. Note these fixes are unofficial and are simply what I needed to do to compile on a raspberry pi 4, YMMV. To compile UOX3 on a Raspberry PI, the steps are:

1. Ensure your PI is on the latest (At this time, Bullseye) release of Raspbian (Required to fix OP's original problem)
2. Download your UOX3 from Git (Instructions on the UOX3 Site)
3. Modify the following files:
- Modify UOX3\spidermonkey\jsapi.c (Fixes errors on running uox3)
- Comment out line 2219 so it looks like: /*JS_ASSERT(!OBJ_GET_PROTO(cx, ctor));*/
- Modify UOX3\spidermonkey\jsobj.c (Fixes errors on running uox3)
- Comment out line 2576 so it looks like: /*JS_ASSERT(!OBJ_GET_PARENT(cx, obj));*/
4. Run the following terminal commands: (These are the same as UOX3 instructions except for line 2)
cd spidermonkey
make -f Makefile.ref CC=gcc
ar -r libjs32.a Linux_All_DBG.OBJ/*.o
cp Linux_All_DBG.OBJ/jsautocfg.h ./
cd ../zlib
make distclean
./configure
make
cd ../source
make
5. Follow the remainder of the setup from the UOX3 documentation.
"
There were a couple of other edits i made, but i don't think they are required to get things working, there seem to be bugs with the "bank" text function, so i'm not sure yet if they're needed or not.
Post Reply