Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IndexOutOfBoundsException when use withStringCompressed(true) #1984

Open
2 tasks done
wzhongke opened this issue Dec 19, 2024 · 4 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@wzhongke
Copy link

Search before asking

  • I had searched in the issues and found no similar issues.

Version

0.9.0

Component(s)

Java

Minimal reproduce step

public class Main {
    private static final ThreadSafeFury FURY = Fury.builder().withLanguage(Language.JAVA)
        .requireClassRegistration(false)
        .withNumberCompressed(true)
        .withStringCompressed(true)
        .withRefTracking(true)
        .withMetaCompressor(new DeflaterMetaCompressor())
        .buildThreadLocalFury();

    @Data
    public static class Simple {
        private String str;

        public Simple(String str) {
            this.str = str;
        }
    }

    public static void main(String[] args) {
        byte[] serialize = FURY.serialize(new Simple("STG@ON DEMAND Solutions@GeoComputing Switch/ Hub@Digi Edgeport/216 – 16 port Serial Hub"));
        FURY.deserialize(serialize);
    }
}

What did you expect to see?

No error

What did you see instead?

Exception in thread "main" org.apache.fury.exception.DeserializationException: Deserialize failed, read objects are: [Main.Simple(str=null)]
at org.apache.fury.util.ExceptionUtils.handleReadFailed(ExceptionUtils.java:63)
at org.apache.fury.Fury.deserialize(Fury.java:797)
at org.apache.fury.Fury.deserialize(Fury.java:714)
at org.apache.fury.ThreadLocalFury.deserialize(ThreadLocalFury.java:137)
at com.lenovo.awakens.Main.main(Main.java:33)
Caused by: java.lang.IndexOutOfBoundsException: readerIndex(30) + length(81) exceeds size(123): org.apache.fury.memory.MemoryBuffer$BoundChecker@2584b82d
at org.apache.fury.memory.MemoryBuffer$BoundChecker.fillBuffer(MemoryBuffer.java:186)
at org.apache.fury.memory.MemoryBuffer.checkReadableBytes(MemoryBuffer.java:2412)
at org.apache.fury.serializer.StringSerializer.readBytesUnCompressedUTF16(StringSerializer.java:434)
at org.apache.fury.serializer.StringSerializer.readBytesString(StringSerializer.java:206)
at com.lenovo.awakens.Main_SimpleFuryRefCodec_0.read(Main_SimpleFuryRefCodec_0.java:56)
at org.apache.fury.Fury.readDataInternal(Fury.java:959)
at org.apache.fury.Fury.readRef(Fury.java:861)
at org.apache.fury.Fury.deserialize(Fury.java:793)
... 3 more

Anything Else?

I think it might be a problem here, but I am not sure about it
image

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@wzhongke wzhongke added the bug Something isn't working label Dec 19, 2024
@chaokunyang
Copy link
Collaborator

@HuangXingBo Could you take a look at this issue? Seems we should check compressString before returning new Invoke(strSerializer, "readBytesString", STRING_TYPE, buffer), and we also need an ut which test a POJO with String field serialization with codegen enabled

@chaokunyang
Copy link
Collaborator

Hi @wzhongke , could you disable string compression? This will keep behaviour consistent with fury 0.8.0. The serialization will still work. Of course the serialized data will be larger.

@wzhongke
Copy link
Author

Hi @wzhongke , could you disable string compression? This will keep behaviour consistent with fury 0.8.0. The serialization will still work. Of course the serialized data will be larger.

OK, thanks

@chaokunyang
Copy link
Collaborator

@wzhongke Would you like to create a PR to fix this? We can make a release in next two weeks

chaokunyang pushed a commit that referenced this issue Dec 30, 2024
…g during deserialization when string compression is enabled. (#1991)

Fix the issue caused by not using readCompressedBytesString during
deserialization when string compression is enabled.

<!--
**Thanks for contributing to Fury.**

**If this is your first time opening a PR on fury, you can refer to
[CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).**

Contribution Checklist

- The **Apache Fury (incubating)** community has restrictions on the
naming of pr titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).

- Fury has a strong focus on performance. If the PR you submit will have
an impact on performance, please benchmark it first and provide the
benchmark result here.
-->

## What does this PR do?

fix issue [#1984 ](#1984)
<!-- Describe the purpose of this PR. -->

## Related issues

<!--
Is there any related issue? Please attach here.

- #xxxx0
- #xxxx1
- #xxxx2
-->

## Does this PR introduce any user-facing change?

<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fury/issues/new/choose) describing the
need to do so and update the document if necessary.
-->

- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?

## Benchmark

<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants