We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`leakfind` should default to `$sp`
The first argument to `leakfind` is required, but it should just default to `$sp` like `probeleak` does.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pwndbg/commands/leakfind.py`
Content:
```
1 """
2 Find a chain of leaks given some starting address.
3 """
4 
5 import argparse
6 import queue
7 
8 import gdb
9 
10 import pwndbg.color.chain as C
11 import pwndbg.color.memory as M
12 import pwndbg.color.message as message
13 import pwndbg.commands
14 import pwndbg.vmmap
15 from pwndbg.chain import config_arrow_right
16 
17 
18 # Used to recursively print the pointer chain.
19 # addr is a pointer. It is taken to be a child pointer.
20 # visited_map is a map of children -> (parent,parent_start)
21 def get_rec_addr_string(addr, visited_map):
22     page = pwndbg.vmmap.find(addr)
23     arrow_right = C.arrow(" %s " % config_arrow_right)
24 
25     if page is not None:
26         if addr not in visited_map:
27             return ""
28 
29         parent_info = visited_map[addr]
30         parent = parent_info[0]
31         parent_base_addr = parent_info[1]
32         if parent - parent_base_addr < 0:
33             curText = hex(parent_base_addr) + hex(parent - parent_base_addr)
34         else:
35             curText = hex(parent_base_addr) + "+" + hex(parent - parent_base_addr)
36         if parent_base_addr == addr:
37             return ""
38         return (
39             get_rec_addr_string(parent_base_addr, visited_map)
40             + M.get(parent_base_addr, text=curText)
41             + arrow_right
42         )
43     else:
44         return ""
45 
46 
47 # Useful for debugging. Prints a map of child -> (parent, parent_start)
48 def dbg_print_map(maps):
49     for child, parent_info in maps.items():
50         print("0x%x + (0x%x, 0x%x)" % (child, parent_info[0], parent_info[1]))
51 
52 
53 parser = argparse.ArgumentParser()
54 parser.description = """
55 Attempt to find a leak chain given a starting address.
56 Scans memory near the given address, looks for pointers, and continues that process to attempt to find leaks.
57 
58 Example: leakfind $rsp --page_name=filename --max_offset=0x48 --max_depth=6. This would look for any chains of leaks \
59 that point to a section in filename which begin near $rsp, are never 0x48 bytes further from a known pointer, \
60 and are a maximum length of 6.
61 """
62 parser.formatter_class = argparse.RawDescriptionHelpFormatter
63 parser.add_argument("address", help="Starting address to find a leak chain from")
64 parser.add_argument(
65     "-p",
66     "--page_name",
67     type=str,
68     nargs="?",
69     default=None,
70     help="Substring required to be part of the name of any found pages",
71 )
72 parser.add_argument(
73     "-o",
74     "--max_offset",
75     default=0x48,
76     nargs="?",
77     help="Max offset to add to addresses when looking for leak",
78 )
79 parser.add_argument(
80     "-d", "--max_depth", default=0x4, nargs="?", help="Maximum depth to follow pointers to"
81 )
82 parser.add_argument(
83     "-s",
84     "--step",
85     nargs="?",
86     default=0x1,
87     help="Step to add between pointers so they are considered. For example, if this is 4 it would only consider pointers at an offset divisible by 4 from the starting pointer",
88 )
89 parser.add_argument(
90     "--negative_offset",
91     nargs="?",
92     default=0x0,
93     help="Max negative offset to search before an address when looking for a leak",
94 )
95 
96 
97 @pwndbg.commands.ArgparsedCommand(parser)
98 @pwndbg.commands.OnlyWhenRunning
99 def leakfind(
100     address=None, page_name=None, max_offset=0x40, max_depth=0x4, step=0x1, negative_offset=0x0
101 ):
102     if address is None:
103         raise argparse.ArgumentTypeError("No starting address provided.")
104     foundPages = pwndbg.vmmap.find(address)
105 
106     if not foundPages:
107         raise argparse.ArgumentTypeError("Starting address is not mapped.")
108 
109     if not pwndbg.gdblib.memory.peek(address):
110         raise argparse.ArgumentTypeError("Unable to read from starting address.")
111 
112     max_depth = int(max_depth)
113     # Just warn the user that a large depth might be slow.
114     # Probably worth checking offset^depth < threshold. Do this when more benchmarking is established.
115     if max_depth > 8:
116         print(message.warn("leakfind may take a while to run on larger depths."))
117 
118     stride = int(step)
119     address = int(address)
120     max_offset = int(max_offset)
121     negative_offset = int(negative_offset)
122 
123     # The below map stores a map of child address->(parent_address,parent_start_address)
124     # In the above tuple, parent_address is the exact address with a pointer to the child address.
125     # parent_start_address is an address that a previous address pointed to.
126     # We need to store both so that we can nicely create our leak chain.
127     visited_map = {}
128     visited_set = {int(address)}
129     address_queue = queue.Queue()
130     address_queue.put(int(address))
131     depth = 0
132     time_to_depth_increase = 0
133 
134     # Run a bfs
135     # TODO look into performance gain from checking if an address is mapped before calling pwndbg.gdblib.memory.pvoid()
136     # TODO also check using pwndbg.gdblib.memory.read for possible performance boosts.
137     while address_queue.qsize() > 0 and depth < max_depth:
138         if time_to_depth_increase == 0:
139             depth = depth + 1
140             time_to_depth_increase = address_queue.qsize()
141         cur_start_addr = address_queue.get()
142         time_to_depth_increase -= 1
143         for cur_addr in range(
144             cur_start_addr - negative_offset, cur_start_addr + max_offset, stride
145         ):
146             try:
147                 cur_addr &= pwndbg.gdblib.arch.ptrmask
148                 result = int(pwndbg.gdblib.memory.pvoid(cur_addr))
149                 if result in visited_map or result in visited_set:
150                     continue
151                 visited_map[result] = (
152                     cur_addr,
153                     cur_start_addr,
154                 )  # map is of form child->(parent,parent_start)
155                 address_queue.put(result)
156                 visited_set.add(result)
157             except gdb.error:
158                 # That means the memory was unmapped. Just skip it if we can't read it.
159                 break
160 
161     # A map of length->list of lines. Used to let us print in a somewhat nice manner.
162     output_map = {}
163     arrow_right = C.arrow(" %s " % config_arrow_right)
164 
165     for child in visited_map:
166         child_page = pwndbg.vmmap.find(child)
167         if child_page is not None:
168             if page_name is not None and page_name not in child_page.objfile:
169                 continue
170             line = (
171                 get_rec_addr_string(child, visited_map)
172                 + M.get(child)
173                 + " "
174                 + M.get(child, text=child_page.objfile)
175             )
176             chain_length = line.count(arrow_right)
177             if chain_length in output_map:
178                 output_map[chain_length].append(line)
179             else:
180                 output_map[chain_length] = [line]
181 
182     # Output sorted by length of chain
183     for chain_length in output_map:
184         for line in output_map[chain_length]:
185             print(line)
186 
187     if pwndbg.gdblib.qemu.is_qemu():
188         print("\n[QEMU target detected - leakfind result might not be accurate; see `help vmmap`]")
189
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pwndbg/commands/leakfind.py b/pwndbg/commands/leakfind.py
--- a/pwndbg/commands/leakfind.py
+++ b/pwndbg/commands/leakfind.py
@@ -60,7 +60,9 @@
 and are a maximum length of 6.
 """
 parser.formatter_class = argparse.RawDescriptionHelpFormatter
-parser.add_argument("address", help="Starting address to find a leak chain from")
+parser.add_argument(
+    "address", nargs="?", default="$sp", help="Starting address to find a leak chain from"
+)
 parser.add_argument(
     "-p",
     "--page_name",

{"golden_diff": "diff --git a/pwndbg/commands/leakfind.py b/pwndbg/commands/leakfind.py\n--- a/pwndbg/commands/leakfind.py\n+++ b/pwndbg/commands/leakfind.py\n@@ -60,7 +60,9 @@\n and are a maximum length of 6.\n \"\"\"\n parser.formatter_class = argparse.RawDescriptionHelpFormatter\n-parser.add_argument(\"address\", help=\"Starting address to find a leak chain from\")\n+parser.add_argument(\n+    \"address\", nargs=\"?\", default=\"$sp\", help=\"Starting address to find a leak chain from\"\n+)\n parser.add_argument(\n     \"-p\",\n     \"--page_name\",\n", "issue": "`leakfind` should default to `$sp`\nThe first argument to `leakfind` is required, but it should just default to `$sp` like `probeleak` does.\n", "before_files": [{"content": "\"\"\"\nFind a chain of leaks given some starting address.\n\"\"\"\n\nimport argparse\nimport queue\n\nimport gdb\n\nimport pwndbg.color.chain as C\nimport pwndbg.color.memory as M\nimport pwndbg.color.message as message\nimport pwndbg.commands\nimport pwndbg.vmmap\nfrom pwndbg.chain import config_arrow_right\n\n\n# Used to recursively print the pointer chain.\n# addr is a pointer. It is taken to be a child pointer.\n# visited_map is a map of children -> (parent,parent_start)\ndef get_rec_addr_string(addr, visited_map):\n    page = pwndbg.vmmap.find(addr)\n    arrow_right = C.arrow(\" %s \" % config_arrow_right)\n\n    if page is not None:\n        if addr not in visited_map:\n            return \"\"\n\n        parent_info = visited_map[addr]\n        parent = parent_info[0]\n        parent_base_addr = parent_info[1]\n        if parent - parent_base_addr < 0:\n            curText = hex(parent_base_addr) + hex(parent - parent_base_addr)\n        else:\n            curText = hex(parent_base_addr) + \"+\" + hex(parent - parent_base_addr)\n        if parent_base_addr == addr:\n            return \"\"\n        return (\n            get_rec_addr_string(parent_base_addr, visited_map)\n            + M.get(parent_base_addr, text=curText)\n            + arrow_right\n        )\n    else:\n        return \"\"\n\n\n# Useful for debugging. Prints a map of child -> (parent, parent_start)\ndef dbg_print_map(maps):\n    for child, parent_info in maps.items():\n        print(\"0x%x + (0x%x, 0x%x)\" % (child, parent_info[0], parent_info[1]))\n\n\nparser = argparse.ArgumentParser()\nparser.description = \"\"\"\nAttempt to find a leak chain given a starting address.\nScans memory near the given address, looks for pointers, and continues that process to attempt to find leaks.\n\nExample: leakfind $rsp --page_name=filename --max_offset=0x48 --max_depth=6. This would look for any chains of leaks \\\nthat point to a section in filename which begin near $rsp, are never 0x48 bytes further from a known pointer, \\\nand are a maximum length of 6.\n\"\"\"\nparser.formatter_class = argparse.RawDescriptionHelpFormatter\nparser.add_argument(\"address\", help=\"Starting address to find a leak chain from\")\nparser.add_argument(\n    \"-p\",\n    \"--page_name\",\n    type=str,\n    nargs=\"?\",\n    default=None,\n    help=\"Substring required to be part of the name of any found pages\",\n)\nparser.add_argument(\n    \"-o\",\n    \"--max_offset\",\n    default=0x48,\n    nargs=\"?\",\n    help=\"Max offset to add to addresses when looking for leak\",\n)\nparser.add_argument(\n    \"-d\", \"--max_depth\", default=0x4, nargs=\"?\", help=\"Maximum depth to follow pointers to\"\n)\nparser.add_argument(\n    \"-s\",\n    \"--step\",\n    nargs=\"?\",\n    default=0x1,\n    help=\"Step to add between pointers so they are considered. For example, if this is 4 it would only consider pointers at an offset divisible by 4 from the starting pointer\",\n)\nparser.add_argument(\n    \"--negative_offset\",\n    nargs=\"?\",\n    default=0x0,\n    help=\"Max negative offset to search before an address when looking for a leak\",\n)\n\n\n@pwndbg.commands.ArgparsedCommand(parser)\n@pwndbg.commands.OnlyWhenRunning\ndef leakfind(\n    address=None, page_name=None, max_offset=0x40, max_depth=0x4, step=0x1, negative_offset=0x0\n):\n    if address is None:\n        raise argparse.ArgumentTypeError(\"No starting address provided.\")\n    foundPages = pwndbg.vmmap.find(address)\n\n    if not foundPages:\n        raise argparse.ArgumentTypeError(\"Starting address is not mapped.\")\n\n    if not pwndbg.gdblib.memory.peek(address):\n        raise argparse.ArgumentTypeError(\"Unable to read from starting address.\")\n\n    max_depth = int(max_depth)\n    # Just warn the user that a large depth might be slow.\n    # Probably worth checking offset^depth < threshold. Do this when more benchmarking is established.\n    if max_depth > 8:\n        print(message.warn(\"leakfind may take a while to run on larger depths.\"))\n\n    stride = int(step)\n    address = int(address)\n    max_offset = int(max_offset)\n    negative_offset = int(negative_offset)\n\n    # The below map stores a map of child address->(parent_address,parent_start_address)\n    # In the above tuple, parent_address is the exact address with a pointer to the child address.\n    # parent_start_address is an address that a previous address pointed to.\n    # We need to store both so that we can nicely create our leak chain.\n    visited_map = {}\n    visited_set = {int(address)}\n    address_queue = queue.Queue()\n    address_queue.put(int(address))\n    depth = 0\n    time_to_depth_increase = 0\n\n    # Run a bfs\n    # TODO look into performance gain from checking if an address is mapped before calling pwndbg.gdblib.memory.pvoid()\n    # TODO also check using pwndbg.gdblib.memory.read for possible performance boosts.\n    while address_queue.qsize() > 0 and depth < max_depth:\n        if time_to_depth_increase == 0:\n            depth = depth + 1\n            time_to_depth_increase = address_queue.qsize()\n        cur_start_addr = address_queue.get()\n        time_to_depth_increase -= 1\n        for cur_addr in range(\n            cur_start_addr - negative_offset, cur_start_addr + max_offset, stride\n        ):\n            try:\n                cur_addr &= pwndbg.gdblib.arch.ptrmask\n                result = int(pwndbg.gdblib.memory.pvoid(cur_addr))\n                if result in visited_map or result in visited_set:\n                    continue\n                visited_map[result] = (\n                    cur_addr,\n                    cur_start_addr,\n                )  # map is of form child->(parent,parent_start)\n                address_queue.put(result)\n                visited_set.add(result)\n            except gdb.error:\n                # That means the memory was unmapped. Just skip it if we can't read it.\n                break\n\n    # A map of length->list of lines. Used to let us print in a somewhat nice manner.\n    output_map = {}\n    arrow_right = C.arrow(\" %s \" % config_arrow_right)\n\n    for child in visited_map:\n        child_page = pwndbg.vmmap.find(child)\n        if child_page is not None:\n            if page_name is not None and page_name not in child_page.objfile:\n                continue\n            line = (\n                get_rec_addr_string(child, visited_map)\n                + M.get(child)\n                + \" \"\n                + M.get(child, text=child_page.objfile)\n            )\n            chain_length = line.count(arrow_right)\n            if chain_length in output_map:\n                output_map[chain_length].append(line)\n            else:\n                output_map[chain_length] = [line]\n\n    # Output sorted by length of chain\n    for chain_length in output_map:\n        for line in output_map[chain_length]:\n            print(line)\n\n    if pwndbg.gdblib.qemu.is_qemu():\n        print(\"\\n[QEMU target detected - leakfind result might not be accurate; see `help vmmap`]\")\n", "path": "pwndbg/commands/leakfind.py"}], "after_files": [{"content": "\"\"\"\nFind a chain of leaks given some starting address.\n\"\"\"\n\nimport argparse\nimport queue\n\nimport gdb\n\nimport pwndbg.color.chain as C\nimport pwndbg.color.memory as M\nimport pwndbg.color.message as message\nimport pwndbg.commands\nimport pwndbg.vmmap\nfrom pwndbg.chain import config_arrow_right\n\n\n# Used to recursively print the pointer chain.\n# addr is a pointer. It is taken to be a child pointer.\n# visited_map is a map of children -> (parent,parent_start)\ndef get_rec_addr_string(addr, visited_map):\n    page = pwndbg.vmmap.find(addr)\n    arrow_right = C.arrow(\" %s \" % config_arrow_right)\n\n    if page is not None:\n        if addr not in visited_map:\n            return \"\"\n\n        parent_info = visited_map[addr]\n        parent = parent_info[0]\n        parent_base_addr = parent_info[1]\n        if parent - parent_base_addr < 0:\n            curText = hex(parent_base_addr) + hex(parent - parent_base_addr)\n        else:\n            curText = hex(parent_base_addr) + \"+\" + hex(parent - parent_base_addr)\n        if parent_base_addr == addr:\n            return \"\"\n        return (\n            get_rec_addr_string(parent_base_addr, visited_map)\n            + M.get(parent_base_addr, text=curText)\n            + arrow_right\n        )\n    else:\n        return \"\"\n\n\n# Useful for debugging. Prints a map of child -> (parent, parent_start)\ndef dbg_print_map(maps):\n    for child, parent_info in maps.items():\n        print(\"0x%x + (0x%x, 0x%x)\" % (child, parent_info[0], parent_info[1]))\n\n\nparser = argparse.ArgumentParser()\nparser.description = \"\"\"\nAttempt to find a leak chain given a starting address.\nScans memory near the given address, looks for pointers, and continues that process to attempt to find leaks.\n\nExample: leakfind $rsp --page_name=filename --max_offset=0x48 --max_depth=6. This would look for any chains of leaks \\\nthat point to a section in filename which begin near $rsp, are never 0x48 bytes further from a known pointer, \\\nand are a maximum length of 6.\n\"\"\"\nparser.formatter_class = argparse.RawDescriptionHelpFormatter\nparser.add_argument(\n    \"address\", nargs=\"?\", default=\"$sp\", help=\"Starting address to find a leak chain from\"\n)\nparser.add_argument(\n    \"-p\",\n    \"--page_name\",\n    type=str,\n    nargs=\"?\",\n    default=None,\n    help=\"Substring required to be part of the name of any found pages\",\n)\nparser.add_argument(\n    \"-o\",\n    \"--max_offset\",\n    default=0x48,\n    nargs=\"?\",\n    help=\"Max offset to add to addresses when looking for leak\",\n)\nparser.add_argument(\n    \"-d\", \"--max_depth\", default=0x4, nargs=\"?\", help=\"Maximum depth to follow pointers to\"\n)\nparser.add_argument(\n    \"-s\",\n    \"--step\",\n    nargs=\"?\",\n    default=0x1,\n    help=\"Step to add between pointers so they are considered. For example, if this is 4 it would only consider pointers at an offset divisible by 4 from the starting pointer\",\n)\nparser.add_argument(\n    \"--negative_offset\",\n    nargs=\"?\",\n    default=0x0,\n    help=\"Max negative offset to search before an address when looking for a leak\",\n)\n\n\n@pwndbg.commands.ArgparsedCommand(parser)\n@pwndbg.commands.OnlyWhenRunning\ndef leakfind(\n    address=None, page_name=None, max_offset=0x40, max_depth=0x4, step=0x1, negative_offset=0x0\n):\n    if address is None:\n        raise argparse.ArgumentTypeError(\"No starting address provided.\")\n    foundPages = pwndbg.vmmap.find(address)\n\n    if not foundPages:\n        raise argparse.ArgumentTypeError(\"Starting address is not mapped.\")\n\n    if not pwndbg.gdblib.memory.peek(address):\n        raise argparse.ArgumentTypeError(\"Unable to read from starting address.\")\n\n    max_depth = int(max_depth)\n    # Just warn the user that a large depth might be slow.\n    # Probably worth checking offset^depth < threshold. Do this when more benchmarking is established.\n    if max_depth > 8:\n        print(message.warn(\"leakfind may take a while to run on larger depths.\"))\n\n    stride = int(step)\n    address = int(address)\n    max_offset = int(max_offset)\n    negative_offset = int(negative_offset)\n\n    # The below map stores a map of child address->(parent_address,parent_start_address)\n    # In the above tuple, parent_address is the exact address with a pointer to the child address.\n    # parent_start_address is an address that a previous address pointed to.\n    # We need to store both so that we can nicely create our leak chain.\n    visited_map = {}\n    visited_set = {int(address)}\n    address_queue = queue.Queue()\n    address_queue.put(int(address))\n    depth = 0\n    time_to_depth_increase = 0\n\n    # Run a bfs\n    # TODO look into performance gain from checking if an address is mapped before calling pwndbg.gdblib.memory.pvoid()\n    # TODO also check using pwndbg.gdblib.memory.read for possible performance boosts.\n    while address_queue.qsize() > 0 and depth < max_depth:\n        if time_to_depth_increase == 0:\n            depth = depth + 1\n            time_to_depth_increase = address_queue.qsize()\n        cur_start_addr = address_queue.get()\n        time_to_depth_increase -= 1\n        for cur_addr in range(\n            cur_start_addr - negative_offset, cur_start_addr + max_offset, stride\n        ):\n            try:\n                cur_addr &= pwndbg.gdblib.arch.ptrmask\n                result = int(pwndbg.gdblib.memory.pvoid(cur_addr))\n                if result in visited_map or result in visited_set:\n                    continue\n                visited_map[result] = (\n                    cur_addr,\n                    cur_start_addr,\n                )  # map is of form child->(parent,parent_start)\n                address_queue.put(result)\n                visited_set.add(result)\n            except gdb.error:\n                # That means the memory was unmapped. Just skip it if we can't read it.\n                break\n\n    # A map of length->list of lines. Used to let us print in a somewhat nice manner.\n    output_map = {}\n    arrow_right = C.arrow(\" %s \" % config_arrow_right)\n\n    for child in visited_map:\n        child_page = pwndbg.vmmap.find(child)\n        if child_page is not None:\n            if page_name is not None and page_name not in child_page.objfile:\n                continue\n            line = (\n                get_rec_addr_string(child, visited_map)\n                + M.get(child)\n                + \" \"\n                + M.get(child, text=child_page.objfile)\n            )\n            chain_length = line.count(arrow_right)\n            if chain_length in output_map:\n                output_map[chain_length].append(line)\n            else:\n                output_map[chain_length] = [line]\n\n    # Output sorted by length of chain\n    for chain_length in output_map:\n        for line in output_map[chain_length]:\n            print(line)\n\n    if pwndbg.gdblib.qemu.is_qemu():\n        print(\"\\n[QEMU target detected - leakfind result might not be accurate; see `help vmmap`]\")\n", "path": "pwndbg/commands/leakfind.py"}]}