Skip to content

Conversation

@Johni0702
Copy link
Contributor

The "Sinytra Connector" mod uses a custom SecureJar implementation, which prior to this commit resulted in us doing an out of bounds memory read (returning what looks like a String, resulting in a class cast exception) because we were using the same unsafe getter that we were using for ML's Jar implementation.

This commit fixes the issue by using a separate getter for each implementation class.
This change alone is sufficient to fix the issue because we'll then get an explicit NoSuchFieldException, which we catch. However, to avoid unnessecary log spam, this commit additionally special cases the dummy class to silently return null. It also changes our getVersion method to still try the fallback paths (which do work!) instead of returning early on null since that is now a legitimate case.

Side note: While this is sufficient to get Essential working with Connector, we do still run into problems if fabric-language-kotlin is installed via it without KotlinForForge being installed. This is because Connector loads FLK into the GAME layer via FML's IDependencyLocator mechanism (unless KFF is installed, in which case it skips loading it) while we load our Kotlin into the PLUGIN layer directly via ModLauncher. Fixing this is non-trivial and since Connector itself also misbehaves if a newer FLK is loaded while an older KFF is already present, I'll be ignoring that issue for the time being.

The "Sinytra Connector" mod uses a custom `SecureJar` implementation,
which prior to this commit resulted in us doing an out of bounds memory
read (returning what looks like a String, resulting in a class cast
exception) because we were using the same unsafe getter that we were
using for ML's `Jar` implementation.

This commit fixes the issue by using a separate getter for each
implementation class.
This change alone is sufficient to fix the issue because we'll then get
an explicit `NoSuchFieldException`, which we catch. However, to avoid
unnessecary log spam, this commit additionally special cases the dummy
class to silently return `null`. It also changes our `getVersion` method
to still try the fallback paths (which do work!) instead of returning
early on `null` since that is now a legitimate case.
@Johni0702 Johni0702 requested a review from DJtheRedstoner May 8, 2025 09:14
@github-actions
Copy link

github-actions bot commented May 8, 2025

Test Results

16 files  ±0  16 suites  ±0   11m 35s ⏱️ -1s
95 tests ±0  95 ✅ ±0  0 💤 ±0  0 ❌ ±0 
99 runs  ±0  99 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit f583b2d. ± Comparison against base commit 2b35cce.

@CallumBugajski CallumBugajski self-requested a review May 8, 2025 12:29
Copy link

@CallumBugajski CallumBugajski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@Johni0702 Johni0702 merged commit 90dc3cf into master May 8, 2025
36 checks passed
@Johni0702 Johni0702 deleted the fix/crash-with-sinytra-connector branch May 8, 2025 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants