-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Segmentation fault in code involving generic functions #48323
Comments
Transferring to the SDK repo. cc @a-siva |
@nightscape thanks for filing the issue, is it is possible for us to get instructions on how we can get a local reproduction of the crash |
@nightscape any possibilities of getting a setup for reproduction |
@a-siva Sorry for taking so long to respond, this slipped under the radar. git clone https://github.com/nightscape/stream_graph.dart.git
cd ./stream_graph.dart/
git checkout a896451677aeb55eeb73bd5959534df8add27164
dart test |
Thanks for the repro.
|
//cc @alexmarkov |
There are 2 bugs triggered on this code:
Small repro: abstract class GraphNode extends Comparable<dynamic> {
int compareTo(dynamic other) => 0;
}
abstract class StreamNode<T> extends GraphNode {}
class TransformNode<S, T> extends StreamNode<T> {}
main() {
print(TransformNode());
}
Small repro: void Function<T>()? genericFunction;
void foo(void Function()? arg) {
print(arg);
}
void main() {
foo(genericFunction);
} The problem is that CFE creates @johnniwinther Could you clarify if this is a valid AST and VM should support this case? |
TEST=vm/dart/regress_48323_1_test Issue: #48323 Change-Id: I50c04a269183c0df5b4ce0ce7be32cd2385e95d8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242601 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
This is related to this issue. I would have expected this code to be a static error (just as implicitly tearing off a call method from a nullable value is a static error), but it seems that neither the analyzer nor the cfe emits an error there. We could make the breaking change to make this an error, or we could specify these to be null aware (in which case the behavior would be essentially to produce |
I could not find any rules about generic function instantiation in the nnbd feature spec. The upcoming update to the language specification where null safety is integrated specifies that generic function instantiation can only take place when the function being instantiated has a function type, not a type of the form However, it would seem reasonable to generalize generic function instantiation to be null-aware if we do the same thing for |
@alexmarkov The CFE shouldn't generate instantiation on a nullable expressions. It should either be an error or converted into |
Debug assertion is fixed in 609ba96. @johnniwinther Could you take a stab at fixing the 2nd bug in the CFE? |
Fix for the CFE in progress: https://dart-review.googlesource.com/c/sdk/+/242869 |
This might be a compile-time error but it should at least not create an Instantiation on a potentially nullable expression. In response to #48323 Change-Id: I6682ddbb8db82623ac7bf4ecf37f8535377f4ca0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242869 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
I believe this issue was fixed by @johnniwinther in 7ab8930. Closing. |
Hi all,
I'm writing a library that allows to build a Directed Acyclic Graph of descriptions of Stream transformations which can then be applied to actual input streams.
One of the core classes is a
StreamNode<T>
from which aStream<T>
will be created, optionally allowing aStreamTransformer<T>
to be retrieved and applied.As the graph has different generic parameters
T
inStreamNode
s, I need to go through some hoops to get the Dart compiler accept my code.In my latest iteration, I thought I had made progress on the issue, but instead I get the Dart to crash with an error like this
The full stack trace can be seen here:
https://github.com/nightscape/stream_graph.dart/runs/5080365009?check_suite_focus=true
I can reproduce this locally on a Mac ARM64 and in an AMD64 Linux env in the Github actions.
Is this something worth looking into, or shall I just go looking for a solution that doesn't make Dart crash?
The text was updated successfully, but these errors were encountered: