stack

Of Memory Management, Heap Corruption, and C++

So, I need some help. I am working on a project in C++. However, I think I have somehow managed to corrupt my heap. This is based off the fact that I added a std::string to a class and assigning it a value from another std::string: std::string hello = "Hello, world.\n"; /* exampleString = "Hello, world.\n" would work fine. */ exampleStr...

How to prevent an object being created on the heap?

Does anyone know how I can, in platform-independant C++ code prevent an object from being created on the heap? That is, for a class "Foo", I want to prevent users from doing this: Foo *ptr = new Foo; and only allow them to do this: Foo myfooObject; Does anyone have any ideas? Cheers, ...

Getting stack traces on Unix systems, automatically

What methods are there for automatically getting a stack trace on Unix systems? I don't mean just getting a core file or attaching interactively with GDB, but having a SIGSEGV handler that dumps a backtrace to a text file. Bonus points for the following optional features: Extra information gathering at crash time (eg. config files). ...

Checking available stack size in C

I'm using MinGW with GCC 3.4.5 (mingw-special vista r3). My C application uses a lot of stack so I was wondering is there any way I can tell programatically how much stack is remaining so I can cleanly handle the situation if I find that I'm about to run out. If not what other ways would you work around the problem of potentially runni...

Measuring stack usage for Linux multi-threaded app

Hello, I'm developing a multi-threaded app for a Linux embedded platform. At the moment I'm setting the stack size for each thread (via pthread_set_attr) to a fairly large default value. I would like to fine tune that value for each thread to something smaller to reduce my application's memory usage. I could go through the trial and er...

Hooking into the TCP Stack in C

It's not just a capture I'm looking to do here. I want to first capture the packet, then in real time, check the payload for specific data, remove it, inject a signature and reinject the packet into the stack to be sent on as before. I had a read of the ipfw divert sockets using IPFW and it looks very promising. What about examples in m...

Interpreting Stacks in Windows Minidumps

As someone who is just starting to learn the intricacies of computer debugging, for the life of me, I can't understand how to read the Stack Text of a dump in Windbg. I've no idea of where to start on how to interpret them or how to go about it. Can anyone offer direction to this poor soul? ie (the only dump I have on hand with me actua...

What and where are the stack and heap

Programming language books usually explain that value types are created on the stack, and reference types created on the heap, without really explaining what these two things are. With my only programming experience being in high level languages, I haven't read a clear explanation of this. I mean I understand what a stack is, but where...

What is the best technology to build an online gambling / poker system ?

What technology / software / framework could be the best match to build an online gambling / poker system (website, standalone applications) ? Would you recommend Java/J2EE, .Net / Erlang ? Thank you. ...

Stack overflow from .NET code in IIS, but not in Winforms

Hello all. So I have a nasty stack overflow I have been trying to track down / solve for the past 8 hours or so, and I'm at the point where i think i need advice. The details: Interestingly enough this code runs fine when called in the context of our regular winforms application -- but I am tasked with writing a web-based version of ...

When does ++ not produce the same results as +1?

The following two C# code snippets produce different results (assuming the variable level is used both before and after the recursive call). Why? public DoStuff(int level) { // ... DoStuff(level++); // ... } , public DoStuff(int level) { // ... DoStuff(level+1); // ... } After reading some of the responses below I thoug...

How to preserve stack space with good design?

I'm programming in C for RAM limited embedded microcontroller with RTOS. I regularly break my code to short functions, but every function calling require to more stack memory. Every task needs his stack, and this is one of the significant memory consumers in the project. Is there an alternative to keep the code well organized and reada...

OSI model - What's the presentation and session layer for?

So I feel I pretty well understand the application layer, and everything below (and including) the transport layer. The session and presentation layers, though, I don't fully understand. I've read the simplistic descriptions in Wikipedia, but it doesn't have an example of why separating out those layers is useful. So: What is the se...

Increase Stack Size on Windows (GCC)

Is there a way to increase the stack size of a Windows application at compile/link time with GCC? ...

How to determine optimal thread stack size?

Actually, two sizes: initially committed and total reserved. Do you use static or dynamic analysis? Which tools? Which techniques? ...

Stack memory read

Hi, With the following piece of code: typedef struct { char fileName[ 1024]; time_t deleteTime; } file_item_t; .... .... setEntry(char *fileName) { file_item_t file; memset( &file, 0x00, sizeof( file_item_t )); memcpy( file.fileName, fileName, sizeof( file.fileName ) - 1 ); ... ... ...

Stack Size for Kernel Development

So I'm working on designing an OS, and I'm working on designing (not coding yet) the kernel. This is going to be for an x86 operating system, and my target is for more modern computers, so RAM can be considered to be at least 256M or more. My question is this: What is a good size to make the stack for each thread run on the system? Or b...

How to detect possible / potential stack overflow problems in a c / c++ program?

Is there a standard way to see how much stack space your app has and what the highest watermark for stack usage is during a run? Also in the dreaded case of actual overflow what happens? Does it crash, trigger an exception or signal? Is there a standard or is it different on all systems and compilers? I'm looking specifically for Win...

Fastest way to iterate over a stack in c#

I feel that using GetEnumerator() and casting IEnumerator.Current is expensive. Any better suggestions? I'm open to using a different data structure if it offers similiar capabilities with better performance. After thought: Would a generic stack be a better idea so that the cast isn't necessary? ...

Patching out CALLL by replacing with NOPs works in user space but not in kernel space

I have a device driver I want to patch. This device driver calls IOLog and I want to get rid of the logging. If I replace the CALLL to IOLog with (the corresponding number of) NOPs inside the device driver (kext), the kernel crashes with what looks like a smashed stack ("Backtrace terminated-invalid frame pointer 0"). The same techniqu...