why not? printf("%x\n", *(int *)0x378);

This is a discussion on why not? printf("%x\n", *(int *)0x378); within the C Programming forums, part of the General Programming Boards category; printf("%x\n", *(int *)0x2ef); Program terminated with signal 11, Segmentation fault the lowest address i could reach is 0xbfbffffc why? just ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    9

    why not? printf("%x\n", *(int *)0x378);

    printf("%x\n", *(int *)0x2ef);
    Program terminated with signal 11, Segmentation fault

    the lowest address i could reach is 0xbfbffffc why?

    just trying to snoop at a UART controller, is that a crime?

  2. #2
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    Maybe OS denied your access.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    A segmentation fault means you are accessing a segment of memory you shouldn't. Most modern operating systems don't like you to start peeking around, so you probably shouldn't poke around where you don't belong.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    9

    Excuse me!?

    i am the root of FreeBSD 6.0!
    maybe its the architecture question? not permissions?
    can i use an assembly code for that? and why not C then? thats what i wana know

  5. #5
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    Modern operating systems use virtual, protected memory. There's undoubtedly an API function to gain access to the UART.
    If you understand what you're doing, you're not learning anything.

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    6,174
    Running as root is insufficient to allow a program to get direct access to the hardware - with any unix. root just has more privileges than other users. One of the privileges is ability to install things like device drivers --- which, once installed, can access hardware. Drivers are programs that are written in specific ways, so they can be trusted not to run rampant when used. Any program executed by a user (and root is a privileged user) must rely on a device driver to access the hardware on its behalf.

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    > just trying to snoop at a UART controller, is that a crime?
    Use a proper API then - this isn't DOS you know.

    I suppose if you really wanted to, you could use the special file "/dev/mem" to look at real memory.

    Ah, but 0x2ef isn't even a memory location is it.
    It's one of the 64K of I/O locations which is completely separate from memory.



    > I am the root of FreeBSD 6.0!
    You're still in a virtual memory OS though.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21