Stack is a data structure. A heap is not a data structure. A stack can be created in the heap.
In fact, the way you appear to be describing them, they are MEMORY ALLOCATION schemes. Programming languages user a third mechanism: static allocation.
If you go behind the programming languages, a heap is just memory. A stack is just memory. The only thing that makes a stack a stack is that the memory is allocated last in last out. Any memory can be a stack.
It sounds like some elaboration is in order.
Executable and shared library files are actually programs that instruct the loader what to do. When you run a program, the executable file directs the loader to allocate pages of memory. This memory will usually be read only (static data), read/write (initialized program data), read/write demand zero (static data initialized to zero, and read/execute pages. One of blocks the executable directs to be creates is designated as the stack. The EXE instructs the loader to place the Stack Pointer register at (near) the top of this block.
Note that there is no heap when the program starts.
Once the program starts, memory managers are likely to execute. Usually there is only one in a program but it is possible to have multiple memory managers. These memory managers allocate read/write pages of memory that become heaps.
It is entirely possible for the application to use a memory manager to allocate a block of memory and then make that the program stack (rare, but it is common to allocate application stacks for various algorithms).
A stack is a generic data structure.
The program stack is a stack that is managed by the stack pointer register.
The stack itself is just a block of read/write memory.
A heap is just a block or read/write memory that is controlled by a memory manager. The memory manager will certainly impose a data structure on the heap but that structure is not visible to the application. All the application sees is that pages have been added to its address space.
There are then two levels of dynamic memory allocation.
- Page allocation from the operation system
- Block allocation from memory managers.
Memory managers have to call #1 to service calls for #2. Generally one refers to memory allocated from memory managers as being "dynamic."
However, the pages loaded in an application can also be dynamic. While the program loader sets up the initial state of the application, the application can modify its page layout by allocating and freeing pages. In most systems, the application can even free pages created by the application loader (but that is likely to cause a crash).
Summing up:
1. The application can have read only, read/write (initialized or demand zero), and read/execute pages of memory.
2. Any page can be made the program stack (but it better be read/write).
3. One or more memory managers can allocate read/write pages and use them for heaps.