« first day (1604 days earlier)      last day (1255 days later) » 

4:26 AM
how to cast a base pointer to a base reference?
case SymbolType::FunctionDeclaration: [[fallthrough]]
case SymbolType::FunctionDefinition:
`warning: ‘fallthrough’ attribute ignored [-Wattributes]`

I don't understand the warning.
 
 
5 hours later…
9:15 AM
@Yashas the fallthrough attribute is only necessary if you have some statements in the case
 
nwp
9:54 AM
@Yashas auto &base_ref = *base_pointer;
 
 
3 hours later…
12:59 PM
ugh programs who complain that 30 is not a float are so stupid. Bro, why force me to write 30.0 that's such an annoyance
 
nwp
30.0 is a double :D
 
1:21 PM
@Hakaishin because you want to clearly indicate what you want? Also if you want a float you'd need to write 30.0f
 
1:52 PM
float foo = 30; how is it not clear that I want a float which is 30?
why force me to repeat myself by adding .0, that's just stupid
 
nwp
C++ doesn't force you. It has implicit conversions, so this is legal C++. And good tools will not even warn, because they know there is no loss of precision here.
 
2:09 PM
@nwp ros params force me
 
nwp
I don't know what that is.
For what it's worth, C++'s implicit conversions are mostly seen as a mistake.
 
@Hakaishin Providing integer literals to initialize a float is sloppy and the compiler is right to warn you. It requires an implicit conversion that can change the value you intended to assign. By using a floating point literal you acknowledge to the compiler that you recognize the potential loss of precision. By using integer literals it is not clear if you intended to exploit the lossless property of integers or not.
@nwp I am glad that this opinion on implicit conversions seems to be becoming more popular.
 
nwp
I'm not. It often makes the code unnecessarily verbose. Especially in this case where the compiler can trivially prove that no loss of precision happens. C++ does it correctly in this case. Narrowing conversion from int to float result in a compilation error, yet the code compiles as it should.
The same applies to explicit constructors that break the return {args}; syntax and require to duplicate the type name. People love that. I don't.
 
2:34 PM
To be fair, nobody loves duplicating type identifiers. What they love is preventing accidentally converting, which has the negative consequence of requiring you to duplicate information. To say people like explicit because they love duplicating information is disingenuous.
 
nwp
2:48 PM
I don't think it actually prevents accidental conversions. It does when the questionable conversion fails to compile and you then pay attention, but not when you put explicit conversions all over the code and they become background noise that your brain ignores. Requiring people to write lots of explicit conversions is a bad thing.
Once you get used to just silence conversions with a cast you lost what you wanted to gain and additionally pay with more verbose code.
 
3:03 PM
I would suggest that if you have "conversions all over the code", specially to the point where it becomes background noise, then that is problem problem with the code requiring too many conversions. Though I'll admit I am not against implicit conversions between class types, because those can at least be allowed and disallowed according to the class' designer wishes. Sometimes it is useful and even necessary.
What I strongly believe is that implicit conversion between built-in types should not be a language feature.
 
nwp
Maybe in a language where numeric literals get their type deduced instead of assigned based on what they look like that would be reasonable. Though even then ... having Qt use int for indexes and the standard library using std::size_t is a huge pain that does require casting all over the code and I don't see a way to get around that.
 
@nwp I guess sometimes you are stuck with what you have. I think Qt could do everyone a favor if they adopted the standard containers.
I've considered using custom allocators with a signed size_type to get around this, but I've never tried to apply it.
I'd be curious to know if anyone has actually applied this in a practical application.
 
nwp
@FrançoisAndrieux I thought people agree that the standard library is the one that made a mistake making std::size_t unsigned.
 
@nwp Yes, I also agree with that. This is why I've considered using custom allocators with standard containers to define a signed size type.
I'm curious if anyone who sees this has ever tried it, and if it worked out.
 
