Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the possible situation of segmentationfault?

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you what the possible situation of segmentationfault is, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The so-called segment error means that the memory accessed exceeds the memory space given to the program by the system. This value is usually saved by gdtr, which is a 48-bit register, in which 32 bits hold the gdt table pointed to by it, and the last 13 bits hold the subscript corresponding to gdt. The last 3 bits include whether the program is in memory and the running level of the program in cpu, and the gdt is pointed to by a table in 64 bits. In this table, there is information about the code segment in which the program is running, the starting address of the data segment, the corresponding segment limit and page exchange, the program running level, memory granularity and so on. Once an out-of-bounds access occurs in a program, cpu will generate corresponding exception protection, and segmentationfault will appear.

What is "SegmentationfaultinLinux"?

That is, "when a program tries to access an area of memory that is not allowed (for example, trying to write a piece of memory that belongs to the operating system), or accessing the area of memory in the wrong type (for example, trying to write a piece of read-only memory). This description is accurate. To deepen our understanding, let's summarize SIGSEGV in more detail. The segment error should be the access to inaccessible memory, which either does not exist or is system protected.

Z SIGSEGV is an error that occurs when accessing memory, and it belongs to the category of memory management

Z SIGSEGV is a concept of user mode, which is what the operating system does when a user mode program misaccesses memory.

SIGSEGV is generated when a user-mode program accesses memory that is not allowed to be accessed by a read, write, or execute program.

A SIGSEGV is generated when a user-mode program accesses allowed memory in the wrong way.

User mode program address space, especially the range of address space that the program can access. In a broad sense, the address space of a process should include the kernel space, but it cannot be accessed.

Possible situations arising from segmentationfault

Pointer out of bounds and SIGSEGV is the most common situation, often see posts confusing the two, and the relationship between the two is really delicate. Here, we classify the out-of-bounds, wild pointers and null pointers caused by pointer operation (addition and subtraction) as pointers out of bounds. In many cases, SIGSEGV is caused by pointer out of bounds, but not all pointers out of bounds will cause SIGSEGV. An out-of-bounds pointer will not cause a SIGSEGV if it is not referenced. And even if dereferencing an out-of-bounds pointer, it does not necessarily cause a SIGSEGV. It sounds crazy, but it is. SIGSEGV involves the operating system, C library, compiler, linker and other aspects, we use some specific examples to illustrate.

The above is all the content of the article "what is the possible situation of segmentationfault?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report