VM crashed at StringTable expansion

Florian Weimer fweimer at redhat.com
Wed Feb 26 11:11:19 UTC 2020


* 向伟(识月):

> We create a simple case to reproduce the issue:
>
> import java.lang.reflect.Field;
> import java.lang.reflect.Modifier;
> public class StringTableTest {
>     public static void main(String[] args) throws Exception {
>         Field f = String.class.getDeclaredField("value");
>         f.setAccessible(true);
>         f.set("s1".intern(), f.get("s2"));
>         for (int i = 0; i < 4_000_000; i++) {
>             ("s_" + i).intern();
>         }
>     }
> }

Doesn't this change the value of the "s1" string literal to the string
"s2"?

I don't think this is supportable at all.  For example, if the
implementation happens to use "s1" anywhere, it's no longer getting the
string "s1", as expected.  There's also a non-trivial interaction with
string deduplication.

Thanks,
Florian



More information about the core-libs-dev mailing list