Skip to content

Commit

Permalink
Avoid adding any framework paths in /System/Library in process_one_mo…
Browse files Browse the repository at this point in the history
…dule.

The merit of process_one_module can be debated, but these are
definitely wrong, system modules must be imported from the SDK instead.

<rdar://problem/56280346>
  • Loading branch information
adrian-prantl committed Oct 29, 2019
1 parent c951307 commit e9e842b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
LEVEL = ../../../make

SWIFT_SOURCES := main.swift

SWIFT_FLAGS_EXTRAS := -framwork CoreGraphics

include $(LEVEL)/Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import lldb
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbtest as lldbtest
import lldbsuite.test.lldbutil as lldbutil
import os
import unittest2


class TestSwiftAnyType(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@swiftTest
def test_system_framework(self):
"""Make sure no framework paths into /System/Library are added"""
self.build()
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
self, 'break here', lldb.SBFileSpec('main.swift'))

log = self.getBuildArtifact("types.log")
self.runCmd('log enable lldb types -f "%s"' % log)
self.expect("settings set target.use-all-compiler-flags true")
self.expect("expression -- 0")
pos = 0
neg = 0
with open(log, "r") as logfile:
for line in logfile:
if "process_one_module rejecting framework path" in line:
pos += 1
elif "/System/Library/Frameworks" in line:
neg += 1

self.assertGreater(pos, 0, "sanity check failed")
self.assertEqual(neg, 0, "found /System/Library/Frameworks in log")
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ApplicationServices

func stop() {}

let a = ATSFSSpec()
stop() // break here
5 changes: 4 additions & 1 deletion lldb/source/Symbol/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2089,7 +2089,10 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
std::string parent_path =
module_path.substr(0, framework_offset);

if (!StringRef(parent_path).equals("/System/Library") &&
// Never add framework paths pointing into the
// system. These modules must be imported from the
// SDK instead.
if (!StringRef(parent_path).startswith("/System/Library") &&
!IsDeviceSupport(parent_path.c_str()))
framework_search_paths.push_back(
{std::move(parent_path), /*system*/ false});
Expand Down

0 comments on commit e9e842b

Please sign in to comment.