aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorNan Zhang <nanzhang@google.com>2018-09-26 15:14:10 -0700
committerNan Zhang <nanzhang@google.com>2018-09-26 16:57:24 -0700
commitcba97e69ab4b9bd15e11fb67e3316d5a273fefb4 (patch)
treeccdeff38561c5cb5dc739fa242e2623a7722e95b /python
parentf9641687f57e09da9a00fed8e2a3a2d288c543db (diff)
downloadbuild_soong-cba97e69ab4b9bd15e11fb67e3316d5a273fefb4.tar.gz
build_soong-cba97e69ab4b9bd15e11fb67e3316d5a273fefb4.tar.bz2
build_soong-cba97e69ab4b9bd15e11fb67e3316d5a273fefb4.zip
Fix invalid memory error for python binary build
The root cause is we didn't check if the optionalpath is valid or not, the registerbuildation function directly invoke the path var and cause the invalid memory error. We just return if the launcher doesn't exist. The ctx.VisitDirectDepsWithTag() also handles allowmissingdependency so we are ok if launcher doesn't exist. Test: N/A Bug: b/116698229, b/67510844 Change-Id: I40941079a64d7797ab879fc5edaa29e835b493a0
Diffstat (limited to 'python')
-rw-r--r--python/binary.go6
-rw-r--r--python/builder.go6
2 files changed, 6 insertions, 6 deletions
diff --git a/python/binary.go b/python/binary.go
index 4135dfef..bf9acb41 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -84,15 +84,15 @@ func (binary *binaryDecorator) bootstrap(ctx android.ModuleContext, actualVersio
main := binary.getPyMainFile(ctx, srcsPathMappings)
- var launcherPath android.Path
+ var launcherPath android.OptionalPath
if embeddedLauncher {
ctx.VisitDirectDepsWithTag(launcherTag, func(m android.Module) {
if provider, ok := m.(IntermPathProvider); ok {
- if launcherPath != nil {
+ if launcherPath.Valid() {
panic(fmt.Errorf("launcher path was found before: %q",
launcherPath))
}
- launcherPath = provider.IntermPathForModuleOut().Path()
+ launcherPath = provider.IntermPathForModuleOut()
}
})
}
diff --git a/python/builder.go b/python/builder.go
index ec4cb4ea..11a792a4 100644
--- a/python/builder.go
+++ b/python/builder.go
@@ -70,7 +70,7 @@ func init() {
}
func registerBuildActionForParFile(ctx android.ModuleContext, embeddedLauncher bool,
- launcherPath android.Path, interpreter, main, binName string,
+ launcherPath android.OptionalPath, interpreter, main, binName string,
srcsZips android.Paths) android.Path {
// .intermediate output path for merged zip file.
@@ -104,9 +104,9 @@ func registerBuildActionForParFile(ctx android.ModuleContext, embeddedLauncher b
"srcsZips": strings.Join(srcsZips.Strings(), " "),
},
})
- } else {
+ } else if launcherPath.Valid() {
// added launcherPath to the implicits Ninja dependencies.
- implicits = append(implicits, launcherPath)
+ implicits = append(implicits, launcherPath.Path())
// .intermediate output path for entry_point.txt
entryPoint := android.PathForModuleOut(ctx, entryPointFile).String()