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

[Bazel 5][objc_library]: NullPointerException thrown during Starlark evaluation (//:main_objc) - at <starlark>.create_compilation_attributes(<builtin>:0) #14173

Closed
jerrymarino opened this issue Oct 26, 2021 · 3 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) platform: apple team-Rules-CPP Issues for C++ rules type: bug

Comments

@jerrymarino
Copy link
Contributor

Description of the problem / feature request:

Make variable substitution in objc_library raises a NullPointerException, seems to be missing a test for that code path and was broken recently somewhere on 5.x.x

Caused by: net.starlark.java.eval.Starlark$UncheckedEvalException: NullPointerException thrown during Starlark evaluation (//:main_objc)
        at <starlark>.create_compilation_attributes(<builtin>:0)                                     
        at <starlark>._build_common_variables(/virtual_builtins_bzl/common/objc/compilation_support.bzl:80)
        at <starlark>._objc_library_impl(/virtual_builtins_bzl/common/objc/objc_library.bzl:114)     
Caused by: java.lang.NullPointerException                                                            
        at java.base/java.lang.String.replace(Unknown Source)                                        
        at com.google.devtools.build.lib.rules.objc.ObjcStarlarkInternal.expandFlag(ObjcStarlarkInternal.java:145)
        at com.google.devtools.build.lib.rules.objc.ObjcStarlarkInternal.expandToolchainAndRuleContextVariables(ObjcStarlarkInternal.java:119)
        at com.google.devtools.build.lib.rules.objc.ObjcStarlarkInternal.createCompilationAttributes(ObjcStarlarkInternal.java:82)

Feature requests: what underlying problem are you trying to solve with this feature?

Use the make variable feature e.g. $(execpath ...) in objc_library native java rule code

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

# BUILD
exports_files(["Foo.ld", "Foo.h"])

cc_library(name="main",
srcs=["main.c"],
copts=["-DXX='$(location :Foo.ld)'"],
deps=[":Foo.ld"])

objc_library(name="main_objc",
srcs=["main.c"],
copts=["-DXX='$(location :Foo.h)'"],
data=[":Foo.h"])
touch WORKSPACE main.c Foo.ld Foo.h
echo 5.0.0-pre.20211011.2 > .bazelversion
bazel build :*

What operating system are you running Bazel on?

macOS Big Sur - on Apple ARM64

What's the output of bazel info release?

5.0.0-pre.20211011.2

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

Use HEAD, pre-releases, of 5.0.0-pre.20211011.2

Any other information, logs, or outputs that you want to share?

Caused by: java.lang.NullPointerException                                                                                                                                                                   
        at java.base/java.lang.String.replace(Unknown Source)                                                                                                                                               
        at com.google.devtools.build.lib.rules.objc.ObjcStarlarkInternal.expandFlag(ObjcStarlarkInternal.java:145)                                                                                          
        at com.google.devtools.build.lib.rules.objc.ObjcStarlarkInternal.expandToolchainAndRuleContextVariables(ObjcStarlarkInternal.java:119)                                                              
        at com.google.devtools.build.lib.rules.objc.ObjcStarlarkInternal.createCompilationAttributes(ObjcStarlarkInternal.java:82)                                                                          
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                                                                   
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)                                                                                                                   
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)                                                                                                               
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)                                  
        at net.starlark.java.eval.MethodDescriptor.call(MethodDescriptor.java:162)                    
        at net.starlark.java.eval.BuiltinFunction.fastcall(BuiltinFunction.java:77)       

This seems break other rulesets using the native objc_rules e.g. rules_ios on Bazel 5:
bazel-ios/rules_ios#342

@oquenchil oquenchil added P3 We're not considering working on this, but happy to review a PR. (No assignee) platform: apple team-Rules-CPP Issues for C++ rules type: bug labels Nov 2, 2021
@keith
Copy link
Member

keith commented Nov 10, 2021

Is this the same as #13862 ?

@jerrymarino
Copy link
Contributor Author

@keith I'm not sure of the repro for #13862 but it looks like the same stack

@jerrymarino
Copy link
Contributor Author

Read through #13862 and this seems like a dupe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) platform: apple team-Rules-CPP Issues for C++ rules type: bug
Projects
None yet
Development

No branches or pull requests

3 participants