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

Dart: allow conditionally disabling 'Finalizable' marker usage #1646

Conversation

pwrobeldev
Copy link
Contributor

@pwrobeldev pwrobeldev commented Jan 15, 2025

---------- Motivation ----------
It turned out that in certain rare cases
Dart compiler experiences internal compiler
error related to scope building when 'Finalizable'
is used.

The fix for the problems is available in Dart SDK 3.6.0+.
There can be problems if the user cannot immediately
upgrade to the new Dart SDK and wants to use other
new features/bug-fixes.

---------- Implemented change ----------
In order to ease the transition phase for users the
new CLI flag called 'dartdisablefinalizablemarker' was
introduced. It allows users to conditionally disable
the usage of 'Finalizable' marker interface.

Moreover, new CMake tests have been introduced to verify
that 'GLUECODIUM_DART_DISABLE_FINALIZABLE_MARKER'
flag works as expected. They bring also a new utility for CMake
tests, which allow users to verify if the generated file contains a
given string.

---------- IMPORTANT ----------
It is discouraged to use this flag, because when 'Finalizable'
marker interface is not used a rare race conditions between
garbage collection and native finalizers may occur.

The flag is designed ONLY to help during the transition phase to
Dart SDK 3.6.0+.

It turned out that in certain rare cases
Dart compiler experiences internal compiler
error related to scope building when 'Finalizable'
is used.

The fix for the problems is available in Dart SDK 3.6.0+.
Therefore, to ease the transition phase for the users a
new CLI flag called 'dartdisablefinalizablemarker' was
introduced. It allows users to conditionally disable
the usage of 'Finalizable' marker interface.

It is discouraged to use this flag, because when 'Finalizable'
marker interface is not used a rare race conditions between
garbage collection and native finalizers can be used.

The flag is designed to help during the transition phase to
Dart SDK 3.6.0+.

Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This change introduces a new cmake tests, which
verifies that 'GLUECODIUM_DART_DISABLE_FINALIZABLE_MARKER'
flag works as expected.

When it is enabled, then generated file for Dart should not
use 'Finalizable' interface marker from Dart FFI.

The positive test is not added, because this flag is disabled
by default -- this logic is verified in smoke tests.

Moreover, this commit introduces a new utility tool for tests.
It allows checking if the generated file contains a given string.

Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
@pwrobeldev pwrobeldev marked this pull request as ready for review January 15, 2025 09:48
@pwrobeldev pwrobeldev merged commit 6519c60 into master Jan 15, 2025
10 checks passed
@pwrobeldev pwrobeldev deleted the pwrobeldev/allow-conditionally-enabling-finalizable-interface branch January 15, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants