CFLint icon indicating copy to clipboard operation
CFLint copied to clipboard

Null pointer on `!C::b`

Open adamcameron opened this issue 3 years ago • 4 comments

Running CFLint for the first time, I was getting a null pointer exception on one of my files. I managed to distill it down to this repro case:

component {

	function f() {
		return !C::b
	}
}

Where C is a CFC, and b is a static boolean value... the real-world case was far more complicated than this, but this reproduces it for me. The real-world code is legit and works fine. The name of the component and the static variable are longer than single-characters IRL.

Note that the ! is significant. No null pointer unless it is there. n the real code it is in the same expression as the static reference, but not immediately adjacent to it. Something like this:

if (!someObj.someMethod(someParam=SomeCfc::someVar)) {

I have other static references in the file, and they do not cause this issue.

I am running CFLint via the commandbox module (https://www.forgebox.io/view/commandbox-cflint). I strongly suspect this is coming from CFLint though, given the nature of it.

If you can't repro from just that, lemme know and I'll provide more info. You'll need to tell me what additional info you need though, as I've been using this thing for about 30min now, and am completely new to it.

Cheers!

adamcameron avatar Jun 29 '21 12:06 adamcameron

From what I can tell, this is an issue stemming from cfparser and it being able to deal with static constructs and notation.

Is this Lucee or does ACF support static as well these days?

I've tried to make some inroads on that a while ago but struggled and ended up realising that in an ideal world and a much better solution would be CFLint sitting on top of the Lucee parser (and have started having discussions with Micha around that).

TheRealAgentK avatar Jun 29 '21 20:06 TheRealAgentK

ACF also supports statics afaik.

Mark Drew

On 29 Jun 2021, at 21:35, Kai Koenig @.***> wrote:

 From what I can tell, this is an issue stemming from cfparser and it being able to deal with static constructs and notation.

Is this Lucee or does ACF support static as well these days?

I've tried to make some inroads on that a while ago but struggled and ended up realising that in an ideal world CFLint would sit on top of the Lucee parser (and have started having discussions with Micha around that).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

cybersonic avatar Jun 29 '21 20:06 cybersonic

@TheRealAgentK , using a 'live' parser like Lucee's makes sense. The language is evolving a rapid pace - and Lucee is on the bleeding edge.

ryaneberly avatar Jun 30 '21 15:06 ryaneberly

I ran into this today while using a static method reference as the default value on a function argument.

For example, cflint cannot parse the file at all if it contains this method (specifically the default value for the options argument)

public UserBean function getById( struct options = { "datasource": libs.udfs::getCustomerDatasource() } ) {
	return queryExecute( "sql": "...", "params": {...}, "options": arguments.options);
}

CFLint ignoring the line with the static reference doesn't make a difference, it still throws a null pointer exception on the first line of the file (which is just a comment).

If I update the method to this, it still works as expected and cflint (or cfparser) no longer bombs on it.

public UserBean function getById( struct options ) {
	arguments["options"] = arguments?.options ?: { "datasource": libs.udfs::getCustomerDatasource() };
	return queryExecute( "sql": "...", "params": {...}, "options": arguments.options );
}

Full stack below (https://github.com/jsteinshouer/commandbox-cflint/blob/master/commands/cflint.cfc#L347)

com.cflint.exception.CFLintScanException: java.lang.NullPointerException
        at com.cflint.CFLint.process(CFLint.java:346)
        at com.cflint.CFLint.scan(CFLint.java:294)
        at com.cflint.CFLint.scan(CFLint.java:280)
        at com.cflint.CFLint.scan(CFLint.java:204)
        at com.cflint.api.CFLintAPI.scan(CFLintAPI.java:66)
        at jdk.internal.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at lucee.runtime.reflection.pairs.MethodInstance.invoke(MethodInstance.java:56)
        at lucee.runtime.reflection.Reflector.callMethod(Reflector.java:877)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:831)
        at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1762)
        at modules.commandbox_cflint495.commands.cflint_cfc$cf.udfCall1(/commandbox/modules/commandbox-cflint/commands/cflint.cfc:347)
        at modules.commandbox_cflint495.commands.cflint_cfc$cf.udfCall(/commandbox/modules/commandbox-cflint/commands/cflint.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
        at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:786)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
        at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1762)
        at modules.commandbox_cflint495.commands.cflint_cfc$cf.udfCall1(/commandbox/modules/commandbox-cflint/commands/cflint.cfc:213)
        at modules.commandbox_cflint495.commands.cflint_cfc$cf.udfCall(/commandbox/modules/commandbox-cflint/commands/cflint.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
        at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:786)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
        at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1762)
        at modules.commandbox_cflint495.commands.cflint_cfc$cf.udfCall1(/commandbox/modules/commandbox-cflint/commands/cflint.cfc:140)
        at modules.commandbox_cflint495.commands.cflint_cfc$cf.udfCall(/commandbox/modules/commandbox-cflint/commands/cflint.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
        at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:786)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
        at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1762)
        at modules.commandbox_cflint495.commands.cflint_cfc$cf.udfCall1(/commandbox/modules/commandbox-cflint/commands/cflint.cfc:100)
        at modules.commandbox_cflint495.commands.cflint_cfc$cf.udfCall(/commandbox/modules/commandbox-cflint/commands/cflint.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:698)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585)
        at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1951)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866)
        at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1781)
        at system.services.commandservice_cfc$cf.udfCall1(/commandbox/system/services/CommandService.cfc:443)
        at system.services.commandservice_cfc$cf.udfCall(/commandbox/system/services/CommandService.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213)
        at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:804)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866)
        at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1781)
        at system.services.commandservice_cfc$cf.udfCall1(/commandbox/system/services/CommandService.cfc:225)
        at system.services.commandservice_cfc$cf.udfCall(/commandbox/system/services/CommandService.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:697)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585)
        at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1932)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
        at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1762)
        at system.shell_cfc$cf.udfCall4(/commandbox/system/Shell.cfc:819)
        at system.shell_cfc$cf.udfCall(/commandbox/system/Shell.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:697)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585)
        at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1932)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
        at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1762)
        at system.services.packageservice_cfc$cf.udfCall3(/commandbox/system/services/PackageService.cfc:1325)
        at system.services.packageservice_cfc$cf.udfCall(/commandbox/system/services/PackageService.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:698)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585)
        at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1951)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866)
        at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1781)
        at system.modules_app.package_commands360.commands._package.run_script_cfc180$cf.udfCall(/commandbox/system/modules_app/package-commands/commands/package/run-script.cfc:49)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:698)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585)
        at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1951)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866)
        at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1781)
        at system.services.commandservice_cfc$cf.udfCall1(/commandbox/system/services/CommandService.cfc:443)
        at system.services.commandservice_cfc$cf.udfCall(/commandbox/system/services/CommandService.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213)
        at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:804)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866)
        at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1781)
        at system.services.commandservice_cfc$cf.udfCall1(/commandbox/system/services/CommandService.cfc:225)
        at system.services.commandservice_cfc$cf.udfCall(/commandbox/system/services/CommandService.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:697)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585)
        at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1932)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
        at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1762)
        at system.shell_cfc$cf.udfCall4(/commandbox/system/Shell.cfc:819)
        at system.shell_cfc$cf.udfCall(/commandbox/system/Shell.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213)
        at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:804)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866)
        at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1781)
        at system.shell_cfc$cf.udfCall3(/commandbox/system/Shell.cfc:634)
        at system.shell_cfc$cf.udfCall(/commandbox/system/Shell.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
        at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:698)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585)
        at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1951)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866)
        at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1781)
        at commandbox.cfml.system.bootstrap_cfm$cf.call(/CommandBox/cfml/system/Bootstrap.cfm:160)
        at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1043)
        at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:935)
        at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:916)
        at nkx9ifxwklmz.call(Unknown Source)
        at lucee.runtime.compiler.Renderer.tag(Renderer.java:107)
        at lucee.runtime.compiler.Renderer.script(Renderer.java:97)
        at lucee.runtime.jsr223.ScriptEngineImpl.eval(ScriptEngineImpl.java:65)
        at lucee.runtime.jsr223.ScriptEngineImpl.eval(ScriptEngineImpl.java:220)
        at cliloader.LoaderCLIMain.execute(LoaderCLIMain.java:328)
        at cliloader.LoaderCLIMain.execute(LoaderCLIMain.java:155)
        at cliloader.LoaderCLIMain.main(LoaderCLIMain.java:580)

bhartsfield avatar Aug 02 '22 14:08 bhartsfield