Custom setter that assigns to this scope causes stack overflow with implicit accessor invocation

Description

When calling:

createObject('component', 'DoubleInit').init()

With a double init component of:

<cfcomponent displayname="DoubleInit" namespace="DoubleInit" output="no"> <cfproperty name="tabs" default="0" type="numeric" /> <cffunction name="init" access="public" output="no" returntype="any"> <cfargument name="tabs" type="numeric" required="no" default="0" /> <cfset this.tabs = arguments.tabs /> <cfreturn this> </cffunction> <cffunction name="setTabs" access="public" output="no" returntype="any"> <cfargument name="tabs" type="numeric" required="no" default="#this.tabs#" /> <cfset this.tabs = arguments.tabs /> </cffunction> </cfcomponent>

A stack overflow error will occur:

java.lang.StackOverflowError at ortus.boxlang.runtime.interop.DynamicObject.unWrap(DynamicObject.java:553) at ortus.boxlang.runtime.dynamic.casters.StringCaster.cast(StringCaster.java:131) at ortus.boxlang.runtime.dynamic.casters.StringCaster.cast(StringCaster.java:111) at ortus.boxlang.runtime.dynamic.casters.StringCaster.cast(StringCaster.java:99) at ortus.boxlang.runtime.dynamic.casters.GenericCaster.cast(GenericCaster.java:141) at ortus.boxlang.runtime.dynamic.casters.GenericCaster.cast(GenericCaster.java:124) at ortus.boxlang.runtime.dynamic.casters.GenericCaster.attempt(GenericCaster.java:80) at ortus.boxlang.runtime.util.ArgumentUtil.ensureArgumentType(ArgumentUtil.java:268) at ortus.boxlang.runtime.util.ArgumentUtil.createArgumentsScope(ArgumentUtil.java:63) at ortus.boxlang.runtime.context.FunctionBoxContext.<init>(FunctionBoxContext.java:178) at ortus.boxlang.runtime.types.Function.generateFunctionContext(Function.java:409) at ortus.boxlang.runtime.runnables.BoxClassSupport.dereferenceAndInvoke(BoxClassSupport.java:330) at ortus.boxlang.runtime.runnables.BoxClassSupport.assign(BoxClassSupport.java:248) at boxgenerated.boxclass.src.test.java.testcases.phase3.Doubleinit$cfc.assign(DoubleInit.cfc)

Activity

Show:

Brad Wood March 3, 2025 at 12:54 AM

As noted on Slack, this is because we have invoke implicit accessors defaulting to try in boxlang. this.tabs = foo is trigger this.setTabs(). And since the setTabs method has this.tabs = … inside of it, it’s endless recursion time.

Jon Clausen March 2, 2025 at 11:20 PM

Note: Removing the declared property of the same name will allow the component to instantiate.

Jon Clausen March 2, 2025 at 11:13 PM

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Fix versions

Priority

Sentry

Created March 2, 2025 at 11:10 PM
Updated March 4, 2025 at 5:30 AM
Resolved March 4, 2025 at 5:30 AM

Flag notifications