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

Value Types: crash when System.arrayCopy sets null in null-restricted array #20253

Closed
theresa-m opened this issue Sep 27, 2024 · 5 comments · Fixed by #20250
Closed

Value Types: crash when System.arrayCopy sets null in null-restricted array #20253

theresa-m opened this issue Sep 27, 2024 · 5 comments · Fixed by #20250
Labels
comp:vm project:valhalla Used to track Project Valhalla related work

Comments

@theresa-m
Copy link
Contributor

Related to #20223 I also tried the following to see whether or not I can copy null into a null-restricted array. This test results in a segmentation error.

java --enable-preview --add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED --add-exports java.base/jdk.internal.value=ALL-UNNAMED -XX:ValueTypeFlatteningThreshold=99999 -XX:+EnableArrayFlattening -Xint TestNullRestrictedArray

        static private void test1(int x) {
           SomeValueClass1[] array1 = (SomeValueClass1[])ValueClass.newArrayInstance(NullRestrictedCheckedType.of(SomeValueClass1.class), ARRAY_SIZE);
           SomeValueClass1[] array2 = new SomeValueClass1[ARRAY_SIZE];
                
                for (int i=0; i < ARRAY_SIZE; i++) {
                        array1[i] = new SomeValueClass1(i*x);
                        array2[i] = null;
                }
                
                System.arraycopy(array2, 0, array1, 0, ARRAY_SIZE);
        }

Changes from #20250 are needed to reproduce this.

@theresa-m theresa-m added comp:vm project:valhalla Used to track Project Valhalla related work labels Sep 27, 2024
Copy link

Issue Number: 20253
Status: Open
Recommended Components: comp:vm, comp:test, comp:gc
Recommended Assignees: hangshao0, babsingh, gacholio

@dmitripivkine
Copy link
Contributor

Speculating, but please be aware it is possible we do not have proper implementation for some cases for Flattened Arrays copy. Traditional array copy functions might have deal with hardcoded element sizes 1, 2, 4 , 8. Copy of different size element byte by byte might be not sufficient due possible object references embedded to the element. Coping object reference should be done size-atomic. Also it might require triggering of GC barriers. Please do not hesitate to ask if there is one of this cases or you need help with investigation.

@hangshao0
Copy link
Contributor

There is a comment in the code:

/* TODO restrict this flag to be set only for null-restricted
* arrays once value type command line tests are updated.
*/
arrayFlags |= J9ClassIsFlattened;

The flag J9ClassIsFlattened is expected to be removed from nullable array.

@theresa-m
Copy link
Contributor Author

Oh yea... that was me wasn't it 😅. Thanks, I'll start there.

Copy link

github-actions bot commented Oct 4, 2024

Issue Number: 20253
Status: Closed
Actual Components: comp:vm, project:valhalla
Actual Assignees: No one :(
PR Assignees: theresa-m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:vm project:valhalla Used to track Project Valhalla related work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants