Repository: yt-dlp
Issue: Abrupt random crash when using --impersonate
Labels: external issue,core:networking

### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting that yt-dlp is broken on a **supported** site
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

Uzbekistan

### Provide a description that is worded well enough to be understood

I think yt-dlp crashes abruptly (no error, the process just exists during a video download) when I use `--impersonate Chrome-110:Windows-10` maybe along with some other options causing this.
I tried to craft a minimal reproductible command, and ended up with this:
`yt-dlp.exe -vU --format "mp4" --format-sort "res:360" --cookies-from-browser firefox --impersonate Chrome-110:Windows-10 -- "https://www.youtube.com/@thisishorosho/videos"`

The crash also happens with `https://www.youtube.com/@lyrica-live/videos` channel for example (not at the very first video) for me.
I saw this on at least two machines, both Windows10.

Each crash creates a `yt-dlp.exe.PID.dmp` minidump file in `AppData\Local\CrashDumps`
I can upload one if it is needed.

In the logs below, I show a batch file with the command, and its complete output. It is obvious that yt-dlp had cashed in the middle of the very first download, despite it was up to downloading a thousand of videos!
Even if this is related to an "ongoing YouTube block in Russia", the crash itself is very strange. I started using `--impersonate` because I feel this way yt-dlp downloads faster than normally (for me it often stuck at ≈43 KiB/s otherwise).

Can anybody confirm the crash with my batch file? I'm afraid it might be related to download speed / throttle pattern specific to Uzbekistan, which makes is harder to reproduce. It really happens randomly during the download.

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
echo on
yt-dlp.exe -vU --format "mp4" --format-sort "res:360" --impersonate Chrome-110:Windows-10 -- "https://www.youtube.com/@thisishorosho/videos"
echo ERRORLEVEL=%errorlevel%
pause

↓

D:\test>echo on

D:\test>yt-dlp.exe -vU --format "mp4" --format-sort "res:360" --impersonate Chrome-110:Windows-10 -- "https://www.youtube.com/@thisishorosho/videos"
[debug] Command-line config: ['-vU', '--format', 'mp4', '--format-sort', 'res:360', '--impersonate', 'Chrome-110:Windows-10', '--', 'https://www.youtube.com/@thisishorosho/videos']
[debug] Encodings: locale cp1251, fs utf-8, pref cp1251, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2024.07.30.232707 from yt-dlp/yt-dlp-nightly-builds [4b69e1b53] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19043-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg N-103655-g1dd3ab4876-20210917 (setts), ffprobe N-103655-g1dd3ab4876-20210917
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.07.04, curl_cffi-0.5.10, mutagen-1.47.0, requests-2.32.3, sqlite3-3.35.5, urllib3-2.2.2, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets, curl_cffi
[debug] Loaded 1829 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Latest version: nightly@2024.07.30.232707 from yt-dlp/yt-dlp-nightly-builds
yt-dlp is up to date (nightly@2024.07.30.232707 from yt-dlp/yt-dlp-nightly-builds)
[youtube:tab] Extracting URL: https://www.youtube.com/@thisishorosho/videos
[youtube:tab] @thisishorosho/videos: Downloading webpage
[debug] [youtube:tab] Selected tab: 'videos' (videos), Requested tab: 'videos'
[download] Downloading playlist: This is Хорошо - Videos
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 1: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 2: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 3: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 4: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 5: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 6: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 7: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 8: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 9: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 10: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 11: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 12: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 13: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 14: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 15: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 16: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 17: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 18: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 19: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 20: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 21: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 22: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 23: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 24: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 25: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 26: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 27: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 28: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 29: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 30: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 31: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 32: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 33: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 34: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 35: Downloading API JSON
[youtube:tab] UCPT9_sNLoBLjH1uea7zpVIA page 36: Downloading API JSON
[youtube:tab] Playlist This is Хорошо - Videos: Downloading 1096 items of 1096
[download] Downloading item 1 of 1096
[youtube] Extracting URL: https://www.youtube.com/watch?v=LcVux8CuLuE
[youtube] LcVux8CuLuE: Downloading webpage
WARNING: [youtube] Webpage contains broken formats (poToken experiment detected). Ignoring initial player response
[youtube] LcVux8CuLuE: Downloading ios player API JSON
[youtube] LcVux8CuLuE: Downloading player 250a2ff7
[youtube] LcVux8CuLuE: Downloading web player API JSON
[debug] Loading youtube-nsig.250a2ff7 from cache
[debug] [youtube] Decrypted nsig -gpiDHpXVGKhSclQ6AJdY5 => f1FN1_eEwn5ANQ
[debug] Loading youtube-nsig.250a2ff7 from cache
[debug] [youtube] Decrypted nsig 5akAn0hlwapUV9r_rlJbA4 => eV7gpd_5E9YaHA
[youtube] LcVux8CuLuE: Downloading m3u8 information
[debug] Sort order given by user: res:360
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, res:360(360.0), quality, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[info] LcVux8CuLuE: Downloading 1 format(s): 18
[debug] Invoking http downloader on "https://rr6---sn-01oxu-u5nd.googlevideo.com/videoplayback?expire=1722449929&ei=qSuqZoeZHLC5v_IPlY_suA8&ip=213.230.111.230&id=o-AHgzNM42HtHxv5dqD0wLhQf5rqoyAMR3Tgg1OZJO7qss&itag=18&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=jk&mm=31%2C29&mn=sn-01oxu-u5nd%2Csn-n8v7znsk&ms=au%2Crdu&mv=m&mvi=6&pl=22&initcwndbps=1107500&bui=AXc671LiNoGAF5ajUlTsrqPujazda9HQUP5sK-M3Ex9hpOAJFoUepB0burk9YwlM4_QP6ZIhDNSNIgxo&spc=NO7bAZIk5Z2z-QnUQNyn73b9PCee2ZgW6H7g883uxh7HLpAHcIjWYI3LZgJOiv4&vprv=1&svpuc=1&mime=video%2Fmp4&ns=nE7CD0VtV3ONjlJwq1KtMssQ&rqh=1&gir=yes&clen=77370720&ratebypass=yes&dur=936.019&lmt=1721917275950254&mt=1722427783&fvip=7&c=WEB&sefc=1&txp=5538434&n=f1FN1_eEwn5ANQ&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AJfQdSswRQIgZ5NlujvH4RikgkWDSc4jP-UidEWvi4T9tKhBhmxW90kCIQDxu986UGmFlvF0zHwxjl9FQaim0H1rkxfMlQVfsPFujA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AGtxev0wRgIhAIH11WH5SeYgxFfuxy_iKxhZEVU5Rkq6ujw5sT9HsPpoAiEA_wa51mdmsh6qdoSPdx5T4TBYwd9beDbVMOFvhAcjUHo%3D"
[debug] File locking is not supported. Proceeding without locking
[download] Destination: ПОЧЕМУ ПСИХОЛОГИ РЕКОМЕНДУЮТ D&D？ ｜  Скандал с Nestle ｜ Препарат по продлению жизни [LcVux8CuLuE].mp4
[download]  36.6% of   73.79MiB at    4.99MiB/s ETA 00:09
D:\test>echo ERRORLEVEL=-1073740940
ERRORLEVEL=-1073740940

D:\test>pause
Для продолжения нажмите любую клавишу . . .