Segmentation fault on response.json()

Here's the nearly full trace of the issue.

Thread 0x00007f6c37fff700 (most recent call first):
  File "/usr/lib/python3.6/threading.py", line 295 in wait
  File "/usr/lib/python3.6/queue.py", line 164 in get
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 67 in _worker
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Thread 0x00007f6c54e79700 (most recent call first):
  File "/usr/lib/python3.6/threading.py", line 295 in wait
  File "/usr/lib/python3.6/queue.py", line 164 in get
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 67 in _worker
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Thread 0x00007f6c5567a700 (most recent call first):
  File "/usr/lib/python3.6/threading.py", line 295 in wait
  File "/usr/lib/python3.6/queue.py", line 164 in get
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 67 in _worker
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Thread 0x00007f6c55e7b700 (most recent call first):
  File "/usr/lib/python3.6/threading.py", line 295 in wait
  File "/usr/lib/python3.6/queue.py", line 164 in get
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 67 in _worker
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Thread 0x00007f6c566bc700 (most recent call first):
  File "/usr/lib/python3.6/threading.py", line 295 in wait
  File "/usr/lib/python3.6/queue.py", line 164 in get
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 67 in _worker
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Thread 0x00007f6c56ebd700 (most recent call first):
  File "/usr/lib/python3.6/threading.py", line 295 in wait
  File "/usr/lib/python3.6/queue.py", line 164 in get
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 67 in _worker
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Thread 0x00007f6c576be700 (most recent call first):
  File "/usr/lib/python3.6/threading.py", line 295 in wait
  File "/usr/lib/python3.6/queue.py", line 164 in get
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 67 in _worker
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Thread 0x00007f6c57f7f700 (most recent call first):
  File "/usr/lib/python3.6/threading.py", line 295 in wait
  File "/usr/lib/python3.6/queue.py", line 164 in get
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 67 in _worker
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Thread 0x00007f6c6ced6700 (most recent call first):
  File "/usr/lib/python3.6/threading.py", line 295 in wait
  File "/usr/lib/python3.6/queue.py", line 164 in get
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 463 in _handle_results
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Thread 0x00007f6c6d6d7700 (most recent call first):
  File "/usr/lib/python3.6/threading.py", line 295 in wait
  File "/usr/lib/python3.6/queue.py", line 164 in get
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 415 in _handle_tasks
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Thread 0x00007f6c6ded8700 (most recent call first):
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 406 in _handle_workers
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Current thread 0x00007f6c6e6d9700 (most recent call first):
  File "/usr/lib/python3.6/json/decoder.py", line 355 in raw_decode
  File "/usr/lib/python3.6/json/decoder.py", line 339 in decode
  File "/usr/lib/python3.6/json/__init__.py", line 354 in loads
  File "/var/lib/jenkins/.local/lib/python3.6/site-packages/requests/models.py", line 897 in json
  **File "/var/lib/jenkins/workspace/my_job/consumers/api_helpers/some_helper.py", line 13 in hit_an_api_and_get_some_status**

At the last line indicated in bold, my code is this:

`return response.json()["status"] if response.status_code == 200 else None`

## Expected Result

There should be no segmentation fault.

## Actual Result

My code fails with a segmentation fault.

## Reproduction Steps

```python
import requests

```

(the code is indicated above)

## System Information
requests version 2.22.0
Python version 3.6 running on Ubuntu 16.04 LTS

Hi @akshayamaldhure, do you actually mean a seg fault, or are your referring to the traceback? Requests doesn't run any C code, so it would be very difficult if not impossible to be the cause of that.

Looking at the stack trace you provided, there's no information on what the actual exception is. Would you be able to provide that?

It looks like you're experiencing this same issue with [aiohttp](https://github.com/slackapi/python-slackclient/issues/624) as well which would point to this not being an issue specific to Requests.

If you're able to reproduce with with a minimal example only using Requests, please feel free to reopen the ticket. Thanks!

> Hi @akshayamaldhure, do you actually mean a seg fault, or are your referring to the traceback? Requests doesn't run any C code, so it would be very difficult if not impossible to be the cause of that.
> 
> Looking at the stack trace you provided, there's no information on what the actual exception is. Would you be able to provide that?

@nateprewitt Before enabling the full logging of the seg fault using the [faulthandler](https://docs.python.org/3/library/faulthandler.html) module, I used to see only "SEGMENTATION FAULT" on the console logs on the corresponding Linux machine. Looking at the stack trace I provided, don't you think the fault is originating from the file `requests/models.py`?

Requests is entirely python code, so a SEGFAULT shouldn't be originating from us. If you look at the stacktrace, the failure point is calling [`json.loads`](https://github.com/psf/requests/blob/v2.22.0/requests/models.py#L897) which is part of the standard library unless you've either a.) installed simplejson or b.) patched the `json` module for your python interpreter in some way.

Looking at the stacktrace, you're using /usr/lib/python3.6/json which may be the next place to look if you're certain it's not related to your threading implementation.

@nateprewitt Here are the contents of my `requirements.txt` file.

aiohttp==3.6.2
async-timeout==3.0.1
attrs==19.3.0
certifi==2019.11.28
chardet==3.0.4
colorama==0.4.3
idna==2.9
lemoncheesecake==1.4.5
multidict==4.7.5
python-slugify==4.0.0
requests==2.22.0
six==1.14.0
slackclient==2.5.0
termcolor==1.1.0
terminaltables==3.1.0
text-unidecode==1.3
typing==3.7.4.1
urllib3==1.25.8
yarl==1.4.2

Apparently, it seems pip was pointing to the incorrect Python version (Python 3.5) on the target machine. After fixing the same, this issue is not seen anymore.

`pip 20.0.2 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)`