-
Notifications
You must be signed in to change notification settings - Fork 728
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
SIGFPE for flattened array of value type that has no fields #14027
Comments
looks like
|
@dmitripivkine Yes, if the value type has no fields then the stride would be zero. Ideally in this case we would just allocated an array object with a header and no elements if the the array is flattened. Is this possible? If so, we would need to augment this check to handle the zero case. |
Looks like it is easier to do the zero check in the GC code. |
strongly disagree, at least with current model |
Should it be just 0-length array? If not (and stride must be zero) we should review array model (again) to have this case handled properly |
Well, I am not sure iteration of 0-length Flattened array is going to work "as-is" either |
Not sure if it'd be related, I see this crash happens with |
@tajila In general conceptually if we allow array element size be 0 is it required "array of N elements of 0-size" to be N != 0 (or only trivial case N == 0) ? |
The JVM spec allows arrays to be of length zero. Ie. In the case of ValueTypes, if it is flattened and there are no fields, the payload (stride) is effectively zero, meaning that there is no data to put in the array element. This is where the requirement for zero element size arrays come from. If the array type has no fields and is flattened we still need to be able to do:
This means even for zero element size arrays the length must be accurate. Given that the following is an overflow check for the aligned size.
We know that zero element sized length arrays will never overflow, so the check is not needed in that case. The alternative is to give a zero element sized array a stride of 1, but that will incur overhead in the |
Just for the record it is easy to fix this particular piece of code. However there are dozen more places where this macro is used. So it is more a general indexable object problem - zero element size arrays were not allowed before. |
@0xdaryl FYI - support for arrays with zero element size |
I am going to review GC code and make changes to support element size 0 arrays |
Test again. Cannot reproduce this issue on my side. |
@kangyining, I had to modify the test case slightly in order to reproduce the failure, as some JIT optimizations resulted in the array allocation being optimized away. You should be able to reproduce the failure with the attached issue14027.zip, using the following command invocation:
|
Update gc code to support 0-stride flattened array and get rid of division by 0 exceptions This is done by adding manually comparison against 0, might find better alternatives in the future. Related: eclipse-openj9#14027 Signed-off-by: Frank Kang <[email protected]>
GC part should be completed for now. Please let us know if something is missed.
Padding is required due minimum object size 16 bytes. I think we need to improve DDR support for 0-stride arrays, currently it is decoded as [L somehow:
|
It could be helpful if the core file is attached here (or upload it to box and paste a link here) for the possible DDR format issue. |
uploaded to https://ibm.box.com/s/m4mamghl6zh81u9jnc1q6c7mrs17h2im |
It seems that DDR always display The object is Object[]:
The object is String[]:
|
I am not sure last statement is accurate, this is example from the same core for Byte Array:
[L should be used for References arrays only. |
Yes, I should mention that is for all reference types on non-valhalla builds. The Q type descriptor is going to be removed from Valhalla, and all value types will still be L type in the upcoming spec. For now I am not worried much about displaying The array class names are from: openj9/runtime/vm/romclasses.c Lines 30 to 38 in 022a2a4
If we want, we could potentially add a new name for flattened value type array (which may imply a new romclass for flattened value type array needs to be generated). |
Since the fix and test have been merged, @hzongaro can this be closed ? |
Fixed under pull request #17994 |
Allocating an array of a value type that has no fields results in an exception for a division by zero if array element flattening is enabled. This only happens with JIT-compiled code, but I don't believe the problem lies in the JIT-compiled code itself.
The problem can be reproduced using this test:
Empty.java
EmptyArr.java
with this command invocation (empty.zip is attached)
Following is the call stack from gdb:
The text was updated successfully, but these errors were encountered: