Closed tdp2110 closed 1 year ago
https://pybind11.readthedocs.io/en/stable/advanced/functions.html#return-value-policies might be relevant here.
This is running with a local build of slang? So a fairly recent revision? I wonder if you're building now with mimalloc and that's incompatible with the way Python handles allocations?
This is running with a local build of slang? So a fairly recent revision? I wonder if you're building now with mimalloc and that's incompatible with the way Python handles allocations?
Local build indeed, head at d27d9ac (Fix noexcept build, Mon May 15 20:54:46 2023 -0400). I tried with both mimallc and without (and lots of other build configs, which led to https://github.com/MikePopoloski/slang/pull/756) and I believe I was crashing them all.
Hmm, ok. It's certainly possible this is a bug in the binding code, the return value policies (which you linked to) are easy to get wrong. Without a more accurate reproducer though it's going to be tough to guess where it is; the call stack you listed pointed to EnumValueSymbols so I can look at methods that return those but otherwise I won't have much to go on.
I did an audit and fixed a few return value policies that seemed wrong in af7827decd2be7c8256513fb6d3703ffb9b8adb9 but I don't know if it will help your specific problem.
Awesome, thanks! I’ll try on Tuesday. Have a great weekend Sent from my iPhoneOn May 20, 2023, at 10:05, Michael Popoloski @.***> wrote: I did an audit and fixed a few return value policies that seemed wrong in af7827d but I don't know if it will help your specific problem.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
https://github.com/MikePopoloski/slang/commit/af7827decd2be7c8256513fb6d3703ffb9b8adb9 removes the crash and the memcheck warning!
Thanks again, I really appreciate your effort!
Describe the bug
Apologies for the lack of repro'ing example (I've been trying, will try some more as I have time), but I've been crashing pyslang in pure python lately. Sometimes I get a segfault, sometimes the OS detects an invalid free or memory corruption. Running in valgrind, I see the following suspicious warning, which might be enough for you to understand the bug (I don't know enough about slang's memory management to offer a fix)
Looks like the diagnostics engine allocates a symbol from inside a block, then python tries to deallocate it using free from the interior of the block (an invalid free). I'm surprised I've had such trouble creating an example based on this.
To Reproduce
Unfortunately I don't have a small repro I can share, but the code roughly takes the following form:
Additional context
I "fixed" my problem by hacking pyslang to just leak everything 🤓