nwp
Well, time for std2 to save the day. Or stdn for some value of n.
I never messed with allocators.
> size_type (optional) An unsigned integer type.
 
3:18 PM
Ah well. At least that answers that.
 
nwp
@nwp Maybe Java had it right all along in forbidding unsigned completely. Though they do have to pay for that decision as well.
 
3:44 PM
@Hakaishin You'd have to ask K&R but the answer is probably space. Storing an integer literal or xoring a register is cheaper than storing or loading a double (30.0) in many cases.
also it's possible to move things around as a float without actually having floating point hardware support
 
what does mips gives each program 32 bits address space?
 
@CătălinaSîrbu what? Which OS?
 
it doesn't say it's just a lecture about virtual memory
 
3:59 PM
so it's just about virtual memory address spaces.
Basically just "a virtual memory address is 32-bits and we can map every address in that space to physical memory"
 
I can't believe how long it took me to realize that the kernel operates in the same virtual address space as the application
even if the pages are mapped into every virtual address space and are marked as supervisor
 
yeah, I was just confused about them saying that's a property of "MIPS" and not any specific operating system. Because you can easily imagine an OS without separate virtual memory spaces for every "program" and even an OS that allows "a program" to switch between multiple Virtual Memory spaces
 
@PeterT Yeah... Mill does that, and technically segmentation can be thought of like that. Ditto device pointers for certain things like graphics cards
 
yes, the std messed that one up
I come from Python mainly so I would like if I could just type any literal I want and it implicitly converts it. I generally agree that implicit conversion is bad, but not for literals, because it's so obvious it's not some random object from some lib, but well a literal
 
4:18 PM
:51055911 the kernel doesn't opperates in the kernel space?
*************Kernel spce****|*************User Space**********|
----------------------------|---------------------------------
 
you can protect pages to be only accessible in kernel mode, but as far as I know the kernel usually has regular access to the user mode memory of a process
 
4:53 PM
if a recursive fuction fails, the stack overflow error ocurs but won't the os allocate more space for program and add in the lookup table ?
i mean stack overflow is related to program memory or ram memory?
 
@CătălinaSîrbu Kernel space is just pages marked for the kernel only, that's all. It's still part of virtual memory
otherwise the kernel would need to convert logical to virtual addresses all the time and that's annoying
@CătălinaSîrbu No, usually not normally stack space is deliberately limited to prevent a program from destroying the machine with a stack overflow. in Kernel space this is extremely limited
 
kernel space it s some memory which does not needs attention from our side, right?
 
@CătălinaSîrbu from user space? usually not. Occasionally APIs can be leaky. Things like File handles etc hold onto kernel memory in effect
 
That's why Handle leaks can be devastating
although there are two types of kernel memory if you think about it, per task/process and universal
universal memory is 'locked' and doesn't change regardless of the running process, it's de-facto mapped into the same logical address in every process
per task/process memory is privileged but not mapped into every process/task
Windows refers to these as 'paged pool' and 'non-paged pool'
I don't remember if linux cares
 
 
2 hours later…
7:05 PM
kernel memory is just once for the entire system
or once for each process ?
 
@CătălinaSîrbu yes to both, some memory is shared... and other pages are not
the memory that is shared is usually things related to device drivers and very low level system stuff
 
Tom
Hi all!
If I write an overloaded Copy assigment operator with copy-and-swap idiom and an overloaded Move assigment operator, which one will have better performance? I guess the performance would be the same in both cases, if the parameter was an Rvalue.
 
@Tom best is not to write either. But if you overload a copy operator you had best copy
if you don't you're breaking the contract of a copy operator/constructor
 
could you provide me some nice to read document about this kind of memory management ?
 
@CătălinaSîrbu not really? it's not something most people care about and it's OS specific
 
7:16 PM
ok, thank you
 
29
Q: What does the Kernel Virtual Memory of each process contain?

