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

VM: Missing test coverage for code GC #17614

Closed
fsc8000 opened this issue Mar 19, 2014 · 9 comments
Closed

VM: Missing test coverage for code GC #17614

fsc8000 opened this issue Mar 19, 2014 · 9 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@fsc8000
Copy link
Contributor

fsc8000 commented Mar 19, 2014

Our tests do not reliably cover code collection. E.g. I tried running tests with deliberately resetting the Function's code-pointer with a random integer on a code collection and there is no crash.

@zanderso
Copy link
Member

There are two flags that control code collection: --code_collection_interval_in_us, which you can set to 0, and --always_drop_code, which causes code to be dropped regardless of the functions use count.

Do you encounter the same problem when you run with those flags?


Added NeedsInfo label.

@fsc8000
Copy link
Contributor Author

fsc8000 commented Mar 19, 2014

Yes, I know. None of our tests are run with these flags.

@fsc8000
Copy link
Contributor Author

fsc8000 commented Mar 19, 2014

I found this test code_collection_test.dart, but it seems that overwriting the code with a random value on GC does not make it crash as it should.

@zanderso
Copy link
Member

Could you explain a bit more what you mean by "overwriting the code with a random value on GC", or maybe paste a small patch here? Thanks.

@fsc8000
Copy link
Contributor Author

fsc8000 commented Mar 19, 2014

I tried the following diff: I think the test does not actually call foo after code GC happened. Othwerwise, it would fine 123 as the code pointer. I do get a crash when running test.py with --vm-options="--code_collection_interval_in_us=0", but that flag in not on by default.

Index: runtime/vm/gc_marker.cc
===================================================================

--- runtime/vm/gc_marker.cc (revision 34110)
+++ runtime/vm/gc_marker.cc (working copy)
@@ -249,8 +249,8 @­@
         // If the code wasn't strongly visited through other references
         // after skipping the function's code pointer, then we disconnect the
         // code from the function.

  •    func->ptr()->code_ = Code::null();
    
  •    func->ptr()->unoptimized_code_ = Code::null();
    
  •    func->ptr()->code_ = reinterpret_cast<RawCode*>(123); //Code::null();
    
  •    func->ptr()->unoptimized_code_ = reinterpret_cast<RawCode*>(456); // Code::null();
    
             if (FLAG_log_code_drop) {
               // NOTE: This code runs while GC is in progress and runs within
               // a NoHandleScope block. Hence it is not okay to use a regular Zone
    Index: tests/standalone/io/code_collection_test.dart
    ===================================================================

--- tests/standalone/io/code_collection_test.dart (revision 34110)
+++ tests/standalone/io/code_collection_test.dart (working copy)
@@ -34,6 +34,7 @­@
       timer.cancel();
       // foo is called again to make sure we can still run it even after
       // its code has been detached.

  •  throw 123;
    
           foo(2);
         }
       });
    @@ -57,6 +58,7 @­@
         // Code drops are logged with --log-code-drop. Look through stdout for the
         // message that foo's code was dropped.
         var found = false;
  • print(pr.stdout);
         pr.stdout.split("\n").forEach((line) {
           if (line.contains("Detaching code") && line.contains("foo")) {
             found = true;

@fsc8000
Copy link
Contributor Author

fsc8000 commented Nov 10, 2014

Any updates on this?

@iposva-google
Copy link
Contributor

Florian, apparently you did have a test setup that was covering the problem. Why did you not submit that version of the test?

It seems that the test is not checking the return code of the dart process it spawned.


Added Accepted label.

@fsc8000
Copy link
Contributor Author

fsc8000 commented Nov 10, 2014

I don't remember precisely, but I don't think I have a fixed version of the test (or I can't find it anymore). The patch set above just illustrates the issue (i.e. foo is not called after code GC)

@fsc8000 fsc8000 added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. labels Nov 10, 2014
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@zanderso
Copy link
Member

The test is now checking the exit code of the spawned process, and has otherwise been hardened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants