aws / aws/aws-cli

[AWS CLI v2] Crash in awscli/telemetry.py on macos arm64

Open
#9,990 18 comments 0 reactions 1 assignee Claimed by @RyanFitzSimmonsAK View on GitHub
bug installation investigating p2
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the bug

Executing `aws` can cause a crash in telemetry.py on macos arm64 (see the stacktrace below).
This seems to be related to sqlite. I tried to use the default parameters of the `sqlite3.connect` method and observed no crashes anymore.

### Regression Issue

- [x] Select this option if this issue appears to be a regression.

### Expected Behavior

`aws` command doesn't crash on startup.

### Current Behavior

`aws` crashes on start and with `PYTHONFAULTHANDLER=1` produces a stacktrace like this:

```
❯ echo $(DYLD_PRINT_LIBRARIES=1 aws --debug --version) at 16:59:59
Fatal Python error: Segmentation fault

Current thread 0x000000020adf2c40 (most recent call first):
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/telemetry.py", line 90 in execute
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/telemetry.py", line 179 in read_host_id
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/telemetry.py", line 273 in _host_id
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/functools.py", line 1001 in __get__
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/telemetry.py", line 229 in cache_key
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/functools.py", line 1001 in __get__
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/telemetry.py", line 239 in session_id
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/functools.py", line 1001 in __get__
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/telemetry.py", line 305 in add_session_id_component_to_user_agent_extra
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/clidriver.py", line 180 in _set_user_agent_for_session
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/clidriver.py", line 117 in create_clidriver
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/clidriver.py", line 222 in _do_main
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/clidriver.py", line 196 in main
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/lib/python3.11/site-packages/awscli/clidriver.py", line 107 in main
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/bin/aws", line 23 in main
File "/Users/g4ius/Workspace/pyenv/versions/3.11.14/bin/aws", line 27 in

Extension modules: _awscrt, ruamel.yaml.clib._ruamel_yaml, _ruamel_yaml (total: 3)

```

### Reproduction Steps

1. `export PYTHONFAULTHANDLER=1`
2. call `echo $(DYLD_PRINT_LIBRARIES=1 aws --debug --version)` repeatedly (e.g. with `watch`)
3. observe crash and stacktrace

### Possible Solution

In the `__init__` method of `CLISessionDatabaseConnection`, set `check_same_thread` to `True` and set `isolation_level` to `DEFERRED`. That worked for me.

### Additional Information/Context

I installed the `aws-cli` directly from the git repository using `pip install -U git+https://github.com/aws/aws-cli.git@2.33.0`.

### CLI version used

aws-cli/2.33.0 Python/3.11.14 Darwin/25.2.0 source/arm64

### Environment details (OS name and version, etc.)

MacOS Tahoe on a Macbook Pro M4

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.