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

Prevent hard crash on duplicate plugin paths #1650

Merged
merged 1 commit into from
Nov 2, 2017

Conversation

ferd
Copy link
Collaborator

@ferd ferd commented Oct 20, 2017

When a global plugin is used both locally and within the project, there
are cases when the rebar3 program will hard crash (killed in do_boot).
This has been traced to plugin-handling in compilation, where the same
code path may be purged twice in a row without further reloading for the
compile operation.

This of course yields the result where the code handling on the VM kills
all processes holding references to the module in memory, in this case
the rebar3 process itself.

By deduplicating the paths first, we ensure at most one purge before
reloading plugins and paths, and this prevents a hard crash.

When a global plugin is used both locally and within the project, there
are cases when the rebar3 program will hard crash (killed in do_boot).
This has been traced to plugin-handling in compilation, where the same
code path may be purged twice in a row without further reloading for the
compile operation.

This of course yields the result where the code handling on the VM kills
all processes holding references to the module in memory, in this case
the rebar3 process itself.

By deduplicating the paths first, we ensure at most one purge before
reloading plugins and paths, and this prevents a hard crash.
@eproxus
Copy link
Contributor

eproxus commented Oct 23, 2017

Is this coming to nightly soon?

@ferd
Copy link
Collaborator Author

ferd commented Oct 23, 2017

I'm awaiting some review from @tsloughter or @talentdeficit

@ferd
Copy link
Collaborator Author

ferd commented Nov 2, 2017

I'll merge this; if @tsloughter can think of a better fix, we can always revert and fix then.

@ferd ferd merged commit a1b1df4 into erlang:master Nov 2, 2017
@eproxus
Copy link
Contributor

eproxus commented Dec 5, 2017

@ferd Found more weird issues related to this. Apparently it works with Rebar3 3.4.4 but not latest master:

3.4.4

$ rebar3 --version
===> Compiling rebar3_grisp
===> Compiling rebar3_grisp
rebar 3.4.4 on Erlang/OTP 19 Erts 8.3
$ rebar3 grisp deploy -n robot -v 0.1.0
===> Compiling rebar3_grisp
===> Compiling rebar3_grisp
===> Compiling rebar3_grisp
===> Compiling rebar3_grisp
===> [{relname,"robot"},{relvsn,"0.1.0"},{force,false}]
===> Current Erlang version ("19") does not match target Erlang version (undefined). It is not guaranteed that the deployed release will work!
===> Compiling rebar3_grisp
===> Compiling rebar3_grisp
===> Verifying dependencies...
===> Compiling grisp
===> Compiling robot
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
          .../robot/_build/grisp/lib
          .../robot/_checkouts
          .../robot/_grisp/otp/19.3.6/install
          .../robot/_build/grisp/rel
===> Resolved robot-0.1.0
===> Including Erts from .../robot/_grisp/otp/19.3.6/install
===> release successfully created!
===> Deploying robot-0.1.0 to /Volumes/GRISP
* Running pre_script
* Copying files...
* Copying release...
* Running post_script
Volume GRISP on disk2s1 unmounted

3.4.7+build.3957.ref46ea7e1e

$ rebar3 --version
===> Compiling rebar3_grisp
===> Compiling rebar3_grisp
rebar 3.4.7+build.3957.ref46ea7e1e on Erlang/OTP 19 Erts 8.3
$ rebar3 grisp deploy -n robot -v 0.1.0
===> Compiling rebar3_grisp
===> Compiling rebar3_grisp
===> Compiling rebar3_grisp
===> Compiling rebar3_grisp
===> [{relname,"robot"},{relvsn,"0.1.0"},{force,false}]
===> Current Erlang version ("19") does not match target Erlang version (undefined). It is not guaranteed that the deployed release will work!
===> Compiling rebar3_grisp
===> Compiling rebar3_grisp
{"init terminating in do_boot",killed}
init terminating in do_boot (killed)

Crash dump is being written to: erl_crash.dump...

(Note the double plugin compiled from both a local rebar.config and the global plugin.

@eproxus
Copy link
Contributor

eproxus commented Dec 5, 2017

Some more research:

Working Versions

  • 3.4.4
  • 3.4.5
  • 3.4.6

Broken Versions

  • 3.4.7

    Fails with:

    $ rebar3 grisp deploy -n robot -v 0.1.0
    ===> Compiling rebar3_grisp
    ===> Compiling rebar3_grisp
    ===> Compiling rebar3_grisp
    ===> Plugin rebar3_grisp not available. It will not be used.
    ===> Compiling rebar3_grisp
    ===> Plugin rebar3_grisp not available. It will not be used.
    ===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
    ===> When submitting a bug report, please include the output of `rebar3 report "your command"`
    

    Running with DEBUG=1 shows:

    ...
    ===> Uncaught error: undef
    ===> Stack trace to the error location:
    [{rebar3_grisp_deploy,do,
        ...
    

    Which means the plugin wasn't even found (even though it was compiled four (!) times above.

  • master

    Fails with:

    $ rebar3 grisp deploy -n robot -v 0.1.0
    ===> Compiling rebar3_grisp
    ===> Compiling rebar3_grisp
    ===> Compiling rebar3_grisp
    ===> Compiling rebar3_grisp
    ===> [{relname,"robot"},{relvsn,"0.1.0"},{force,false}]
    ===> Current Erlang version ("19") does not match target Erlang version (undefined). It is not guaranteed that the deployed release will work!
    ===> Compiling rebar3_grisp
    ===> Compiling rebar3_grisp
    {"init terminating in do_boot",killed}
    init terminating in do_boot (killed)
    
    Crash dump is being written to: erl_crash.dump...
    

@ferd
Copy link
Collaborator Author

ferd commented Dec 5, 2017

Ugh, I'm betting there's more stuff related to plugins paths here. I'll have to take a look a bit later. Possibly related to the following series of patches:

I'm guessing the global plugin path is lost on the newest one, so the fix may not be super hard.

@ferd
Copy link
Collaborator Author

ferd commented Dec 5, 2017

See #1686 @eproxus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants