in reply to Re^22: Perl crash during perl_clone
in thread Perl crash during perl_clone
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^24: Perl crash during perl_clone
by BrowserUk (Patriarch) on Nov 09, 2010 at 12:06 UTC | |
I found this function in perlguts, section "Examining internal data structures with the dump functions". Well yeah, but that doesn't define the arguments. Not even just how many. And it use both Perl_sv_dump() and sv_dump() in the same para implying they might be the same thing. But that post I linked suggests otherwise. My attempts to use either here just crash. I've been trying to wrap my brain around why your making a copy of the SV rather than just storing the SV* would make a difference, and the only thing that makes any sense is that this "mortality" thing. The SV* you receive points to a temporary SV that has been GC'd or reused by the time you try to use it. Maybe if you incremented its refcount (the SV pointed at by the SV* you receive), then Perl would know there was another reference kicking around somewhere and not recycle it? I thought I'd try that and it worked. This (minus the unchanged bits from above) allows me to use coderefs:
| [reply] [d/l] [select] |
by perlmonk1729 (Acolyte) on Nov 10, 2010 at 06:51 UTC | |
This was precisely my theory as well. I guess "out-of-scope" etc., werent the right phrases to describe in a perl context (I'm a "C" guy, learning Perl as needed). Maybe if you incremented its refcount I had just stumbled across this SvREFCNT_inc yesterday and was thinking of trying it. I'm glad to hear it worked for you. Do you think I should still be worried about going ahead with this as the right solution? So far my testing hasnt shown any negative/unexpected results. | [reply] |
by BrowserUk (Patriarch) on Nov 10, 2010 at 08:08 UTC | |
Do you think I should still be worried about going ahead with this as the right solution? So far my testing hasnt shown any negative/unexpected results. Honestly, I am uncomfortable with expressing an opinion on that. I am unaware of anyone else doing anything like this--sharing an interpreter context between multiple concurrent C-threads--so you are on bleeding edge without a backup or safety net. You're running code I've never seen, on a platform I don't use. To run even theoretically correctly requires the use of mutexes. I've use platform dependant mutexes, you'll have to use something else. The only mechanism I'm aware of on your platform is pthreads cond_vars. At best I find these confusing to use; at worst down right flaky. They seem to be (akin to) "level triggered" rather than "edge triggered" interrupts, with all the ramifications that implies. You will have to code those and I cannot help you. Even if you posted your implementation, I couldn't judge it one way or another. Whilst my implementation runs properly on my platform for as long as I care to leave it running, when it terminates it produces errors:
This is almost certainly because I have not coded a mechanism to terminate the C-threads, hence they attempt to call back when the perl thread is undergoing global destruction, and errors occur. But "Modification of a read-only value attempted ..." is a weird error to receive? Is that indicative of a coding error within the XS? Would it behave differently on your system (as with Perl_sv_dump)? I'm simply not qualified to answer that. Also, you've never really explained why you need to use coderefs rather than qualified subnames? They have geven me less trouble on my system. They don't require me to mess around with mortality--which has to be a good thing :) I haven't been able to exercise, much less test, your real code on your real platform, so any opinion I expressed would be a wild-assed guess, and frankly irresponsible. I'm not enamoured with that idea. Finally, I'm not party to the criticality of your systems or data; or whether you are subsequently going to start selling your code as part of a package to run air traffic control systems, heart-beat monitors or similar. I cannot make that call for you. I do know that I would want to soak test this in a testbed environment for a good long while before declaring it production ready. And if the system and data involved are in any way critical; multiple, distinct, realistic testbeds for considerably longer! The the last partial code I posted contained several errors, so here is the full thing with the corrections:
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by perlmonk1729 (Acolyte) on Nov 12, 2010 at 10:05 UTC | |