473,387 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

newbie in C

sd

Hi group,
lets suppose you do the following

int x;
int * ptr;
prt = &x;

without assigning any value to x

but you do this all within a compiler running on a virtual machine,
do this can damage the physical machine ?

thanks in advance, Carlos.

Jul 13 '08 #1
10 1144
>lets suppose you do the following
>
int x;
int * ptr;
prt = &x;

without assigning any value to x

but you do this all within a compiler running on a virtual machine,
do this can damage the physical machine ?
No. And neither can it "damage" the virtual machine - or the process
the code runs in.

Is this a trick question?

Dave
Jul 13 '08 #2
sd wrote:
Hi group,
lets suppose you do the following

int x;
int * ptr;
prt = &x;

without assigning any value to x
So far everything is just fine, once you fix the misspelled identifier (i.e.
compiler will tell you that prt is not defined, because you have a variable
named ptr but not prt).

If you were to do:

printf("%d\n", *ptr);

you would get a random value (not crypto random though, it may be very
easily predictable, but not by the C++ standard), but still you won't harm
the computer at all.
>
but you do this all within a compiler running on a virtual machine,
do this can damage the physical machine ?

thanks in advance, Carlos.

Jul 14 '08 #3
sd

excuseme, i m learning this crazy things

int * ptr;
ptr = 65;

now this mistake looks ok
this way ptr doesnt point
to any variable

of course, I do this inside a VM.
do this can damage the physical
machine ?.

thanks very much, Carlos.



"sd" <is***@mail.comescreveu na mensagem
news:%2****************@TK2MSFTNGP04.phx.gbl...
>
Hi group,
lets suppose you do the following

int x;
int * ptr;
prt = &x;

without assigning any value to x

but you do this all within a compiler running on a virtual machine,
do this can damage the physical machine ?

thanks in advance, Carlos.

Jul 14 '08 #4
sd
another "related" question,

what if I do such a mistake
in a physical machine.
do this can be "repaired"
by reinstalling windows
completelly?, i.e,
formationg hard disk and
installing Windows ?

thanks, Carlos.

"sd" <is***@mail.comescreveu na mensagem
news:%2****************@TK2MSFTNGP06.phx.gbl...
>
excuseme, i m learning this crazy things

int * ptr;
ptr = 65;

now this mistake looks ok
this way ptr doesnt point
to any variable

of course, I do this inside a VM.
do this can damage the physical
machine ?.

thanks very much, Carlos.



"sd" <is***@mail.comescreveu na mensagem
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>
Hi group,
lets suppose you do the following

int x;
int * ptr;
prt = &x;

without assigning any value to x

but you do this all within a compiler running on a virtual machine,
do this can damage the physical machine ?

thanks in advance, Carlos.


Jul 15 '08 #5
>what if I do such a mistake
>in a physical machine.
Your code:

int * ptr;
ptr = 65;

Doesn't do anything.

I assume you meant to write something more like:

int * ptr;
*ptr = 65;

Which would attempt to write to a random location.

In modern Windows this won't affect anything other than the process
running your code (which might crash). It won't affect hardware
(virtual or real).

Dave
Jul 15 '08 #6
sd
thanks Dave,

Please permit to me to be exceptic, how do u know this?
"In modern Windows this won't affect anything other than the process
running your code (which might crash) "

Carlos.

"David Lowndes" <Da****@example.invalidescreveu na mensagem
news:qa********************************@4ax.com...
what if I do such a mistake
in a physical machine.

Your code:

int * ptr;
ptr = 65;

Doesn't do anything.

I assume you meant to write something more like:

int * ptr;
*ptr = 65;

Which would attempt to write to a random location.

In modern Windows this won't affect anything other than the process
running your code (which might crash). It won't affect hardware
(virtual or real).

Dave

