thread scope being reported as unscoped

Description

1. unscoped, thread scoped variables aren't being resolved inside a thread

Preview unavailable

https://docs.lucee.org/guides/developing-with-lucee-server/scope.html
https://github.com/lucee/Lucee/blob/5.3/core/src/main/java/lucee/runtime/type/scope/UndefinedImpl.java#L215

2. implicit scope access, reports thread scope when accessing a thread scoped variable within a thread?

Preview unavailable
<cfscript> echo("<h1>" & server.lucee.version & "</h1>"); s = getTickCount(); url.bingo = 1; dump(var=bingo, label="unscoped url access outside thread"); function napASecond(idx) localmode=true { var _index = duplicate(arguments.idx); thread._idx = _index; dump(var=thread, label="#_index#) thread scope before thread()"); thread name="thread-#_index#" { //thread.index = index*1000; //dump(var=thread, label="#_index#) thread access inside thread #thread.name# START"); thread._start=now(); sleep(500) thread._end=now(); thread.vars = structKeyList(thread); dump(var=thread, label="#thread.name#) thread access inside thread"); dump(var=bingo, label="#thread.name#) unscoped url access inside thread FINISH"); thread.implicitAccess = getPageContext().getDebugger().getDebuggingData(getPageContext()).implicitAccess; dump(var=_start, label="#thread.name#) unscoped thread access inside thread"); // should resolve to thread._start } dump(var=thread, label="#_index#) thread scope after thread()"); } start=getTickCount(); loop from=1 to=2 index="loopIndex" { napASecond(loopIndex); } function dumpThreads(threads, label){ echo("<h2>" & arguments.label & "</h2>"); for (var _t in arguments.threads){ //dump(arguments); dump(var=arguments.threads[_t], label="#_t#"); echo("<blockquote>" & arguments.threads[_t].output & "</blockquote>"); echo("<hr>"); } } // show threads dumpThreads(cfthread, "Before Threads joined"); // wait for all threads to finish thread action="join" name=cfthread.keyList(); // show threads dumpThreads(cfthread, "After Threads joined"); dump("done in #getTickCount()-start#ms"); dump(getPageContext().getDebugger().getDebuggingData(getPageContext()).implicitAccess); </cfscript>

Environment

None

Activity

Show:

Zac Spitzer 30 October 2024 at 12:35

Michael Offner 17 October 2024 at 16:22

thread also is not a real scope in Lucee

Zac Spitzer 18 October 2022 at 15:34

this code

 thread name="thread-2773" {         thread.test2773 = "2773";         thread.inThread = isInThread();         thread.keys =  structKeyList(thread);         thread.scope= getPageContext().getThreadScopeNames();         url.zac=1;

generates the following bytecode

paramPageContext.set(paramPageContext.touch(paramPageContext.us(), this.keys[2]), this.keys[3], "2773"); paramPageContext.set(paramPageContext.touch(paramPageContext.us(), this.keys[2]), this.keys[4], Caster.toRef(IsInThread.call(paramPageContext))); paramPageContext.set(paramPageContext.touch(paramPageContext.us(), this.keys[2]), this.keys[5], StructKeyList.call(paramPageContext, Caster.toStruct(paramPageContext.us().get(this.keys[2])))); paramPageContext.set(paramPageContext.touch(paramPageContext.us(), this.keys[2]), KeyConstants._SCOPE, paramPageContext.getFunction(GetPageContext.call(paramPageContext), this.keys[6], Constants.EMPTY_OBJECT_ARRAY)); paramPageContext.urlScope().set(this.keys[7], ConstantsDouble._1); CFFunction.call(paramPageContext, new Object[] { FunctionValueImpl

thread isn’t being treated a scope here, it’s falling back on the undefined logic, hence why it’s slower, and reporting as unscoped

Unresolved

Details

Assignee

Reporter

Priority

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 18 October 2022 at 15:33
Updated 30 October 2024 at 12:35

Flag notifications