Skip to content

Conversation

@HosseinYousefi
Copy link
Member

@HosseinYousefi HosseinYousefi commented Dec 8, 2025

This is useful for debugging use-after-release and double-release bugs.

We store all of the points where the objects is registered to be released by an arena, and also the point when it was finally released. When it comes to throwing either UseAfterReleaseError or DoubleReleaseError, we can show the user where they previously released or registered to release the object. We only do this inside assertions and also everything is behind a boolean flag Jni.captureStackTraceOnRelease which is false by default.

We store the stack trace string using in a char** in C because we want to access it from any isolate. A finalizable handle is created to handle garbage collection.

Also make releasedBy(arena) less strict: meaning it will only release if the object has not been released before and will not throw a double release error.

Closes #2246.

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

PR Health

License Headers ⚠️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
pkgs/jni/test/debug_release_test.dart

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/hooks_runner/test_data/download_assets/hook/build.dart
pkgs/objective_c/example/command_line/lib/main.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

This check can be disabled by tagging the PR with skip-license-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Breaking changes ⚠️
Package Change Current Version New Version Needed Version Looking good?
jni Breaking 0.15.2 0.15.3-wip 0.16.0
Got "0.15.3-wip" expected >= "0.16.0" (breaking changes)
⚠️

This check can be disabled by tagging the PR with skip-breaking-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

@coveralls
Copy link

Coverage Status

coverage: 82.767% (+0.05%) from 82.722%
when pulling b5567fa on release
into 9d538ae on main.

@HosseinYousefi HosseinYousefi merged commit e46b07f into main Dec 9, 2025
28 of 29 checks passed
@HosseinYousefi HosseinYousefi deleted the release branch December 9, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

using() does not show a useful stacktrace on double frees.

3 participants