Jul 18 '08 #7
>Please permit to me to be exceptic, how do u know this?
>"In modern Windows this won't affect anything other than the process
running your code (which might crash) "
The hardware/OS isolates each process, so unless your code is running
as a kernel driver (which I presume it's not), it can't affect other
processes or the real hardware.

Dave
Jul 19 '08 #8
David Lowndes wrote:
>Please permit to me to be exceptic, how do u know this?
>"In modern Windows this won't affect anything other than the process
running your code (which might crash) "

The hardware/OS isolates each process, so unless your code is running
as a kernel driver (which I presume it's not), it can't affect other
processes or the real hardware.
This is of course true in general but it's possible to devise exceptions to
the rule. For example, if another thread is writing a file meanwhile, when
your app crashes you will get a half-written file, which in turn could
affect other programs.

The point is that the MMU hardware prevents direct effects on other
processes. Secondary effects are left to the progammer to ensure
correctness.
>
Dave

Jul 21 '08 #9

Hi

" For example, if another thread is writing a file meanwhile, when
your app crashes you will get a half-written file, which in turn could
affect other programs."
Perhaps such rupture could affect only its execution thread,
it should depend only on internal details of Windows. For example,
perhaps a thread really define its "environment activity", not only
refered to memory issues but also to any other related thing this
thread could affect.

IMHO, I believe there must exist mechanisms of protection in this sense,
otherwise a thread crash and its "environment activity" should be a very
dangerous threat for any running process.

Of course, all these rises the question about, what do things like

"safe threading"

really mean ?

Greetings, Carlos.
>The hardware/OS isolates each process, so unless your code is running
as a kernel driver (which I presume it's not), it can't affect other
processes or the real hardware.
This is of course true in general but it's possible to devise exceptions
to the rule. For example, if another thread is writing a file meanwhile,
when your app crashes you will get a half-written file, which in turn
could affect other programs.

The point is that the MMU hardware prevents direct effects on other
processes. Secondary effects are left to the progammer to ensure
correctness.
>>
Dave




Jul 30 '08 #10
Carlos wrote:
Hi

" For example, if another thread is writing a file meanwhile, when
>your app crashes you will get a half-written file, which in turn
could affect other programs."

Perhaps such rupture could affect only its execution thread,
it should depend only on internal details of Windows. For example,
perhaps a thread really define its "environment activity", not only
refered to memory issues but also to any other related thing this
thread could affect.
The only way to ensure that a thread's activity isn't left partially
completed is to never start the activity at all.
>
IMHO, I believe there must exist mechanisms of protection in this
sense, otherwise a thread crash and its "environment activity" should
be a very dangerous threat for any running process.
There are mechanisms, on a task-specific basis. For example, you can use an
ACID database to prevent the example problem I mentioned.

But some things just can't be made atomic.
Jul 31 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Philippe C. Martin | last post by:
Hi, Is there a program out there that would generate the C code to instantiate objects and call them: ex: miracle.exe -i mymodule.py -o module_internface.c ? I seem to recall a _yes_ to...
0
by: Twayne | last post by:
Twayne wrote: That's the verification I was looking for I think. There are times that doesn't seem to be so, but perhaps I'll looking at the wrong side of the tree in the wrong forest ... I...
5
by: Banibrata Dutta | last post by:
Hi, I've gone through the list of "language differences" between 2.3 / 2.4 & 2.5 of CPython. I've spend around 2 weeks now, learning v2.5 of CPython, and I consider myself still very very...
16
by: Raxit | last post by:
Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? what can i do easily with python which is not easy...
10
by: Peter Michaux | last post by:
On May 14, 8:55 pm, Prisoner at War <prisoner_at_...@yahoo.comwrote: Get it from the library. I cannot imagine needing to own an HTML book. There are plenty of good references on the web....
2
by: r_ahimsa_m | last post by:
Could you recommend me some free JavaScript validator? I was using JSlint but it reports nonsense errors. Please help. Thanks. /RAM/
6
by: raylopez99 | last post by:
Will ASP.NET 3.0 work under Visual Studio 2005? And what is a good newbie ASP.NET book? Subject: Will ASP.NET 3.0 work under Visual Studio 2005? And what is a good newbie ASP.NET book? My...
3
Lokean
by: Lokean | last post by:
Sorry for this newbie question, this is not my realm of expertese. I have searched google, tried several applications that claim they can do this, such as Mapforce, which I found confusing, to...
5
by: Dave | last post by:
I am new to Visual Web Developer 2005 Expres. I am using absolute positioning and every time I add a button control to my web form its width extends all the way to the edge of the page. IOW I...
5
by: SharkD | last post by:
Hi! I'm a total newbie when it comes to ASP (or any type of server-side programming). I want to start a project that does the following: 1. query Wikipedia for information regarding...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.