Thread: Sometimes segfault, sometimes not

  1. #16
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The /proc/cpuinfo just tells you if it's available or not, not if the bit is enabled. Most 32-bit variants of Linux runs without PAE enabled, and without PAE enabled, all bits of the page-table are used. In PAE-mode, the page-table entries are 64-bit long, and the highest bit (bit 63) is used to indicate "NX" enabled or not (along with a bit in CR4 to enable NX).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #17
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by jcafaro10 View Post
    As for the nx bit. I did cat /proc/cpuinfo and saw that the nx bit IS there. What that means, I don't know. If the nx bit is enabled I shouldn't be able to do things that I'm able to do. Doesn't make sense.
    /proc/cpuinfo doesn't tell you whether NX is enabled. It simply tells you whether the CPU supports it.

    The state of the NX bit is a per-process thing.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #18
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by brewbuck View Post
    /proc/cpuinfo doesn't tell you whether NX is enabled. It simply tells you whether the CPU supports it.

    The state of the NX bit is a per-process thing.
    Yes, but for NX to at all possibly work, the system needs to be PAE-enabled. Most general kernels are not PAE-enabled -> no NX bit available.

    64-bit kernels are generally NX-enabled by default, since 64-bit OS requires PAE-type page-table entries (it actually isn't quite the same as PAE, since it's got 4-level page-tables, but it uses the same page-table entry layout as PAE). Sorry for the geek-level on this subject, but I was there when it was discussed for the first 64-bit kernel port.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #19
    Registered User
    Join Date
    Jul 2007
    Posts
    186
    Thanks for the help guys, I'm learning a lot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segfault with Linked List Program
    By kbrandt in forum C Programming
    Replies: 1
    Last Post: 06-23-2009, 07:13 AM
  2. Segfault with additional variable?
    By misterFry in forum C++ Programming
    Replies: 11
    Last Post: 11-12-2008, 10:55 AM
  3. malloc() resulting in a SegFault?!
    By cipher82 in forum C++ Programming
    Replies: 21
    Last Post: 09-18-2008, 11:24 AM
  4. use of printf prevents segfault!
    By MK27 in forum C Programming
    Replies: 31
    Last Post: 08-27-2008, 12:38 PM
  5. Segfault and Warning help
    By Uncle Rico in forum C Programming
    Replies: 1
    Last Post: 03-25-2005, 02:51 PM