Fail when using taichi (Exception: Picked an invalid source context)
See original GitHub issueYour package is so useful that I stop using ipython anymore. Thank you!
I start using taichi recently and I encounter an error, the minimal sample is list below.
import stackprinter
import taichi as ti
stackprinter.set_excepthook(style="darkbg2")
@ti.kernel
def my_kernel() -> float:
return "22"
my_kernel()
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Advanced guide to creating IntelliJ IDEA plugins
Advanced guide to creating JetBrains Platform plugins: VFS, PSI, Kotlin UI DSL, Dialog, Tool window, List, Swing UI and layout managers, ...
Read more >Adding Core Data to existing iPhone project - Stack Overflow
When you click on this Model object you will see the interface to add the Entities to your project with any relationships you...
Read more >PRISMA 2020 explanation and elaboration: updated guidance ...
PRISMA 2020 is intended for use in systematic reviews that include synthesis (such ... Specify the primary source of funding for the review....
Read more >Nmap Change Log
Hundreds of commercial products now use Nmap for network discovery tasks like port scanning, host discovery, OS detection, service/version detection, and of ...
Read more >Exercise Standards for Testing and Training - AHA Journals
ECG monitoring is not routinely done with this testing, thus limiting its diagnostic accuracy. Exercise Test Supervision and Interpretation. Exercise testing ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Interesting, in your second example, the troubled frame looks like this:
frame.f_code.co_name
==wrong_syntax_in_taichi
frame.f_code.co_firstlineno
is 8, which looks correctframe.f_lineno
is13
which is a blank line 🤔I could extend my workaround and guess a different lineno here too – may still be better than crashing?
I think I found something. For some reason, the line number that the python interpreter reports on that particular frame is before the beginning of the code scope of that frame (as discovered by the
inspect
module, which ultimately relies onframe.f_code.co_firstlineno
i.e. ultimately the interpreter contradicts itself).I have a workaround #46, which detects this situation, prints a warning and moves the displayed lineno to the beginning of the frame’s available source block. Of course I’m only half-happy with that, but it fixes the crash and seems like reasonable behavior.
(Interestingly, I could only reproduce this bug with
taichi
so far, so I assume it’s an edge case where the interpreter confuses itself during the heavy introspection & dynamic rewriting of the stack thattaichi
seems to be doing.)If you’re able to test the workaround locally (by doing
pip uninstall stackprinter; pip install -e /path/to/a/clone/of/this/repository
), I’d be grateful to hear how it goes on your real code!On my side, I can run your test now and get a traceback with all sorts of stuff in it 🙂 (Note the “problematic” frame in the middle)