clawsWhen say 3 programs (executables) are loaded into memory the layout might look something like this: alt text http://img97.imageshack.us/img97/3460/processesm.jpg I've following questions: Is the concept of Virtual Memory limited to user processes? Because, I am wondering where does the Operat...

actually has some good answers though
 
I don't understand the fact that kernel is actually the code and some cache memory and buffers stored for each process. It makes more sense to be once per memory, isn't it the space for the entire kernel? Isn't there just one kernel ?
 
@CătălinaSîrbu There is one kernel, but there are many tasks. A processor doesn't have a concept of a 'process' just a task. A process is in effect a collection of tasks that share the same virtual memory space from a userland perspective
 
why kernel resides in virtual memory?
 
@CătălinaSîrbu Because it has to communicate with user processes? And it's expensive to switch memory modes. But that doesn't mean that the logical and virtual addresses can't be the same for kernel mode
 
7:24 PM
it could've just been stored in actual physically RAM as far as I understand it's something not such changing
 
@CătălinaSîrbu it effectively is, the kernel pages are always resident and don't leave even when the process changes
but that doesn't mean the logical address and the virtual addresses are the same
remember that even 32GB of ram isn't going to fill up a 64bit address space
 
maybe I'm wrong but virtual addresses were added because of lack of physically RAM, therefore you could "simulate" infinite RAM. But the kernel is not that infinte, or unpredictable. And My question is why is it stored in virtual memory instead of pysical memory without being passed through any converting table
 
@CătălinaSîrbu nope, they were added for security and isolation primarily. Also the ability to page things out
but you could technically do that with segments previously and windows 2.0 and 1.0 did
Virtual memory also allows you to share between processes easier
 
how should I see the kernel
as a program which does what
shortly it does the connection between hardware and software, right ?
 
the kernel is best viewed as a program unto itself, that has a few jobs. 1. to interact with hardware. 2. to provide a stable env for the userland 3. manage all of this
but it doesn't need to be a multitasking OS for example
@CătălinaSîrbu and scheduling tasks
but it also does things like providing services to user space programs
 
7:30 PM
and because each process (task) needs access to hardware, needs to be managed by someone you need kernel in virtual memory so that it is easyer to be accessed?(by the tasks)?
 
@CătălinaSîrbu well you need it in virtual memory because the processor doesn't like switching modes. It needs to know how to interpret a jump instruction. It's best if it can do so consistently all the time.
 
so this is the thing that I'm missing
there is just virtual memory
and I was thinking there are multiple ways of accessing memory
on the same arhitecture
 
@CătălinaSîrbu not at once. When the processor boots there are no page tables. So once those are set up and switched on the processor only interprets things through that lens
 
so if my computer works with virtual memory and pagination it won't switch to other method as long as it is in use? Or as long as it has the same architecture (meaning you could do some setups and then reboot)
 
@CătălinaSîrbu on modern systems no
the 286 was wierd
 
7:35 PM
i've seen online about one architecture that changed the segments after rebooting
 
it's pretty rare these days. AFAIK the only time that sort of thing happened was on the 286... and it's because the 286 didn't have v8086 mode
but even segmentation is rare these days
the x86 CPU is the last CPU in regular usage that AFAIK still has segments
but they aren't really used?
regardless once paging is activated the kernel uses virtual address internally and then uses logical (real memory addresses) for setting up the page tables
or modifying them
 
Tom
8:03 PM
@Mgetz Thank you!
 
8:37 PM
How to create a bool from an integer in LLVM IR?
I accidently casted integers from iN to i1 and if(10) started evaluating to false which isn't surprising. I think I need something like == 0 for casting to bool. Is there a method in IRBuilder that already does this conversion directly? (Nothing wrong with a comparison except that it wouldn't be as readable as a direct instruction).
 
inside a program it has memory alocated for:
- executing code
- static variables
- stack
- heap

I would Like to know, when an app whats to run, it asks the OS for memory , but how much memory? What happends if it asks for 4mb memory and then yoour stack grows very much near the heap threhsold? Is it going to crash or the os is going to extend the memory allocated for the process?
 
