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

Ensure that Xref does not see Debugger as a dependency for Kernel #4554

Conversation

bjorng
Copy link
Contributor

@bjorng bjorng commented Feb 26, 2021

The error_handler module in the Kernel application has a call to the
int module in the Debugger application. That call is only there to
make the Debugger work. To avoid that Xref sees Debugger as a
dependency for Kernel, the call to the int module is obfuscated in
the following way:

breakpoint(Module, Func, Args) ->
    (int()):eval(Module, Func, Args).
int() -> int.

That is, the call will show up as a call to an unknown module in
Xref.

With the improved whole-module type analysis introduced in
294d66a (#2100), the compiler sees through the obfuscation
and rewrites the code to:

breakpoint(Module, Func, Args) ->
    int:eval(Module, Func, Args).

It would be fun to solve this issue by introducing further obfuscations,
but such tricks could stop working in the future when the compiler is
improved. Instead, turn off whole-module type analysis by compiling
the module with the no_module_opt option.

Resolves #4546

The `error_handler` module in the Kernel application has a call to the
`int` module in the Debugger application. That call is only there to
make the Debugger work. To avoid that Xref sees Debugger as a
dependency for Kernel, the call to the `int` module is obfuscated in
the following way:

    breakpoint(Module, Func, Args) ->
        (int()):eval(Module, Func, Args).
    int() -> int.

That is, the call will show up as a call to an unknown module in
Xref.

With the improved whole-module type analysis introduced in
294d66a (erlang#2100), the compiler sees through the obfuscation
and rewrites the code to:

    breakpoint(Module, Func, Args) ->
        int:eval(Module, Func, Args).

It would be fun to solve this issue by introducing further obfuscations,
but such tricks could stop working in the future when the compiler is
improved. Instead, turn off whole-module type analysis by compiling
the module with the `no_module_opt` option.

Resolves erlang#4546
@bjorng bjorng added team:VM Assigned to OTP team VM fix labels Feb 26, 2021
@bjorng bjorng self-assigned this Feb 26, 2021
@bjorng bjorng linked an issue Feb 26, 2021 that may be closed by this pull request
@bjorng bjorng changed the base branch from maint-22 to maint March 1, 2021 04:40
@bjorng bjorng merged commit 9e4dd54 into erlang:maint Mar 1, 2021
@bjorng bjorng deleted the bjorn/kernel/cut-debugger-dependency/GH-4546/OTP-17223 branch September 3, 2021 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reltool adds debugger to release without any dependency
1 participant