SkriptLang / Skript

Skript is a Spigot plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
https://docs.skriptlang.org
GNU General Public License v3.0
1.05k stars 365 forks source link

Skript Not Loading Correctly #2752

Closed LoganLilypad closed 4 years ago

LoganLilypad commented 4 years ago

Question

I am currently trying to run a local test server with Skript and while trying to do so, Skript spits out an error. I am currently running the latest stable Spigot build along with the latest Skript build, even tried running Paper Spigot with no luck and finally tried running it on another computer.

There are no other plugins being ran on the server except Skript Skript error taken from logs https://pastebin.com/raw/dKiCK6Vi

Just wondering if this is just me doing something wrong or if its an actual issue

bensku commented 4 years ago

This could be a bug in Skript. What scripts are you running? Does this happen without them? Also, if you have addons installed, try without them.

LoganLilypad commented 4 years ago

Nope as I said, its just plain Skript, no addons or anything, I just booted up the server without touching anything

bensku commented 4 years ago

Oops, missed no other plugins part. With no scripts either, this is puzzling. Please try removing Skript plugin folder and reinstalling Skript jar; issues like this are sometimes caused by corrupted files.

soulstriker23 commented 4 years ago

Has there been a fix for this? I tried paperspigot 1.15.1 (paper-48) with no other plugins, fresh install for skript 2.5 & 2.4.1 with the same issue.

bluelhf commented 4 years ago

@soulstriker23 Debugging this issue is hard because all the information we get from the stack trace roughly translates to

We were about to run out of space on the stack because something regex-related recursed far too deeply.

So, basically, we have little information to work with, and there isn't a fix yet because of that.

bluelhf commented 4 years ago

@bensku

Unfortunately, Java's builtin regex support has problems with regexes containing repetitive alternative paths (that is, (A|B)*). This is compiled into a recursive call, which results in a StackOverflow error when used on a very large string. A possible solution is to rewrite your regex to not use a repititive alternative.

Maybe this would help?

bensku commented 4 years ago

Applying this advise to current parser might not be possible, unfortunately.

bluelhf commented 4 years ago

Applying this advise to current parser might not be possible, unfortunately.

That would mean this is quite literally impossible to fix unless we start asking whoever maintains OpenJDK to improve Java's regex parser itself?

That's reassuring.

bensku commented 4 years ago

Sorry, I was unclear. I meant that it is possible that there is no way to fix this issue with current Skript parser. We'll try to avoid regex parsing in future works.

Pikachu920 commented 4 years ago

OP can always increase their stack size, it's more of a problem with how recursive the parser is with complex patterns that causes the trouble

soulstriker23 commented 4 years ago

OP can always increase their stack size, it's more of a problem with how recursive the parser is with complex patterns that causes the trouble

Is that something the user can do to make skript actually work without it being disabled?

bluelhf commented 4 years ago

@soulstriker23 If the stack size is too small, Skript won't have enough space on the stack to do the regex, resulting in this error. The user can modify their stack size with the -Xss JVM argument, which should resolve the problem provided it's set to a high enough value.

bensku commented 4 years ago

I do not recommend increasing stack size, because it may lead to the server running out of memory. A better workaround is to not have overly long lines. Avoiding installation and/or usage of addons with very complex syntaxes might also help, but I haven't tested it.

soulstriker23 commented 4 years ago

@bensku Okay, that make sense. I tried it and it works sometimes. But then tried it again with fresh install and putting the skript.jar with no skript written (just the disabled default ones) it gives the massive error and disables skript completely so I can't do anything with it. Any reason why it would just randomly work and not? Only have skquery & skript installed.

bensku commented 4 years ago

Without scripts? There are a few possibilities:

bluelhf commented 4 years ago

@LoganLilypad Are you, by chance, running a version of Paper that's not officially supported? A legacy build of Paper, that is..?

soulstriker23 commented 4 years ago

Well, @bensku I downloaded the 2.4.1 skript.jar from the releases page. Running PaperSpigot 1.15.1 Build#62 (latest) & I also removed skquery. Starts to load then sends this whole error section and at the end says "disabled" image

image

Polda18 commented 4 years ago

I have very similar issue:

[20:45:48 ERROR]: Error occurred while enabling Skript v2.4.1 (Is it up to date?)
java.lang.StackOverflowError: null
        at java.lang.Character.codePointAt(Unknown Source) ~[?:1.8.0_241]
      <snipped>
        at java.util.regex.Pattern$GroupHead.match(Unknown Source) ~[?:1.8.0_241]

Server: Paper 70 (Minecraft 1.15.2), Skript version 2.4.1, one Skript enabled:

