Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
chaokunyang committed Oct 3, 2023
1 parent 0f3fdab commit da80783
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ jobs:
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
- name: Install bazel
run: ./ci/run_ci.sh install_bazel
- name: Install python
run: ./ci/run_ci.sh install_python
- name: Install pyfury
run: ./ci/run_ci.sh install_pyfury
# - name: Install bazel
# run: ./ci/run_ci.sh install_bazel
# - name: Install python
# run: ./ci/run_ci.sh install_python
# - name: Install pyfury
# run: ./ci/run_ci.sh install_pyfury
- name: Run CI with Maven
run: PATH="$HOME/miniconda/bin:$PATH" ./ci/run_ci.sh java${{ matrix.java-version }}
integration_tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
package io.fury.benchmark;

import io.fury.Fury;
import java.util.ArrayList;
import java.util.List;
import org.openjdk.jmh.Main;
import org.openjdk.jmh.annotations.Benchmark;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
* Test suite for collection.
*
Expand All @@ -45,6 +44,7 @@ public static void main(String[] args) throws Exception {
private static Fury fury = Fury.builder().build();
private static List<Integer> list1 = new ArrayList<>(1024);
private static byte[] list1Bytes;

static {
for (int i = 0; i < 1024; i++) {
list1.add(i % 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void testDeserializeUnexistedNewFury(
boolean compressNumber,
boolean enableCodegen1,
boolean enableCodegen2,
boolean enableCodegen3) throws Exception {
boolean enableCodegen3) {
Fury fury =
builder()
.withRefTracking(referenceTracking)
Expand All @@ -115,8 +115,12 @@ public void testDeserializeUnexistedNewFury(
ClassLoader classLoader = getClass().getClassLoader();
for (Class<?> structClass :
new Class<?>[] {
Struct.createNumberStructClass("TestSkipUnexistedClass1", 2),
Struct.createStructClass("TestSkipUnexistedClass1", 2)
// Serialization may crash at `G1ParScanThreadState::copy_to_survivor_space` in
// ubuntu22 and jdk11/17. It's a jvm bug, see:
// https://github.com/alipay/fury/pull/923#issuecomment-1745035339
// Workaround by disable cache.
Struct.createNumberStructClass("TestSkipUnexistedClass2", 2, false),
Struct.createStructClass("TestSkipUnexistedClass2", 2, false)
}) {
Object pojo = Struct.createPOJO(structClass);
MetaContext context1 = new MetaContext();
Expand Down Expand Up @@ -146,12 +150,6 @@ public void testDeserializeUnexistedNewFury(
.build();
MetaContext context3 = new MetaContext();
fury3.getSerializationContext().setMetaContext(context3);
// This may crash at `G1ParScanThreadState::copy_to_survivor_space` in
// ubuntu22 and jdk11/17. It's a jvm bug, see:
// https://github.com/alipay/fury/pull/923#issuecomment-1745035339
// Workaround by gc manually.
System.gc();
Thread.sleep(50);
Object o3 = fury3.deserialize(bytes2);
assertEquals(o3.getClass(), structClass);
assertEquals(o3, pojo);
Expand All @@ -178,8 +176,12 @@ public void testDeserializeUnexisted(
ClassLoader classLoader = getClass().getClassLoader();
for (Class<?> structClass :
new Class<?>[] {
Struct.createNumberStructClass("TestSkipUnexistedClass1", 2),
Struct.createStructClass("TestSkipUnexistedClass1", 2)
// Serialization may crash at `G1ParScanThreadState::copy_to_survivor_space` in
// ubuntu22 and jdk11/17. It's a jvm bug, see:
// https://github.com/alipay/fury/pull/923#issuecomment-1745035339
// Workaround by disable cache.
Struct.createNumberStructClass("TestSkipUnexistedClass3", 2, false),
Struct.createStructClass("TestSkipUnexistedClass3", 2, false)
}) {
Fury fury2 =
builder()
Expand Down Expand Up @@ -220,7 +222,7 @@ public void testDeserializeUnexisted(
public void testThrowExceptionIfClassNotExist() {
Fury fury = builder().withDeserializeUnexistedClass(false).build();
ClassLoader classLoader = getClass().getClassLoader();
Class<?> structClass = Struct.createNumberStructClass("TestSkipUnexistedClass1", 2);
Class<?> structClass = Struct.createNumberStructClass("TestSkipUnexistedClass1", 2, false);
Object pojo = Struct.createPOJO(structClass);
Fury fury2 =
builder().withDeserializeUnexistedClass(false).withClassLoader(classLoader).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,17 @@ public static Class<?> loadClass(Object key, boolean cache, Supplier<Class<?>> f

/** Create class. */
public static Class<?> createNumberStructClass(String classname, int repeat) {
return createNumberStructClass(classname, repeat, true);
}

public static Class<?> createNumberStructClass(String classname, int repeat, boolean cache) {
if (StringUtils.isBlank(classname)) {
throw new IllegalArgumentException("Class name is empty");
}
String key = "createNumberStructClass" + classname + repeat;
return loadClass(
key,
cache,
() -> {
StringBuilder classCode =
new StringBuilder(
Expand Down

0 comments on commit da80783

Please sign in to comment.