Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: NPE when building a service with feature-codegen-optimizer branch #43581

Closed
Thushara-Piyasekara opened this issue Nov 13, 2024 · 4 comments
Labels
Reason/Invalid Issue is invalid. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation

Comments

@Thushara-Piyasekara
Copy link
Contributor

Description

When building a ballerina template service project with feature-codegen-optimizer branch, it fails compilation with the following NPE error,

Compiling source
	thusharapiyasekara/httpService:0.1.0
ballerina: Oh no, something really went wrong. Bad. Sad.

We appreciate it if you can report the code that broke Ballerina in
https://github.com/ballerina-platform/ballerina-lang/issues with the
log you get below and your sample code.

We thank you for helping make us better.

[2024-11-13 21:12:53,937] SEVERE {b7a.log.crash} - Cannot read field "pkgID" because "pkg.symbol" is null 
java.lang.NullPointerException: Cannot read field "pkgID" because "pkg.symbol" is null
	at org.wso2.ballerinalang.compiler.desugar.DeclarativeAuthDesugar.getPackageSymbol(DeclarativeAuthDesugar.java:193)
	at org.wso2.ballerinalang.compiler.desugar.DeclarativeAuthDesugar.addAuthDesugarFunctionInvocation(DeclarativeAuthDesugar.java:134)
	at org.wso2.ballerinalang.compiler.desugar.DeclarativeAuthDesugar.desugarFunction(DeclarativeAuthDesugar.java:102)
	at org.wso2.ballerinalang.compiler.desugar.ServiceDesugar.engageCustomResourceDesugar(ServiceDesugar.java:302)
	at org.wso2.ballerinalang.compiler.desugar.ServiceDesugar.lambda$engageCustomServiceDesugar$3(ServiceDesugar.java:293)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.wso2.ballerinalang.compiler.desugar.ServiceDesugar.engageCustomServiceDesugar(ServiceDesugar.java:293)
	at org.wso2.ballerinalang.compiler.desugar.Desugar.lambda$visit$4(Desugar.java:808)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.wso2.ballerinalang.compiler.desugar.Desugar.visit(Desugar.java:808)
	at org.wso2.ballerinalang.compiler.tree.BLangPackage.accept(BLangPackage.java:167)
	at org.wso2.ballerinalang.compiler.desugar.Desugar.rewrite(Desugar.java:9255)
	at org.wso2.ballerinalang.compiler.desugar.Desugar.perform(Desugar.java:491)
	at io.ballerina.projects.internal.CompilerPhaseRunner.desugar(CompilerPhaseRunner.java:205)
	at io.ballerina.projects.internal.CompilerPhaseRunner.performBirGenPhases(CompilerPhaseRunner.java:141)
	at io.ballerina.projects.ModuleContext.generateCodeInternal(ModuleContext.java:438)
	at io.ballerina.projects.ModuleCompilationState$4.generatePlatformSpecificCode(ModuleCompilationState.java:132)
	at io.ballerina.projects.ModuleContext.generatePlatformSpecificCode(ModuleContext.java:368)
	at io.ballerina.projects.JBallerinaBackend.performCodeGen(JBallerinaBackend.java:216)
	at io.ballerina.projects.JBallerinaBackend.<init>(JBallerinaBackend.java:180)
	at io.ballerina.projects.JBallerinaBackend.lambda$from$0(JBallerinaBackend.java:150)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
	at io.ballerina.projects.PackageCompilation.getCompilerBackend(PackageCompilation.java:179)
	at io.ballerina.projects.JBallerinaBackend.from(JBallerinaBackend.java:149)
	at io.ballerina.projects.JBallerinaBackend.from(JBallerinaBackend.java:137)
	at io.ballerina.cli.task.CompileTask.execute(CompileTask.java:240)
	at io.ballerina.cli.TaskExecutor.executeTasks(TaskExecutor.java:40)
	at io.ballerina.cli.cmd.BuildCommand.execute(BuildCommand.java:308)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)
	at io.ballerina.cli.launcher.Main.main(Main.java:63)
 
ERROR [httpService:(1:1,1:1)] Compilation failed due to: Cannot read field "pkgID" because "pkg.symbol" is null
error: compilation contains errors

Steps to Reproduce

  1. Build the feature-codegen-optimizer branch.
  2. Create a new http service template project with <BAL> new httpService -t service command.
  3. Build the created project with <BAL> build.

Note: replace <BAL> with the path to bal command path of the feature branch. In my case its /ballerina-lang/distribution/zip/jballerina-tools/build/extracted-distributions/jballerina-tools-2201.11.0-SNAPSHOT/bin/bal.

Affected Version(s)

Feature branch feature-codegen-optimizer upto commit 092cc69 as its head.

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Nov 13, 2024
@Thushara-Piyasekara
Copy link
Contributor Author

This error might not be related to the DCE process because it occurs regardless of the --eliminate-dead-code flag

Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@Thushara-Piyasekara
Copy link
Contributor Author

The error was due to not disabling observability in the project.

Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@MaryamZi MaryamZi added Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Reason/Invalid Issue is invalid. and removed needTriage The issue has to be inspected and labeled manually labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reason/Invalid Issue is invalid. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation
Projects
None yet
Development

No branches or pull requests

3 participants