# Hráč se připojí
on join:
    # Nejpre vyčistíme inventář
    set inventory of player to air

    # Do 9. slotu vložíme kompas pro výběr serveru
    set {_selector} to compass named "&2&lVolba serveru &7(Pravé myšítko)" with lore "&5Klikni pravým myšítkem pro výběr serveru"
    set slot 8 of player to {_selector}

    # Do 5. slotu vložíme knihu pro pravidla
    set {_pravidla} to book named "&4&lPravidla &7(Pravé myšítko)" with lore "&5Klikni pravým myšítkem k zobrazení pravidel"
    set slot 4 of player to {_pravidla}

This is some serious issue as I was gonna test out if that skript is going to work (Yes, I made testing server just for Skripts to be tested before it is going to be deployed into main server). I cannot since Skript is having bad time enabling itself. I don't know, can't it connect to Internet?

RXJpaw commented 4 years ago

2770

Polda18 commented 4 years ago

@RXJpaw Are you therefore suggesting that this is fixed in Java 13, Erik? Oracle Java download still claims Java 8 is latest version. From IntelliJ IDEA I know that that's not true, since there is JDK version 11 used.

bensku commented 4 years ago

Script made by @Polda18 doesn't look terribly complex. Can someone reproduce this with it? If yes, does having addons have any effect on it? Can anyone reproduce on Java 11 or newer version?

Dropping support for Java 8 has been in plans for a while (see #1321), but continued support from OpenJDK vendors has made it difficult. If this is indeed a bug in Java 8, I'm not terribly interested in working on it.

Polda18 commented 4 years ago

@bensku Tried, it works. Looks like it really doesn't work on Java 8 or older.

ShaneBeee commented 4 years ago

Here is a bit of info regarding this:

bensku commented 4 years ago

I can't reproduce these on OpenJDK 8 or 11 either. Some generic tips that might help:

Polda18 commented 4 years ago

@ShaneBeee, @bensku - I was using Oracle's Java 8, it Skript didn't work. And Update Scheduler didn't announce any new update. Strange. With OpenJDK v13, it works.

bensku commented 4 years ago

Stack traces posted here do not contain any references to Skript, which makes debugging hard. Moreover, we've failed to reproduce this with both Java 8 and 11, including Oracle's JDK 8. I do not consider this to be worth investigating more with our limited resources.

I'll reconsider this if someone provides a stack trace with Skript methods and/or example I can reproduce this with on both Java 8 and 11.

To people having this issue: update to a newer Java version. It is likely going to help, even though I have no idea why.

bensku commented 4 years ago

I managed to isolate this bug to https://github.com/SkriptLang/Skript/blob/master/src/main/java/ch/njol/skript/config/Node.java#L132, and the code in question is being called by aliases system. I'm not sure why it would affect some people but not others, but replacing the regex is should be reasonably easy.

soulstriker23 commented 4 years ago

That's great! Is this something that can be fixed on our end, or will you update the 2.4.1 later on?

Jayderp commented 4 years ago

This is a major issue.

Jayderp commented 4 years ago

What should someone encountering this issue increase their stack size to?

bensku commented 4 years ago

Updating to Java 11 or 14 might help with this, but increasing stack size manually is not recommended.

Romitou commented 4 years ago

Hello, I'm not sure what I'm saying, but the many times I've seen people with this error, the majority have been Java 32-bit. Do you think it could be related to that?

Pikachu920 commented 4 years ago

that's actually a good point, the default stack size is lower on 32bit which could explain at least part of this error. what do you think @bensku

bluelhf commented 4 years ago

@Pikachu920 The issue has been consistently solved by updating Java from 8 to something newer, usually 11 or 14. Whether they also upgraded to 64bit at the same time, I'm not sure. If I have some time I'll experiment with 32 and 64-bit versions of Java 8 and 11.

Wealthyturtle commented 4 years ago

@bensku It seems like this is mainly caused by users not using 64-bit Java... Maybe it would be a good idea to add a warning if users run Skript on 32-bit Java?

ASebastian1 commented 4 years ago

hello good, also the same error happens to me. Do you know how to solve it?

Romitou commented 4 years ago

hello good, also the same error happens to me. Do you know how to solve it?

Hello, this error has always been solved by updating Java to 64bits.

ASebastian1 commented 4 years ago

hola bien, también me pasa el mismo error. sabes como resolverlo?

Hola, este error siempre se ha solucionado actualizando Java a 64 bits.

I have a 64-bit PC, but the plugin does not run anyway. Should I do something else?

Romitou commented 4 years ago

You may have a 64-bit PC, but you've probably downloaded 32-bit Java. Try downloading it again here, hopefully it will work! https://www.java.com/en/download/manual.jsp

Screenshot: image

ASebastian1 commented 4 years ago

You may have a 64-bit PC, but you've probably downloaded 32-bit Java. Try downloading it again here, hopefully it will work! https://www.java.com/en/download/manual.jsp

Screenshot: image

It worked thanks a lot for the help.