oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.43k stars 1.64k forks source link

`G1 doesn't support multiple isolates at the moment` exception occurs when I use g1 garbage collection type in MySQL UDF #9678

Open strongduanmu opened 2 months ago

strongduanmu commented 2 months ago

Dear GraalVM community, I am trying to use GraalVM to build a shared library, then call the so file through C language and package it as a MySQL UDF function. After I deployed UDF to MySQL Server, an exception occurred when executing the following SQL.

SELECT encrypt("DES", 'des-key-value=test', '222');

But unfortunately, an exception occurred:

#  guarantee(SVMIsolateData::_heap_base == nullptr) failed: G1 doesn't support multiple isolates at the moment.
2024-09-13T09:11:55Z UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
BuildID[sha1]=760904bb5c412602b3f2c1b7241648b1a2970a7b
Thread pointer: 0x7f1276cb38c0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7f121df19bf0 thread_stack 0x100000
/root/mysql-8.0.37-linux-glibc2.17-x86_64/bin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x3d) [0x21211bd]
/root/mysql-8.0.37-linux-glibc2.17-x86_64/bin/mysqld(print_fatal_signal(int)+0x37f) [0xfe111f]
/root/mysql-8.0.37-linux-glibc2.17-x86_64/bin/mysqld(handle_fatal_signal+0xa5) [0xfe11d5]
/lib64/libpthread.so.0(+0xf630) [0x7f128940f630]
/lib64/libc.so.6(gsignal+0x37) [0x7f1287754387]
/lib64/libc.so.6(abort+0x148) [0x7f1287755a78]
/usr/lib/udf/libsphereex_encrypt_udf.so(+0x1261b6) [0x7f122c32a1b6]
/usr/lib/udf/libsphereex_encrypt_udf.so(+0x17fdb57) [0x7f122da01b57]
/usr/lib/udf/libsphereex_encrypt_udf.so(+0x17fdbbe) [0x7f122da01bbe]
/usr/lib/udf/libsphereex_encrypt_udf.so(+0x17faf05) [0x7f122d9fef05]
/usr/lib/udf/libsphereex_encrypt_udf.so(+0x176489f) [0x7f122d96889f]
/usr/lib/udf/libsphereex_encrypt_udf.so(+0x329426) [0x7f122c52d426]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7f12773673e0): SELECT spex_encrypt("SphereEx:DES", 'des-key-value=test', '222')
Connection ID (thread ID): 22
Status: NOT_KILLED

Does the exception G1 doesn't support multiple isolates at the moment mean that the G1 garbage collector cannot be used at present, or that some specifications need to be followed? If any developer familiar with this problem could help me out, I'd be very grateful.

strongduanmu commented 2 months ago

Hi @fernando-valdez, thank you for your attention to this issue. This is a simple example of writing a MySQL UDF using GraalVM. Hopefully it will help you reproduce the issue——https://github.com/strongduanmu/graalvm-lecture/tree/main/mysql-udf.

This example currently uses serial gc. You need to modify the GraalVM build parameters to specify G1 gc, then execute the following script to compile the so file and deploy it to the MySQL Server plugin directory.

Looking forward to your feedback, and if there is anything you need my help with, you can ping me. Thank you very much!!!

./mvnw -Pnative clean package -f mysql-udf
gcc -I/opt/homebrew/opt/mysql/include/mysql -I./mysql-udf/target -L./mysql-udf/target -lsm4_udf -fPIC -g -shared -o ./mysql-udf/target/sm4_encrypt_udf.so ./mysql-udf/src/main/native/sm4_encrypt_udf.c