Comments (5)
Confirmed on main
. @Eclips4 and @Zheaoli , did you use --with-address-sanitizer
?
So this is a very rare case, or rather an explicit case to crash the profiler. I can't think of any real use case where stopping a profiler inside the timer function makes sense. It's a very interesting hack, but not that meaningful in the real world.
We can do some heuristics to check this rare case, but the profiler itself is kind of performance sensitive. I don't want to make it any slower in most real-world cases. So I'll make a PR to detect if an external timer changes the profiler context and if so, write a warning (unraisable exception). This way the user would know that they are doing something crazy.
There's no way for us to propagate the exception from there because it returns a time. This has no effect in normal cases where an internal timer is used. I think this is a good middle ground to address this issue.
I believe even with the evil code, in most case this won't crash because the memory is not really "freed". You need ASAN to report this. So having an extra exception look reasonable to me.
The alternative is to do a PyErr_Occured
check every time we uses call_timer()
before we assign it to anything. We can protect it with the externel timer check but still some overhead. I'm not the security expert and from my perspective it seems very difficult to utilize this problem.
from cpython.
After some investigation on this. I don't believe there's a quick and clean fix to check this. I think the best way is not to free the memory of profile context when the profiler is disabled. Only free when the profiler itself is released. I made the PR and it fixed the issue.
from cpython.
I cannot reproduce it using your example on current main branch, debug build, macOS.
from cpython.
I cannot reproduce it using your example on current main branch, debug build, macOS.
The same, I cannot reproduce the issue with the poc code for O3 or debug build in Linux with main branch
from cpython.
Oh we actually do have an ASAN check. Maybe I'll have to make it work with ASAN.
from cpython.
Related Issues (20)
- loop.'getaddrinfo' would be better if it weren't executor pool dependent HOT 1
- dataclass(a=nan) == dataclass(a=nan) change in truthnes between 3.12 and 3.13 HOT 9
- RotatingFileHandler fails when logs are stored in a non-posix file system docker-mounted in Linux-OS HOT 3
- Pandas cannot import numpy in free-threaded version of 3.13.0b2 HOT 7
- Runtime Error: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. HOT 3
- Skip `test_free_threading` with GIL HOT 2
- Type error in the section on type hints HOT 2
- Bug in smtplib example HOT 5
- unittest loaders should avoid loading test cases that are abstract base classes HOT 1
- Failing configure tests due to missing space HOT 5
- Protect multi-line macros expansions in `_test*.c` files HOT 1
- Use `@file` for gcc commands HOT 11
- New REPL does not include globals from executed module when used with `-i` HOT 3
- Python 3.13.0b2: rounding can cause incorrect log timestamps HOT 1
- Removed unused internal C API functions
- test_email fails on WASI: thread 'main' has overflowed its stack HOT 1
- faulthandler will hang the process with a TSAN and free-thread build Python HOT 5
- cpython HOT 1
- locals() does not include local variables set in exec() statement in 3.13b2 HOT 33
- `datetime.strftime("%Y")` is not padding correctly HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.