Closed yaminet1024 closed 11 months ago
//cc @aam
@yaminet1024 thanks for the report. Do you have small app that reproduces the problem? Do you have a flutter or standalone dart app? What is the screenshot of? What is that that you use for leak detection?
@yaminet1024 thanks for the report. Do you have small app that reproduces the problem? Do you have a flutter or standalone dart app? What is the screenshot of? What is that that you use for leak detection?
Thank you for your assistance. We use Visual Studio to debug our Flutter application. The screenshot provided is from the Visual Studio debugger focusing on memory usage. You can find more information about this tool at https://learn.microsoft.com/en-us/visualstudio/profiling/memory-usage-without-debugging2?view=vs-2022. I've noticed that the number of Dart SSL objects increases each time I open and close the Flutter windows. I plan to create a Flutter example to illustrate this issue. Additionally, could you guide me on how to debug a windows standalone Dart application to analyze memory?
Aha, thanks.
Additionally, could you guide me on how to debug a windows standalone Dart application to analyze memory?
You should be able to run .dart programs from powershell using dart.exe that is part of flutter like so:
C> dart main.dart
/CN=storage.googleapis.com
/C=US/O=Google Trust Services LLC/CN=GTS CA 1C3
dc7198af64b5e40a69b2e8d8998e6d5e9aa02ab7748063d903f1d5887c5b1bcf *dartsdk-windows-x64-release.zip
C>
with main.dart having the following contents
import 'dart:io';
main() {
HttpClient client = new HttpClient();
client
.getUrl(Uri.parse("https://storage.googleapis.com/dart-archive/channels/stable/release/3.2.3/sdk/dartsdk-windows-x64-release.zip.sha256sum"))
.then((request) => request.close())
.then((response) {
print(response.certificate!.subject);
print(response.certificate!.issuer);
return response
.fold<List<int>>(<int>[], (message, data) => message..addAll(data));
}).then((message) {
String received = new String.fromCharCodes(message);
print(received);
client.close();
});
}
You can also download dart sdk separately from flutter from https://dart.dev/get-dart/archive
Profiling such apps with Visual Studio would involve launching dart.exe
process with main.dart
as an argument from Visual Studio.
Aha, thanks.
Additionally, could you guide me on how to debug a windows standalone Dart application to analyze memory?
You should be able to run .dart programs from powershell using dart.exe that is part of flutter like so:
C> dart main.dart /CN=storage.googleapis.com /C=US/O=Google Trust Services LLC/CN=GTS CA 1C3 dc7198af64b5e40a69b2e8d8998e6d5e9aa02ab7748063d903f1d5887c5b1bcf *dartsdk-windows-x64-release.zip C>
with main.dart having the following contents
import 'dart:io'; main() { HttpClient client = new HttpClient(); client .getUrl(Uri.parse("https://storage.googleapis.com/dart-archive/channels/stable/release/3.2.3/sdk/dartsdk-windows-x64-release.zip.sha256sum")) .then((request) => request.close()) .then((response) { print(response.certificate!.subject); print(response.certificate!.issuer); return response .fold<List<int>>(<int>[], (message, data) => message..addAll(data)); }).then((message) { String received = new String.fromCharCodes(message); print(received); client.close(); }); }
You can also download dart sdk separately from flutter from https://dart.dev/get-dart/archive
Profiling such apps with Visual Studio would involve launching
dart.exe
process withmain.dart
as an argument from Visual Studio.
Here is the Flutter example that uses image.url, which can reproduce the memory leak issue. You can watch the video to see how to reproduce it
https://github.com/dart-lang/sdk/assets/23304639/9345fa41-4710-4ef9-87c9-7d897755e4ce
I've identified the issue: if the status is not equal to 0 in the line int status = X509_STORE_add_cert(store, root_cert);, then root_cert is never freed. However, when I call X509_free(root_cert) after X509_STORE_add_cert, X509 will not leak
The function X509_STORE_add_cert increases the reference count for the X509 certificate. If we do not free root_cert, it will always have a reference count remaining. You can refer to the documentation for more details at:
For X509_STORE_add_cert: https://www.openssl.org/docs/man1.1.1/man3/X509_STORE_add_cert.html For X509_free: https://www.openssl.org/docs/man3.2/man3/X509_free.html
Thank you @yaminet1024 , you are right, X509_free(root_cert)
call is missing. We should do the freeing right after the call to X509_STORE_add_cert
, remove such calls from if (status == 0)
then-branch. Do you want to submit a patch?
Thank you @yaminet1024 , you are right,
X509_free(root_cert)
call is missing. We should do the freeing right after the call toX509_STORE_add_cert
, remove such calls fromif (status == 0)
then-branch. Do you want to submit a patch?
yes, I'd be happy to help! I hope I can be of assistance.
Sounds good, see if you can follow https://github.com/dart-lang/sdk/blob/main/CONTRIBUTING.md to create either Github PR or Gerrit patch. Gerrit workflow is what dart sdk dev team uses internally, but might take a little more effort to set up compared to Github workflow.
Си
Ага, спасибо.
Кроме того, не могли бы вы подсказать мне, как отладить автономное приложение Dart для Windows для анализа памяти?
Вы должны иметь возможность запускать программы .dart из PowerShell с помощью dart.exe, который является частью flutter, например, так:
C> dart main.dart /CN=storage.googleapis.com /C=US/O=Google Trust Services LLC/CN=GTS CA 1C3 dc7198af64b5e40a69b2e8d8998e6d5e9aa02ab7748063d903f1d5887c5b1bcf *dartsdk-windows-x64-release.zip C>
с main.dart, имеющим следующее содержимое
import 'dart:io'; main() { HttpClient client = new HttpClient(); client .getUrl(Uri.parse("https://storage.googleapis.com/dart-archive/channels/stable/release/3.2.3/sdk/dartsdk-windows-x64-release.zip.sha256sum")) .then((request) => request.close()) .then((response) { print(response.certificate!.subject); print(response.certificate!.issuer); return response .fold<List<int>>(<int>[], (message, data) => message..addAll(data)); }).then((message) { String received = new String.fromCharCodes(message); print(received); client.close(); }); }
Вы также можете загрузить dart sdk отдельно от flutter с https://dart.dev/get-dart/archive Профилирование таких приложений с помощью Visual Studio будет включать запуск
dart.exe
процесса с использованиемmain.dart
в качестве аргумента из Visual Studio.Вот пример Flutter, который использует image.url, который может воспроизвести проблему утечки памяти. Вы можете посмотреть видео, чтобы увидеть, как это воспроизвести
играть.mp4 demo_win.zip
the memory leak is reproducible again, windows and linux
@afl-dev wrote
the memory leak is reproducible again, windows and linux
Since the original issue with security context leaking was fixed, please raisea new issue in this tracker describing the problem you are experiencing. Please specify flutter version you are using. The app from demo_win.zip seems to work as expected on 3.5.0-176.0. mp4-file you mentioned is not available.
This tracker is for issues related to:
dart:async
,dart:io
, etc.)Dart version and tooling diagnostic info
Dart 3.0.2 (stable) (Unknown timestamp) on "windows_x64" on windows / "Windows 10 Pro" 10.0 (Build 22631) locale is zh-CN
Whether you are using Windows, macOS, or Linux
Windows
problem
I found it when I was looking at the leaks in my Flutter Windows application.