Codesys v3.5.22.10 - Internal error:System.AggregateException...Value cannot be null...Parameter name: expLValue

vstrom
2026-04-22
9 hours ago
  • vstrom - 2026-04-22

    Hi to all,

    I receive an error when I try to compile a project that in v.3.5.21.50 have no problem.

    The error seems to comes out when I add the Visualization part into the project.

    The complete error is:

    [ERROR] Internal error:System.AggregateException: One or more errors occurred. ---> System.Exception: Internal error in Code ---> System.ArgumentNullException: Value cannot be null. Parameter name: expLValue at _3S.CoDeSys.LanguageModelManager.LanguageModelBuilder.CreateAssignmentExpression(IExprementPosition pos, IExpression expLValue, IExpression expRValue, Operator kindof) at _3S.CoDeSys.LanguageModelManager.LanguageModelBuilder.CreateAssignmentStatement(IExprementPosition pos, IExpression expLeft, IExpression expRight) at ..(IExpression , IExpression ) at ..(_IAssignmentExpression ,  ) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.AssignmentStatementReplacer.ReplaceExpressionStatement(_IExpressionStatement expressionStatement, _ICompiledPOU cpou) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_ISequenceStatement sequenceStatement) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_IIfStatement ifst) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_ISequenceStatement sequenceStatement) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_IIfStatement ifst) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_ISequenceStatement sequenceStatement) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_IForStatement forloop) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_ISequenceStatement sequenceStatement) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_ISequenceStatement sequenceStatement) at ..(_ICompiledPOU ) at ..(_ICompiledPOU ) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Codegeneration.(_ICompiledPOU , _ISignature ) at ..(_ICompiledPOU ) at ..(_ICompiledPOU& ) at ..() --- End of inner exception stack trace --- --- End of inner exception stack trace --- at _3S.CoDeSys.Compiler35220.CompilerPhases.CompilerPhase5_Codegenerator.(IList1 ) at _3S.CoDeSys.Compiler35220.CompilerPhases.CompilerPhase5_Codegenerator.(IScope5 , IList1 ) at _3S.CoDeSys.Compiler35220.CompilerPhases.CompilerPhase5_Codegenerator.(ICodegenerator ) at _3S.CoDeSys.Compiler35220.CompilerPhases.CompilerPhaseControllerGenerateCode.() at _3S.CoDeSys.Compiler35220.CompilerPhases.CompilerPhaseControllerGenerateCode.() ---> (Inner Exception #0) System.Exception: Internal error in Code ---> System.ArgumentNullException: Value cannot be null. Parameter name: expLValue at _3S.CoDeSys.LanguageModelManager.LanguageModelBuilder.CreateAssignmentExpression(IExprementPosition pos, IExpression expLValue, IExpression expRValue, Operator kindof) at _3S.CoDeSys.LanguageModelManager.LanguageModelBuilder.CreateAssignmentStatement(IExprementPosition pos, IExpression expLeft, IExpression expRight) at ..(IExpression , IExpression ) at ..(_IAssignmentExpression ,  ) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.AssignmentStatementReplacer.ReplaceExpressionStatement(_IExpressionStatement expressionStatement, _ICompiledPOU cpou) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_ISequenceStatement sequenceStatement) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_IIfStatement ifst) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_ISequenceStatement sequenceStatement) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_IIfStatement ifst) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_ISequenceStatement sequenceStatement) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_IForStatement forloop) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_ISequenceStatement sequenceStatement) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Optimization.ExpressionStatementReplacerVisitor.visit(_ISequenceStatement sequenceStatement) at ..(_ICompiledPOU ) at ..(_ICompiledPOU ) at _3S.CoDeSys.Compiler35220.Phase5_Codegeneration.Codegeneration.(_ICompiledPOU , _ISignature ) at ..(_ICompiledPOU ) at ..(_ICompiledPOU& ) at ..() --- End of inner exception stack trace ---<---

     
  • hhermsen - 2026-07-11

    Internal compiler error in SP22.x (expLValue null) β€” SP21 unaffected β€” need help isolating root cause
    I'm hitting the same internal compiler crash reported here. Same exact stack trace (AssignmentStatementReplacer β†’ CreateAssignmentExpression β†’ ArgumentNullException: Value cannot be null. Parameter name: expLValue), but in my case triggered by a self-written library, not a Visualization object β€” so this looks like a general SP22.x codegen regression rather than something tied to one specific language feature.

    What I've confirmed:

    Reverting to SP21 β€” no issue, builds clean
    SP22.x β€” internal compiler crash during Build > Application, code generation phase, with zero useful location info (no POU, no line number)
    check_for_errors/precompile-only passes cleanly; the crash only happens on a real full build, meaning static analysis never sees it coming

    What I've tried to isolate the cause (without success):

    Removed a suspected pattern involving a VAR_IN_OUT parameter used directly as a FOR-loop control variable, combined with early RETURN inside the loop β€” crash persisted identically afterward
    Confirmed no Visualization Manager or similar object in the project (ruling out the trigger in the linked report)
    Used an AI coding assistant (Claude Code) to search for other suspicious patterns β€” no luck pinpointing the exact statement

    Question @codesys-com
    Since the compiler gives no location info at all, is there any way to get more diagnostic output from the SP22.x codegen phase (verbose/debug build flags, log level settings, etc.)? Without that, isolating this in a large library means blind bisection β€” cutting the codebase in half repeatedly until the crash disappears, which is slow and error-prone without official tooling support.

    Happy to share the affected project or a minimal repro if that helps CODESYS engineering track it down.

     
  • hhermsen - 2026-07-11

    I pinpointed down 4 possible causes for this compiler error:

    1. Bare/empty statements (;) standing alone inside an IF/CASE branch β€” just removed two instances. The optimizer that tries to inline/replace expression statements may choke when a statement has no actual assignment to extract.

    2. A VAR_IN_OUT parameter used directly as a FOR loop's own control variable (FOR X := X TO Y DO)

    3. General deep-nesting complexity β€” every one of my decode routines has the same shape (IF busy THEN ... FOR loop containing nested CASE/IF chains ... END_IF), and the crash trace consistently shows for loop β†’ sequence β†’ ifst β†’ sequence β†’ ifst β†’ sequence regardless of the code change. This raises the possibility that it's not one specific statement but a structural depth/complexity limit in SP22.x's compiler optimizer β€” which would mean no small code change fixes the issue. Only restructuring to reduce nesting depth, or downgrading the compiler will.

    4. Something entirely outside my library files β€” which cannot not ruled out since the exact stack trace was triggered by a Visualization object, in a totally different codebase. This means the same crash signature can come from unrelated causes.

    IMHO cause 3 seems the most probable one..

     

    Last edit: hhermsen 2026-07-11
  • tristan - 5 days ago

    Hi,

    I have exactly the same issue when I try to update from 3.5.21.50 to 3.5.22.20.
    Currently I didn't find where is the problem.

    Hope somebody can find a way.

    Tristan

     

Log in to post a comment.