|
4 | 4 |
|
5 | 5 | 1. Clone (or pull) swift-docker: https://github.com/apple/swift-docker
|
6 | 6 | 2. Build the Ubuntu 18.04 container: `cd swift-ci/master/ubuntu/18.04; docker build .`
|
7 |
| -3. `docker run -it —cpus <CPUs> —memory <Memory> -v ~/<path to your local sources>:/src-on-host:cached —name lsan-reproducer —cap-add=SYS_PTRACE —security-opt seccomp=unconfined <hash that docker build outputs> bash` |
| 7 | +3. `docker run -it --cpus <CPUs> --memory <Memory> -v ~/<path to your local sources>:/src-on-host:cached --name lsan-reproducer --cap-add=SYS_PTRACE --security-opt seccomp=unconfined <hash that docker build outputs> bash` |
8 | 8 | - The `-cap-add` and `-security-opt` arguments are needed to run LLDB inside the Docker container
|
9 |
| -4. Copy the sources to inside the Docker container: `cp /src-on-host/* ~` |
| 9 | +4. Copy the sources to inside the Docker container: `cp -r /src-on-host/* ~` |
10 | 10 | - We need to to this because the build needs a case-sensitive file system and your host machine probably has a case-insensitive file system
|
11 | 11 |
|
12 | 12 | Build inside the Container
|
@@ -36,36 +36,25 @@ Direct leak of 120 byte(s) in 3 object(s) allocated from:
|
36 | 36 | SUMMARY: LeakSanitizer: 120 byte(s) leaked in 3 allocation(s).
|
37 | 37 | ```
|
38 | 38 | 2. `lldb -- <your swiftc invocation above>`
|
39 |
| -3. Set a breakpoint somewhere in swiftc, eg. at the start of main: `br s -f driver.cpp -l 19`. This should output something like |
40 |
| - |
41 |
| -``` |
42 |
| -Breakpoint 1: where = swiftc`main + 4 at driver.cpp:20:10, address = 0x00000000014d25d4 |
43 |
| -``` |
44 |
| - |
45 |
| -4. Run swiftc to the breakpoint |
46 |
| -5. This should stop you with something like |
47 |
| - |
| 39 | +3. Start running swiftc inside lldb by executing `r` |
| 40 | +4. Find the loaded offset of swift-frontend by running `image list` |
| 41 | +For example, this might output |
48 | 42 | ```
|
49 |
| -* thread #1, name = 'swiftc', stop reason = breakpoint 1.1 |
50 |
| - frame #0: 0x0000555556a265d4 swiftc`main(argc_=168, argv_=0x00007fffffffced8) at driver.cpp:20:10 |
51 |
| - 17 #include "swift/DriverTool/DriverTool.h" |
52 |
| - 18 |
53 |
| - 19 int main(int argc_, const char **argv_) { |
54 |
| -→ 20 return swift::mainEntry(argc_, argv_); |
55 |
| -21 } |
| 43 | +[ 0] 0AEA10C1 0x0000555555554000 /home/build-user/build/buildbot_incremental_lsan/swift-linux-x86_64/bin/swift-frontend |
| 44 | +[ 1] D52BB67A-BBBB-E429-6E87-FC16144CA7CE-55276DD6 0x00007ffff7ffb000 [vdso] (0x00007ffff7ffb000) |
| 45 | +[ 2] 9EA8014C-F020-21A2-9E57-AA3E0512E9BB-6E30541D 0x00007ffff7dd3000 /lib/x86_64-linux-gnu/ld-2.27.so |
56 | 46 | ```
|
57 |
| - |
58 |
| -6. Find the loaded offset of swift-frontend by subtracting the breakpoint address from the frame address. With the example above, that’s `0x0000555556a265d4 - 0x00000000014d25d4 = 0x555555554000`. |
59 |
| -7. For the frame that you want to symbolicate,, add the offset you computed above to the stack frame in the LSAN report, eg. to symbolicate frame 1 `0x555555554000 + 0x292d81c = 0x555557E8181C` |
60 |
| -8. Look up the address using `image lookup -a <address you computed>`. This should output something like |
| 47 | +The loaded offset is `0x0000555555554000` |
| 48 | +5. For the frame that you want to symbolicate,, add the offset you computed above to the stack frame in the LSAN report, eg. to symbolicate frame 1 `0x555555554000 + 0x292d81c = 0x555557E8181C` |
| 49 | +6. Look up the address using `image lookup -a <address you computed>`. This should output something like |
61 | 50 |
|
62 | 51 | ```
|
63 | 52 | (lldb) image lookup -a 0x555557E8181C
|
64 | 53 | Address: swiftc[0x000000000292d81c] (swiftc.PT_LOAD[0]..text + 22056284)
|
65 | 54 | Summary: swiftc`registerFunctionTest(BridgedStringRef, void*) + 28 at SILBridging.cpp:148:3
|
66 | 55 | ```
|
67 | 56 |
|
68 |
| -9. Hoorray, you know which function is leaking. |
| 57 | +7. Hoorray, you know which function is leaking. |
69 | 58 |
|
70 | 59 | ### Making Local Changes Inside the Container
|
71 | 60 |
|
|
0 commit comments