9:40 PM
@CătălinaSîrbu In most modern OSes the executable be it PE or ELF has parameters that dictate stack size at launch. The OS allocates that and then jumps to _start on linux or a specific entry point on windows.
The application then proceeds via bootstapping code to set itself up
including heap etc.
 
not quite understandable :)
 
@CătălinaSîrbu but if the stack overflows the allocated area? The OS triggers a stackoverflow fault
@CătălinaSîrbu basically? The executable says in metadata it needs so much space for the stack.
the OS allocates that when it loads the executable
 
but then for what would a process need to dmand more memory if the stack will overflow anyway?
 
@CătălinaSîrbu well it shouldn't?
 
so a program can't ask the os for more space while running ?
 
9:42 PM
@CătălinaSîrbu it can, as heap
or it can ask for the OS to load another executable
 
so if the heap nears the stack threshold ?
os allocates new page?
 
@CătălinaSîrbu there is a guard page
basically the heap and the stack will generally be placed such that the stack can never overwrite the heap
and they will grow in opposite directions
the stack always has a guard page at the end
 
if the program is running and the heap is growing towards the stack from the highest address to lowest, and let's say between the stack pointer and heap pointer is less than 4 bytes left and a dynamic memory allocation is demanded of about 20 bytes, what would happen?
 
@CătălinaSîrbu wouldn't happen?
you deliberately set it up to expand opposite ways
just to prevent that
 
I dont get it
 
9:48 PM
so lets say an application asks for 1MB of stack, and 20MB of heap
you set up the memory space for that application such that the stack will grow (based on the endianness of the processor) away from where the heap is located
also the heap manager in the libc deliberately grows the heap away from the stack
 
@CătălinaSîrbu doesn't happen
 
but what about this way of growing towards each other
 
you'd move the heap up and the stack down
even if you did do that you'd have a guard page in between them
 
does it makes any differeence?
 
9:52 PM
yes... it's much more secure to have them grow opposite directions
the stack size is usually fixed
that said... threads are a thing
so it's kinda moot
 
but it is odd this kind of heap growing towards stack or what? bc I've read some explainations and all where talking about stack growing towards heap not opposite
 
it practice it doesn't really matter
if you stay within the confines of defined behavior, it is not observable
 
@CătălinaSîrbu again... guard pages
guard pages act like tripwires
if you touch them.. you crash
remember page tables allow you to map a page as non-resident. E.g. it exists but doesn't actually exist in logical memory for that process
if the process attempt to access it it triggers a page fault, the OS can then determine it's a guard page and kill the application
 
76
A: Why does the stack address grow towards decreasing memory addresses?

Mehrdad AfshariFirst, it's platform dependent. In some architectures, stack is allocated from the bottom of the address space and grows upwards. Assuming an architecture like x86 that stack grown downwards from the top of address space, the idea is pretty simple: =============== Highest Address (e.g. 0xF...

 
@CătălinaSîrbu that's just an example?
 
10:01 PM
yes
 
I heard that if you need to use vmm then you have some real problems in you code :))
or I'm wrong ...?
 
@CătălinaSîrbu VMMap is just virtual memory map
it's just a tool to look at a VM space for an app
 
but it kinda shows you if you have some overlapping memory zones?
 
@CătălinaSîrbu no because that's not allowed
well... it's complicated but the way you're asking it's not allowed per se
you can technically map the same logical address however you want
 
10:07 PM
I was talking about Rational Purify, sry :)) I don't know why but for a second VMMap seems similar with the other :)
 
FWIW stacks hitting heap doesn't happen on most modern systems. Particularly not 64bit
even 8MB stacks are not unusual and it would be rare to exceed that
 
thank you
 
 
1 hour later…
11:36 PM
hi all, does anyone understand encryption? it has me bewildered?
 

« first day (1604 days earlier)      last day (1255 days later) »