Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
Is reading from unallocated memory safe?

Is reading from a random address safe? I know writing is undefined behaviour but how about reading only?

Well, in many visual debuggers, I can see the contents of the memory in an arbitrary address. How is this done?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Since the behavior is undefined, the answer is undefined - or at the very least, erratic.

If you get lucky and the random address is within the memory bounds of your program, it would be fine to read most likely and you'd just get random junk.

If it's outside of the scope, (i.e. 0x0/NULL), you'd most likely get a segmentation fault (although again, this isn't guaranteed) which would terminate your program - if you'd consider this "safe" then yes, otherwise no.

over 4 years ago · Santiago Trujillo Report

0

No, it is not safe. Even if you don't care about the value being defined or accurate, there is such a thing as memory mapped IO, so a random address could interact with peripheral hardware. I did that in the days before protected memory, and yes, it can bring down the system.

Nowadays, depending on your system, I'd expect to see a segfault for addresses outside your process space. Without that protection, a bad app could access valuable data, like passwords, credit card info, etc. when used in a good app.

Also, addresses you see in the debugger are likely not real, physical addresses. Instead, you probably only see virtual memory addresses.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!