LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-11-2005, 10:55 PM   #1
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Rep: Reputation: 16
whats an illegal address


what do we reffer as an illegal address?

any references. or ideas
 
Old 03-11-2005, 11:27 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
What kind of address? An illegal memory address is an address that your program is not permitted to access. Modern operating systems give processes virtual address spaces and map address onto physical memory. A program that tries to access unmapped memory will not be allowed to do so (this is something of a simplification, but basically accurate).
 
Old 03-11-2005, 11:32 PM   #3
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
thanx for response ,btmiller,

u mean to say except for the allocated range of addresses to our program/task/process, anything every address our 'entity' tries to access is illegal.
 
Old 03-11-2005, 11:34 PM   #4
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
or its a particular set of addresses in the memory our program should not address at all
 
Old 03-11-2005, 11:46 PM   #5
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
The only thing that I can think about right now that could lead into an illegal address, is when using pointers, for example:

Code:
/* test.c */

#include <stdio.h>

int main()
{
    int someInt = 3;        /* declares an integer */
    int *somePoint;         /* declares a pointer */
    int *anotherPoint;     /* declares yet another pointer */

    somePoint = &someInt;  /* here we assign the pointer to the address
                              of someInt */
    
    printf("%d\n", *somePoint);
    printf("%d\n", *anotherPoint);    /* this is an illegal address */

    return 0;
}
The line "printf("%d\n", *anotherPoint);" should be an illegal address because the pointer has not been initialized. Some compilers should compile it without telling any erros, some should say that the value was not initialized and the program would either crash during the execution or print wrong things...

Last edited by Mega Man X; 03-12-2005 at 09:08 PM.
 
Old 03-12-2005, 01:56 AM   #6
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
thanx Megaman X,

for the illustration :-)
 
Old 03-12-2005, 02:12 AM   #7
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
You are welcome kapsikum . I hope I got that address thing right though... I've not been very accurate replying to posts here lately... gheh.
 
Old 03-12-2005, 02:55 AM   #8
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
well , u r right
Megaman X
 
Old 03-12-2005, 04:28 AM   #9
fssengg
Member
 
Registered: Feb 2005
Location: Kerala(God's own country)
Distribution: Redhat-8
Posts: 35

Rep: Reputation: 15
well is there any way in linux to know which are the address range which the program can access?
 
Old 05-29-2006, 01:04 AM   #10
ganta.rajesh
LQ Newbie
 
Registered: May 2006
Posts: 1

Rep: Reputation: 0
Hello, On Windows there is an API named VirtualQuery, using which one
can find whether a memory region is legal or illegal, can anybody
tell me an API with the same functionality on Linux.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you believe this, This should be illegal!!!!! BajaNick General 6 11-19-2005 11:38 AM
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 04:33 AM
illegal use of my domain address Lui Linux - Security 9 06-17-2004 05:36 PM
This should be illegal Kovacs General 32 05-21-2004 03:58 PM
illegal or not? doralsoral Linux - Software 3 01-31-2004 03:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration