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

Fix log_initial for panic! and refine a panic! info #1124

Merged
merged 6 commits into from
Mar 17, 2023

Conversation

dbsxdbsx
Copy link
Contributor

Changes

Before, the rust panic! would not be logged to disk. So this pr fixed this and refine the output panic info more friendly for #1123.

@dbsxdbsx
Copy link
Contributor Author

@fzyzcjy , done.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 15, 2023

Good job! I am quite busy now so will probably review today :)

Copy link
Owner

@fzyzcjy fzyzcjy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, only two nits!

frb_codegen/src/lib.rs Outdated Show resolved Hide resolved
frb_codegen/src/logs.rs Outdated Show resolved Hide resolved
@dbsxdbsx
Copy link
Contributor Author

@fzyzcjy , by the way, when running just precommit locally , it always fails at dart_linter_pana:

dbsx@DESKTOP-MGEUC6C MINGW64 ~/Desktop/flutter_rust_bridge (master)
$ just dart_linter_pana
flutter pub global activate pana
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Package pana is currently active at version 0.21.27.
Resolving dependencies...
The package pana is already activated at newest available version.
To recompile executables, first run `flutter pub global deactivate pana`.
Installed executable pana.
Activated pana 0.21.27.
cd frb_dart && pana.bat --no-warning --line-length 80 --exit-code-threshold 0
INFO       Running `D:\flutter\bin\cache\dart-sdk\bin\dart.exe --no-analytics --version`...
INFO       Running `flutter.bat --suppress-analytics --no-version-check --version --machine`...
INFO       Running `git rev-parse --show-toplevel`...
INFO       Running `D:\flutter\bin\cache\dart-sdk\bin\dart.exe --no-analytics pub get --no-example`...
INFO       Running `D:\flutter\bin\cache\dart-sdk\bin\dart.exe --no-analytics pub outdated --json --up-to-date --no-dev-dependencies --no-dependency-overrides`...
INFO       Analyzing package...
INFO       Running `D:\flutter\bin\cache\dart-sdk\bin\dart.exe --no-analytics analyze --format machine bin`...
INFO       Running `D:\flutter\bin\cache\dart-sdk\bin\dart.exe --no-analytics analyze --format machine lib`...
INFO       Running `git init`...
INFO       Running `git remote add origin https://github.com/fzyzcjy/flutter_rust_bridge`...
INFO       Running `git remote show origin`...
INFO       Running `git fetch --depth 1 --no-recurse-submodules origin master`...
INFO       Running `git ls-tree -r --name-only --full-tree origin/master`...
INFO       Unable to parse `pubspec.yaml` from git repository. Invalid argument(s): Path "frb_dart/pubspec.yaml" is not normalized.
           Invalid argument(s): Path "frb_dart/pubspec.yaml" is not normalized.
           #0      GitLocalRepository._assertPathFormat (package:pana/src/repository/git_local_repository.dart:223:7)
           #1      GitLocalRepository.showStringContent (package:pana/src/repository/git_local_repository.dart:156:5)
           #2      checkRepository.matchRepoPubspecYaml (package:pana/src/repository/check_repository.dart:91:36)
           #3      checkRepository (package:pana/src/repository/check_repository.dart:159:27)
           <asynchronous suspension>
           #4      SharedAnalysisContext.verifyRepository (package:pana/src/package_context.dart:72:24)
           <asynchronous suspension>
           #5      checkPubspecUrls (package:pana/src/references/pubspec_urls.dart:60:30)
           <asynchronous suspension>
           #6      followsTemplate.checkPubspec (package:pana/src/report/template.dart:186:25)
           <asynchronous suspension>
           #7      followsTemplate (package:pana/src/report/template.dart:254:26)
           <asynchronous suspension>
           #8      createReport (package:pana/src/report/create_report.dart:42:5)
           <asynchronous suspension>
           #9      PackageAnalyzer._inspect (package:pana/src/package_analyzer.dart:320:15)
           <asynchronous suspension>
           #10     PackageAnalyzer.inspectDir.<anonymous closure> (package:pana/src/package_analyzer.dart:143:14)
           <asynchronous suspension>
           #11     withTempDir (package:pana/src/utils.dart:236:12)
           <asynchronous suspension>
           #12     main (file:///C:/Users/dbsx/AppData/Local/Pub/Cache/hosted/pub.dev/pana-0.21.27/bin/pana.dart:176:19)
           <asynchronous suspension>
