8000 Possible NPE in BasicCompilerPassListener:endExecute() found by SAST · Issue #8811 · jruby/jruby · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Possible NPE in BasicCompilerPassListener:endExecute() found by SAST #8811
Closed as not planned
@ngr-ilmarh

Description

@ngr-ilmarh

Our SAST shows possible NullPointerException in https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/ir/passes/BasicCompilerPassListener.java#L45

    public void endExecute(CompilerPass pass, FullInterpreterContext fic, Object data, boolean childScope) {
        Long startTime = times.get(pass);
        long timeTaken = startTime != null ? System.currentTimeMillis() - startTime.longValue() : -1;

...

        if (startTime > 0) {
            LOG.info("Finished " + pass.getLabel() + " on scope in " + timeTaken + "ms.");
        } else { // Not really sure we should allow same pass to be run twice in same pass order run...too defensive?
            LOG.info("Finished " + pass.getLabel() + " on scope " + fic.getScope());
        }
    }

If startTime may be null, then it will cause NPE at startTime > 0.

Maybe it is mistype and conditional should be timeTaken > 0?

Environment Information

We are analyzing versions 9.4.x (8-12), but this problem is still in master

Expected Behavior

  • No NPE at all. But it seems nobody catch it through the years, so i don't know if this Long may hold null at all

Actual Behavior

  • have no tests to show this NPE, can't figure out how to make one. This is simply code analysis, that showed possible NPE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0