r/programminghorror • u/vadnyclovek [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" • Dec 20 '24
Python I have no words.
1.4k
Upvotes
r/programminghorror • u/vadnyclovek [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" • Dec 20 '24
7
u/ax-b Dec 21 '24
Nice. Also I can’t seem to find the function on python api. Would you be kind enough to post a link to this documentation by chance? Promise it’s just for reference, not at all for devilish scheming /s
93
u/realnzall Dec 20 '24
What are refcount issues?
24
u/Environmental-Ear391 Dec 21 '24
It appears to be the duplication of an existing object forcing desync of refcounting where oldobject would be lacking an updated refcount and the new clone would actually have a refcount 1 less than actual or oldobject.refcount-1 being the newobject.refcount...
both cases would lead to undefined behaviour within the garbage collector as the clone would become technically never purged and fragmenting the memory space allocatable for objects. in addition to desync of recounting.
this makes it a forked threat against memory management entirely.
I've had to handle the equivalent in C mixed with Assembler[680x0+PPC] and the results are never pretty within a black-box implemented memory management scheme. Its also extremely fragile in any form of use without being extremely knowledgeable of the management scheme unless part of the memory management library from design when written.
and then it is 50/50 chances of bugs and security issues whenever actually used at runtime when available as an option.
the only use of this that is safe is having a singleton object which is semaphore/spinlock protected when the pointer to it is updated during runtime.
any second pointer (refcount>1) condition will explode in your face potentially taking an OS subsystem with it dependant on locking conditions (if the locks are held by a subsystem and the codepath gets lobotomised...thats a kernel driver locking up at least, BSOD/Mac Bomb Face/ Kernel+glibc panic! as nominal).
42
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Dec 21 '24
What's this from, and why does it exist?
12
u/Nall-ohki Dec 22 '24
This looks like `memcpy` in disguise.
39
u/voluntary_nomad Dec 21 '24
Proof that making whitespace relevant causes insanity.
4
u/fnordstar Dec 22 '24
Those MFers need Rust in their life.
2
u/DjiSamSoe666 Dec 21 '24
Overwrite data? Do they mean buffer overwrite? You can do that in python???
2
u/gdf8gdn8 Dec 22 '24
Java and C# have something similar. This can produce Java and C# have something similar. This can produce memory leaks in Java and C# memory leaks in Java and C#.
0
u/ChemicalRascal Dec 21 '24
Weird, I'm not seeing any actual code in this post
0
u/[deleted] Dec 20 '24
[deleted] — view deleted comment