INFO       Running `D:\flutter\bin\cache\dart-sdk\bin\dart.exe --no-analytics format --output=none --set-exit-if-changed --line-length 80 C:\Users\dbsx\AppData\Local\Temp\pana_caf1ff1c\frb_dart\bin`...
INFO       Running `D:\flutter\bin\cache\dart-sdk\bin\dart.exe --no-analytics format --output=none --set-exit-if-changed --line-length 80 C:\Users\dbsx\AppData\Local\Temp\pana_caf1ff1c\frb_dart\lib`...

## ✗ Follow Dart file conventions (20 / 30)
### [x] 0/10 points: Provide a valid `pubspec.yaml`

<details>
<summary>
Failed to verify repository URL.
</summary>

Please provide a valid [`repository`](https://dart.dev/tools/pub/pubspec#repository) URL in `pubspec.yaml`, such that:

 * `repository` can be cloned,
 * a clone of the repository contains a `pubspec.yaml`, which:,
    * contains `name: flutter_rust_bridge`,
    * contains a `version` property, and,
    * does not contain a `publish_to` property.

Unable to parse `pubspec.yaml` from git repository. Invalid argument(s): Path "frb_dart/pubspec.yaml" is not normalized.
</details>

### [*] 5/5 points: Provide a valid `README.md`


### [*] 5/5 points: Provide a valid `CHANGELOG.md`


### [*] 10/10 points: Use an OSI-approved license

Detected license: `MIT`.

## ✓ Provide documentation (10 / 10)
### [*] 10/10 points: Package has an example


## ✓ Platform support (20 / 20)
### [*] 20/20 points: Supports 6 of 6 possible platforms (**iOS**, **Android**, **Web**, **Windows**, **MacOS**, **Linux**)

* ✓ Android
* ✓ iOS
* ✓ Windows
* ✓ Linux
* ✓ MacOS
* ✓ Web

## ✓ Pass static analysis (30 / 30)
### [*] 30/30 points: code has no errors, warnings, lints, or formatting issues


## ✓ Support up-to-date dependencies (20 / 20)
### [*] 10/10 points: All of the package dependencies are supported in the latest version

|Package|Constraint|Compatible|Latest|
|:-|:-|:-|:-|
|[`args`]|`^2.3.1`|2.4.0|2.4.0|
|[`build_cli_annotations`]|`^2.1.0`|2.1.0|2.1.0|
|[`colorize`]|`^3.0.0`|3.0.0|3.0.0|
|[`js`]|`^0.6.4`|0.6.7|0.6.7|
|[`meta`]|`^1.3.0`|1.9.0|1.9.0|
|[`path`]|`^1.8.1`|1.8.3|1.8.3|
|[`puppeteer`]|`^2.12.0`|2.23.0|2.23.0|
|[`shelf`]|`^1.3.2`|1.4.0|1.4.0|
|[`shelf_static`]|`^1.1.1`|1.1.1|1.1.1|
|[`shelf_web_socket`]|`^1.0.2`|1.0.3|1.0.3|
|[`tuple`]|`^2.0.1`|2.0.1|2.0.1|
|[`uuid`]|`^3.0.6`|3.0.7|3.0.7|
|[`web_socket_channel`]|`^2.2.0`|2.3.0|2.3.0|
|[`yaml`]|`^3.1.1`|3.1.1|3.1.1|

<details><summary>Transitive dependencies</summary>

|Package|Constraint|Compatible|Latest|
|:-|:-|:-|:-|
|[`archive`]|-|3.3.6|3.3.6|
|[`async`]|-|2.11.0|2.11.0|
|[`collection`]|-|1.17.1|1.17.1|
|[`convert`]|-|3.1.1|3.1.1|
|[`crypto`]|-|3.0.2|3.0.2|
|[`http`]|-|0.13.5|0.13.5|
|[`http_parser`]|-|4.0.2|4.0.2|
|[`logging`]|-|1.1.1|1.1.1|
|[`mime`]|-|1.0.4|1.0.4|
|[`petitparser`]|-|5.3.0|5.3.0|
|[`pointycastle`]|-|3.6.2|3.6.2|
|[`pool`]|-|1.5.1|1.5.1|
|[`source_span`]|-|1.9.1|1.9.1|
|[`stack_trace`]|-|1.11.0|1.11.0|
|[`stream_channel`]|-|2.1.1|2.1.1|
|[`string_scanner`]|-|1.2.0|1.2.0|
|[`term_glyph`]|-|1.2.1|1.2.1|
|[`typed_data`]|-|1.3.1|1.3.1|
</details>

To reproduce run `dart pub outdated --no-dev-dependencies --up-to-date --no-dependency-overrides`.

[`args`]: https://pub.dev/packages/args
[`build_cli_annotations`]: https://pub.dev/packages/build_cli_annotations
[`colorize`]: https://pub.dev/packages/colorize
[`js`]: https://pub.dev/packages/js
[`meta`]: https://pub.dev/packages/meta
[`path`]: https://pub.dev/packages/path
[`puppeteer`]: https://pub.dev/packages/puppeteer
[`shelf`]: https://pub.dev/packages/shelf
[`shelf_static`]: https://pub.dev/packages/shelf_static
[`shelf_web_socket`]: https://pub.dev/packages/shelf_web_socket
[`tuple`]: https://pub.dev/packages/tuple
[`uuid`]: https://pub.dev/packages/uuid
[`web_socket_channel`]: https://pub.dev/packages/web_socket_channel
[`yaml`]: https://pub.dev/packages/yaml
[`archive`]: https://pub.dev/packages/archive
[`async`]: https://pub.dev/packages/async
[`collection`]: https://pub.dev/packages/collection
[`convert`]: https://pub.dev/packages/convert
[`crypto`]: https://pub.dev/packages/crypto
[`http`]: https://pub.dev/packages/http
[`http_parser`]: https://pub.dev/packages/http_parser
[`logging`]: https://pub.dev/packages/logging
[`mime`]: https://pub.dev/packages/mime
[`petitparser`]: https://pub.dev/packages/petitparser
[`pointycastle`]: https://pub.dev/packages/pointycastle
[`pool`]: https://pub.dev/packages/pool
[`source_span`]: https://pub.dev/packages/source_span
[`stack_trace`]: https://pub.dev/packages/stack_trace
[`stream_channel`]: https://pub.dev/packages/stream_channel
[`string_scanner`]: https://pub.dev/packages/string_scanner
[`term_glyph`]: https://pub.dev/packages/term_glyph
[`typed_data`]: https://pub.dev/packages/typed_data


### [*] 10/10 points: Package supports latest stable Dart and Flutter SDKs


## ✓ Support sound null safety (20 / 20)
### [*] 20/20 points: Package and dependencies are fully migrated to null safety!


Points: 120/130.
error: Recipe `dart_linter_pana` failed on line 163 with exit code 127

Is this an issue?

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 16, 2023

Invalid argument(s): Path "frb_dart/pubspec.yaml" is not normalized.

Looks like justfile has a bug?

@dbsxdbsx
Copy link
Contributor Author

dbsxdbsx commented Mar 16, 2023

Invalid argument(s): Path "frb_dart/pubspec.yaml" is not normalized.

Looks like justfile has a bug?

I guess so. And take a look at here:

Please provide a valid [`repository`](https://dart.dev/tools/pub/pubspec#repository) URL in `pubspec.yaml`, such that:

 * `repository` can be cloned,
 * a clone of the repository contains a `pubspec.yaml`, which:,
    * contains `name: flutter_rust_bridge`,
    * contains a `version` property, and,
    * does not contain a `publish_to` property.

Unable to parse `pubspec.yaml` from git repository. Invalid argument(s): Path "frb_dart/pubspec.yaml" is not normalized.
</details>

Even changing the field repository into https://github.com/fzyzcjy/flutter_rust_bridge.git with a git format, it still failed. Because frb_dart is not at the root of the whole project. I have no idea how to fix it.

And I wonder whether no other contributors ever mentioned this? Does it only occur on win10,which I work on?

@dbsxdbsx
Copy link
Contributor Author

dbsxdbsx commented Mar 16, 2023

Meanwhile, the git action issue here is weird. Running just check_no_git_diff locally shows nothing changed. But the CI failed. And this strange thing doesn't occur for my first commit yesterday.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 16, 2023

Hmm can it be caused by version bumps?

cc @Desdaemon - are you using windows and did you see the problem?

Mine on macos:

(base) ➜  flutter_rust_bridge git:(master) just dart_linter_pana
flutter pub global activate pana
Package pana is currently active at version 0.21.27.
Resolving dependencies...
The package pana is already activated at newest available version.
To recompile executables, first run `flutter pub global deactivate pana`.
Installed executable pana.
Activated pana 0.21.27.
cd frb_dart && pana --no-warning --line-length 80 --exit-code-threshold 0
INFO       Running `/Users/tom/fvm/versions/3.7.7/bin/cache/dart-sdk/bin/dart --no-analytics --version`...
INFO       Running `flutter --suppress-analytics --no-version-check --version --machine`...
INFO       Running `git rev-parse --show-toplevel`...
INFO       Running `/Users/tom/fvm/versions/3.7.7/bin/cache/dart-sdk/bin/dart --no-analytics pub get --no-example`...
INFO       Running `/Users/tom/fvm/versions/3.7.7/bin/cache/dart-sdk/bin/dart --no-analytics pub outdated --json --up-to-date --no-dev-dependencies --no-dependency-overrides`...
INFO       Analyzing package...
INFO       Running `/Users/tom/fvm/versions/3.7.7/bin/cache/dart-sdk/bin/dart --no-analytics analyze --format machine bin`...
INFO       Running `/Users/tom/fvm/versions/3.7.7/bin/cache/dart-sdk/bin/dart --no-analytics analyze --format machine lib`...
INFO       Running `git init`...
INFO       Running `git remote add origin https://github.com/fzyzcjy/flutter_rust_bridge`...
INFO       Running `git remote show origin`...
INFO       Running `git fetch --depth 1 --no-recurse-submodules origin master`...
INFO       Running `git ls-tree -r --name-only --full-tree origin/master`...
INFO       Running `git show origin/master:frb_dart/pubspec.yaml`...
INFO       Running `git show origin/master:frb_example/pure_dart/dart/pubspec.yaml`...
INFO       Running `git show origin/master:frb_example/pure_dart_multi/dart/pubspec.yaml`...
INFO       Running `git show origin/master:frb_example/with_flutter/pubspec.yaml`...
INFO       Running `/Users/tom/fvm/versions/3.7.7/bin/cache/dart-sdk/bin/dart --no-analytics format --output=none --set-exit-if-changed --line-length 80 /private/var/folders/j5/j6ymn7yd70564hzt31pq_0g80000gn/T/pana_li6Pqv/frb_dart/bin`...
INFO       Running `/Users/tom/fvm/versions/3.7.7/bin/cache/dart-sdk/bin/dart --no-analytics format --output=none --set-exit-if-changed --line-length 80 /private/var/folders/j5/j6ymn7yd70564hzt31pq_0g80000gn/T/pana_li6Pqv/frb_dart/lib`...

## ✓ Follow Dart file conventions (30 / 30)
### [*] 10/10 points: Provide a valid `pubspec.yaml`


### [*] 5/5 points: Provide a valid `README.md`


### [*] 5/5 points: Provide a valid `CHANGELOG.md`


### [*] 10/10 points: Use an OSI-approved license

Detected license: `MIT`.

## ✓ Provide documentation (10 / 10)
### [*] 10/10 points: Package has an example


## ✓ Platform support (20 / 20)
### [*] 20/20 points: Supports 6 of 6 possible platforms (**iOS**, **Android**, **Web**, **Windows**, **MacOS**, **Linux**)

* ✓ Android
* ✓ iOS
* ✓ Windows
* ✓ Linux
* ✓ MacOS
* ✓ Web

## ✓ Pass static analysis (30 / 30)
### [*] 30/30 points: code has no errors, warnings, lints, or formatting issues


## ✓ Support up-to-date dependencies (20 / 20)
### [*] 10/10 points: All of the package dependencies are supported in the latest version

|Package|Constraint|Compatible|Latest|
|:-|:-|:-|:-|
|[`args`]|`^2.3.1`|2.4.0|2.4.0|
|[`build_cli_annotations`]|`^2.1.0`|2.1.0|2.1.0|
|[`colorize`]|`^3.0.0`|3.0.0|3.0.0|
|[`js`]|`^0.6.4`|0.6.7|0.6.7|
|[`meta`]|`^1.3.0`|1.9.0|1.9.0|
|[`path`]|`^1.8.1`|1.8.3|1.8.3|
|[`puppeteer`]|`^2.12.0`|2.23.0|2.23.0|
|[`shelf`]|`^1.3.2`|1.4.0|1.4.0|
|[`shelf_static`]|`^1.1.1`|1.1.1|1.1.1|
|[`shelf_web_socket`]|`^1.0.2`|1.0.3|1.0.3|
|[`tuple`]|`^2.0.1`|2.0.1|2.0.1|
|[`uuid`]|`^3.0.6`|3.0.7|3.0.7|
|[`web_socket_channel`]|`^2.2.0`|2.3.0|2.3.0|
|[`yaml`]|`^3.1.1`|3.1.1|3.1.1|

<details><summary>Transitive dependencies</summary>

|Package|Constraint|Compatible|Latest|
|:-|:-|:-|:-|
|[`archive`]|-|3.3.6|3.3.6|
|[`async`]|-|2.11.0|2.11.0|
|[`collection`]|-|1.17.1|1.17.1|
|[`convert`]|-|3.1.1|3.1.1|
|[`crypto`]|-|3.0.2|3.0.2|
|[`http`]|-|0.13.5|0.13.5|
|[`http_parser`]|-|4.0.2|4.0.2|
|[`logging`]|-|1.1.1|1.1.1|
|[`mime`]|-|1.0.4|1.0.4|
|[`petitparser`]|-|5.3.0|5.3.0|
|[`pointycastle`]|-|3.6.2|3.6.2|
|[`pool`]|-|1.5.1|1.5.1|
|[`source_span`]|-|1.9.1|1.9.1|
|[`stack_trace`]|-|1.11.0|1.11.0|
|[`stream_channel`]|-|2.1.1|2.1.1|
|[`string_scanner`]|-|1.2.0|1.2.0|
|[`term_glyph`]|-|1.2.1|1.2.1|
|[`typed_data`]|-|1.3.1|1.3.1|
</details>

To reproduce run `dart pub outdated --no-dev-dependencies --up-to-date --no-dependency-overrides`.

[`args`]: https://pub.dev/packages/args
[`build_cli_annotations`]: https://pub.dev/packages/build_cli_annotations
[`colorize`]: https://pub.dev/packages/colorize
[`js`]: https://pub.dev/packages/js
[`meta`]: https://pub.dev/packages/meta
[`path`]: https://pub.dev/packages/path
[`puppeteer`]: https://pub.dev/packages/puppeteer
[`shelf`]: https://pub.dev/packages/shelf
[`shelf_static`]: https://pub.dev/packages/shelf_static
[`shelf_web_socket`]: https://pub.dev/packages/shelf_web_socket
[`tuple`]: https://pub.dev/packages/tuple
[`uuid`]: https://pub.dev/packages/uuid
[`web_socket_channel`]: https://pub.dev/packages/web_socket_channel
[`yaml`]: https://pub.dev/packages/yaml
[`archive`]: https://pub.dev/packages/archive
[`async`]: https://pub.dev/packages/async
[`collection`]: https://pub.dev/packages/collection
[`convert`]: https://pub.dev/packages/convert
[`crypto`]: https://pub.dev/packages/crypto
[`http`]: https://pub.dev/packages/http
[`http_parser`]: https://pub.dev/packages/http_parser
[`logging`]: https://pub.dev/packages/logging
[`mime`]: https://pub.dev/packages/mime
[`petitparser`]: https://pub.dev/packages/petitparser
[`pointycastle`]: https://pub.dev/packages/pointycastle
[`pool`]: https://pub.dev/packages/pool
[`source_span`]: https://pub.dev/packages/source_span
[`stack_trace`]: https://pub.dev/packages/stack_trace
[`stream_channel`]: https://pub.dev/packages/stream_channel
[`string_scanner`]: https://pub.dev/packages/string_scanner
[`term_glyph`]: https://pub.dev/packages/term_glyph
[`typed_data`]: https://pub.dev/packages/typed_data


### [*] 10/10 points: Package supports latest stable Dart and Flutter SDKs


## ✓ Support sound null safety (20 / 20)
### [*] 20/20 points: Package and dependencies are fully migrated to null safety!


Points: 130/130.

@dbsxdbsx
Copy link
Contributor Author

Meanwhile, the git action issue here is weird. Running just check_no_git_diff locally shows nothing changed. But the CI failed. And this strange thing doesn't occur for my first commit yesterday.

I worked it around by adding the missing comment line in cf8164e.

Ready for review.

Copy link
Owner

@fzyzcjy fzyzcjy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to merge after the hook thing :)

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 16, 2023

A bit more context about hooks: e.g. rust-lang/rust#92649 says "the common use case" as:

let prev = panic::take_hook();
panic::set_hook(Box::new(move |info| {
    println!("panic handler A");
    prev(info);
}));

so we can just do this.

(note that I am not saying we should use the update_hook function in issue92649, since it is unstable now)

@Desdaemon
Copy link
Contributor

No, I haven't been using Windows recently but I can check if the problem persists.

@fzyzcjy fzyzcjy merged commit ab35b14 into fzyzcjy:master Mar 17, 2023
@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 17, 2023

Well done :)

@Desdaemon
Copy link
Contributor

I was able to determine that the issue @dbsxdbsx encountered is an upstream issue. A sample script:

import 'package:path/path.dart' as p;

void main() {
  final path = 'frb_dart/pubspec.yaml';
  print({
    'path': path,
    'normalized': p.normalize(path),
  });
}

yields

❯ dart .\test.dart
{path: frb_dart/pubspec.yaml, normalized: frb_dart\pubspec.yaml}

and yet Pana expects normalization to be a no-op here:

https://github.com/dart-lang/pana/blob/46dfe081dbd79abe35d8ed99353b5634a5cf5c7a/lib/src/repository/git_local_repository.dart#L222-L224

Don't know what's the expected behavior here, might open an issue upstream later.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 17, 2023

@Desdaemon Then, shall we somehow input the path as pubspec.yaml and change working directory? Then there is no problem of / or \

@Desdaemon
Copy link
Contributor

Opened an issue at dart-lang/pana#1207

Czappi pushed a commit to Czappi/flutter_rust_bridge that referenced this pull request Nov 10, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants