|
You can2take over the world until you have a skull-shaped island in a part of the ocean never visited by ships of photographed by satellites. It's part of the Evil Villain Code.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Don't forget the underground lair in an extinct(ish) volcano!
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
I'm not sure this world is worth taking over.
|
|
|
|
|
I think the world might be a kinder place if you took over.
I am sure the world would be more interesting !
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
|
Not sure that watch helps to get world domination, but I am eager to know what you will be making out of it.
A contrario, buying from aliexpress (or amazon) is definitely helping someone to get world domination.
|
|
|
|
|
i usually avoid them but they are good for finding hard to find electronics like this.
Real programmers use butterflies
|
|
|
|
|
I am afraid you are right.
|
|
|
|
|
Yay! First time ever I actually need to use one ... and it's for QA!
Stack overflow problem that he can't track down, so I thought "how do I monitor stack usage?"
And bingo: a pointer to a local variable!
static void Main(string[] args)
{
unsafe
{
Console.WriteLine(new IntPtr(GetStackLevel()));
}
foo();
bar();
}
static void foo()
{
unsafe
{
Console.WriteLine(new IntPtr(GetStackLevel()));
}
}
static void bar()
{
foo();
unsafe
{
Console.WriteLine(new IntPtr(GetStackLevel()));
}
}
unsafe static char* GetStackLevel()
{
char a;
return &a;
}
}
Probably won't work in production builds as the whole method's existence is likely to be optimized away, but ... works in dev ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Stack overflow problems? There's a site for that...
(IGMC)
|
|
|
|
|
What does this help you with Paul ?
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
He's running out of stack, but logging shows that recursion isn't (or shouldn't be) a problem.
So ... the next step is to find out where the stack is being used ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wow, the thrill of 'unsafe'.
Now goto is on the way!
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
CPallini wrote: Now goto is on the way! And then C++
|
|
|
|
|
Please! Let's not go backwards!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Is the guy using structs by any chance ?
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
I have no code to work from, but he says that all "local variables" have been moved to a class to reduce stack usage. I've mentioned large value types as parameters, but ... no code, so guesswork is the order of the day here - and gathering information, obviously!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Please! Let's not go backwards! .++C neht dnA
|
|
|
|
|
Not sure if this helps, but I use StackTrace and StackFrameData as discussed here[^] in production code, no pointers required.
|
|
|
|
|
This is also what I do, though the local is declared in a Thread::Start function that invokes the subclass' Enter function after saving the pointer in per-thread data. The pointer is then used to monitor stack usage and stop a stack overflow before it occurs.
|
|
|
|
|
Does it work in release versions?
I'd have thought an intelligent compiler would throw it's hands up in horror and optimize it into a register, then optimize the method into oblivion.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
The item to which a pointer is obtained is declared as a local in a function that remains on the stack, and the pointer to it is saved in per-thread data (the equivalent of thread_local ). So yes, it works in a release build. But this is also C++, and I disable some optimizations so that a release build can actually be debugged.
|
|
|
|
|
They can be quite useful - for example, if you want to get the bytes out of a SecureString[^] without going via a string .
public static byte[] GetBytes(this Encoding encoding, SecureString value)
{
if (encoding is null) throw new ArgumentNullException(nameof(encoding));
if (value is null || value.Length == 0) return Array.Empty<byte>();
IntPtr valuePtr = IntPtr.Zero;
try
{
valuePtr = Marshal.SecureStringToGlobalAllocUnicode(value);
if (valuePtr == IntPtr.Zero) return Array.Empty<byte>();
unsafe
{
char* chars = (char*)valuePtr;
int byteCount = encoding.GetByteCount(chars, value.Length);
var result = new byte[byteCount];
fixed (byte* bytes = result)
{
encoding.GetBytes(chars, value.Length, bytes, byteCount);
}
return result;
}
}
finally
{
if (valuePtr != IntPtr.Zero)
{
Marshal.ZeroFreeGlobalAllocUnicode(valuePtr);
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Timothy confused, initially, by 0 BYTES FREE (3, 4, 11)
_______________________
Sorry about the very late solution here folks, life gets in the way sometimes!
TOO MUCH INFORMATION
Timothy = Tim
confused (anag. indicator) = TMI
initially = abbreviation / initials
TMI = Too Much Information
0 bytes free = Too much information :-D The point of using the VAR formatting was simply to emphasise that yes, the message was to be taken literally.
I'd quite liked the "0 bytes free" = "too much information" idea anyway, then last week someone replied to Griff's comment that he was off for a wee with "TMI = Too much information" and the die was cast... S'pose I need to think of something else for tomorrow now. Advance warning - I'm out from 09:30 and not back to 16:30, and being on duty can't access emails!
modified 12-May-21 11:54am.
|
|
|
|
|
I suspect you will be up again tomorrow Derek - I'm nowhere with this one.
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|