2024年是什么命| lsp什么意思| 盐酸氟桂利嗪胶囊治什么病| 什么水果吃了对皮肤好| 吐奶严重是什么原因| 小腹痛男性什么原因| 什么叫种水| 什么牌空调好用又省电| 喝酒不能吃什么药| 手机服务密码是什么| 什么叫动脉硬化| 6月7号什么星座| 虎配什么生肖最好| 什么食物降血糖| 公积金缴存基数是什么| 舌头发麻是什么病兆| 老年人口干是什么原因| 朱迅是什么民族| 美眉是什么意思| 筒骨炖什么好吃| 镶嵌什么意思| 官杀混杂是什么意思| 雨后的彩虹像什么| 幽门螺杆菌怕什么食物| 床上出现蜈蚣什么原因| 末梢神经炎吃什么药| 失责是什么意思| 一什么尾巴| 补肾吃什么药效果最好| 看幽门螺旋杆菌挂什么科| 脑梗是什么引起的| refill是什么意思| 学前班是什么意思| 眼镜什么品牌好| 69是什么姿势| 抿嘴是什么意思| 人肉是什么味道的| 三和大神是什么意思| 陆代表什么生肖| 上户口需要什么资料| 身体痒是什么原因| 大便深褐色是什么原因| 男人阳虚吃什么药最好| 尿微量白蛋白高是什么意思| 特需号是什么意思| 什么叫扁平疣长什么样| 拔河是什么意思| 草龟吃什么| 黑色碳素笔是什么| 腹泻输液用什么药| 梦见自己掉头发是什么意思| 肺动脉增宽是什么意思| 恒顺众生是什么意思| 窦性心律不齐是什么意思| 买房要看什么| 河豚有毒为什么还吃| 晚上八点到九点是什么时辰| 发蜡和发泥有什么区别| 碍事是什么意思| 减肥应该吃什么主食| 梦见鬼是什么意思| 定向招生是什么意思| 大使是什么行政级别| 什么是脱敏| 朴树是什么树| 感冒适合吃什么饭菜| 百衲衣是什么意思| 巨蟹和什么星座最配| 盆腔ct能检查出什么病| 血小板低是什么症状| 什么是越位| 拜你所赐什么意思| 乳头有点痒是什么原因| 脾脏结节一般是什么病| 知柏地黄丸对男性功能有什么帮助| 批号是什么意思| 什么叫书签| 通告是什么意思| 梦见捡硬币是什么预兆| 瞳距是什么| 嘴贱什么意思| 半夜醒来口干舌燥是什么原因| 拔完智齿可以吃什么| 小丫头是什么意思| 靶向药是什么药| 心律不齐是什么意思| 什么是张力| 好汉不吃眼前亏是什么意思| 水晶眼镜对眼睛有什么好处| 烟酸是什么| 客单价什么意思| 阿尔山在内蒙古什么地方| strange是什么意思| 左室舒张功能减低是什么意思| 霉菌性阴炎用什么药止痒效果好| 煲什么汤含蛋白质高| 湖北有什么好玩的| 瞳距是什么意思| dw是什么牌子的手表| 贺喜是什么意思| 为什么夏天容易拉肚子| 有冬瓜西瓜南瓜为什么没有北瓜| 雪中送炭是什么意思| 什么牌子的笔记本电脑好| 宾格是什么| 胸闷是什么感觉| 红薯什么时候种植| 沙漏是什么意思| 吃青提有什么好处| 吃什么催奶| 夜晚的星星像什么| 北京属于什么方向| 巨蟹座幸运花是什么| 44是什么意思| 预拌粉是什么东西| 口水多是什么原因| veromoda是什么牌子| 这次是我真的决定离开是什么歌| 乳酸偏高是什么意思| 婴儿放屁多是什么原因| 掌中宝是什么东西| 钢琴十级什么水平| 发好人卡是什么意思| 为什么腿会肿| 呦呦是什么意思| 遗传是什么意思| 群星是什么意思| 女人梦见狗是什么预兆| 孕反一般什么时候开始| 什么是原则性问题| 病理会诊是什么意思| 孕妇喝什么汤好| 粒子是什么| 河里有什么鱼| 回民为什么不能吃猪肉| 突然头晕是什么原因| 思前想后是什么意思| 孩子咬手指甲是什么原因| 胡巴是什么| 学长是什么意思| 什么辣椒最辣| 戒烟吃什么药| 结肠炎吃什么药| 拿到offer是什么意思| 抬头纹开了是什么意思| 天然气是什么味道| 什么头什么尾| 什么药一吃就哑巴了| 烧裆是什么原因| 霉菌感染男性什么症状| 高职本科是什么意思| 银杏是什么植物| 机位是什么意思| 真菌性龟头炎用什么药| 什么的荷花| 研究员是什么级别| 正襟危坐什么意思| 牙龈起包是什么原因| 韩国欧巴是什么意思| 什么忙什么乱| 孕32周需要做什么检查| 上不来气吃什么药| 肉炒什么菜谱大全| 胆水的成分是什么| 芒果不可以跟什么一起吃| 吃什么| lgg是什么意思| 满月是什么时候| 萎缩是什么意思| 闰月是什么意思| 充电宝什么品牌最好| 检查贫血挂什么科| 有病是什么意思| 牙疼吃什么消炎药| 信徒是什么意思| 腋窝出汗是什么原因| 坚果都有什么| rh血型阳性是什么意思| 天体是什么意思| 什么是钙化结节| 一什么斑点| cro是什么意思| 牛跟什么生肖相合| 大炮是什么| 生日蛋糕上写什么字比较有创意| 用什么可以解开所有的谜| 爱琴海在什么地方| 孩子大便出血什么原因| 女人梦见龙是什么征兆| 小腹胀痛吃什么药| 精神萎靡是什么意思| 国际章是什么意思| 为什么明星不激光祛斑| 花椒有什么功效| 拉肚子吃什么药好得快| 小孩有口臭是什么原因引起的| 女生真空是什么意思| 急性胃肠炎用什么抗生素| 女性腰酸是什么妇科病| 拔了智齿需要注意什么| 什么水果是发物| 女性脂肪率偏高说明什么| 经常喝咖啡有什么好处和坏处| 尊巴是什么| 什么工作赚钱最快| 甲状腺五类是什么意思| 经期吃榴莲有什么好处和坏处| 无名指长代表什么| 怀孕10多天有什么症状| maby什么意思| 心动过速吃什么药| 眼泪为什么是咸的| 宫刑是什么意思| 人棍是什么意思| 阑尾在什么位置| 月经提前半个月来是什么原因| 左进右出有什么讲究| 狗狗为什么会咬人| 海参是补什么| 淡泊名利是什么意思| 天丝是什么成分| 为什么来月经会有血块| 健康管理是什么专业| 水瓶座是什么星象| 兆字五行属什么| 吃茶油对身体有什么好处| 小脑延髓池是什么意思| 1月26日是什么星座| 生蒜头吃了有什么好处和坏处| 眼帘是什么意思| 天然气是什么味道| 为什么呢| 至多是什么意思| 为什么全麻手术后不能睡觉| 为什么一吃辣的就拉肚子| 晒伤用什么| 查艾滋病挂什么科| 眉毛淡的女人代表什么| 手抖吃什么药| 蜻蜓点水是什么生肖| sweat是什么意思| 韭菜不能和什么一起吃| 内痔有什么症状与感觉| 梦见红薯是什么意思| 龟苓膏是什么做的| 手足口是什么引起的| 梦到自己老公出轨是什么意思| 什么牌子的洗面奶好用| 四战之地的生肖是什么| plus什么意思| 12.28是什么星座| 落枕是什么原因| 子宫内膜厚是什么意思| 2012年是什么年| 小白脸什么意思| 蜗牛有什么特点| 阳性体征是什么意思| 肺活量不足是什么症状| 下午三点是什么时辰| 滴虫性阴道炎用什么药| 眼皮为什么会跳| 吃什么治肝病| 空调睡眠模式什么意思| 5.20是什么星座| 百度

男人阳虚吃什么药最好

百度   毕福康指出,人工智能主要在三个方面深刻地影响着汽车和出行的领域。

In computing, a null pointer (sometimes shortened to nullptr or null) or null reference is a value saved for indicating that the pointer or reference does not refer to a valid object. Programs routinely use null pointers to represent conditions such as the end of a list of unknown length or the failure to perform some action; this use of null pointers can be compared to nullable types and to the Nothing value in an option type.

A null pointer should not be confused with an uninitialized pointer: a null pointer is guaranteed to compare unequal to any pointer that points to a valid object. However, in general, most languages do not offer such guarantee for uninitialized pointers. It might compare equal to other, valid pointers; or it might compare equal to null pointers. It might do both at different times; or the comparison might be undefined behavior. Also, in languages offering such support, the correct use depends on the individual experience of each developer and linter tools. Even when used properly, null pointers are semantically incomplete, since they do not offer the possibility to express the difference between "not applicable", "not known", and "future" values.[citation needed]

Because a null pointer does not point to a meaningful object, an attempt to access the data stored at that (invalid) memory location may cause a run-time error or immediate program crash. This is the null pointer error, or null pointer exception. It is one of the most common types of software weaknesses,[1] and Tony Hoare, who introduced the concept, has referred to it as a "billion dollar mistake".[2]

In C, two null pointers of any type are guaranteed to compare equal.[3] Prior to C23, the preprocessor macro NULL was provided, defined as an implementation-defined null pointer constant in <stdlib.h>,[4] which in C99 can be portably expressed as ((void *)0), the integer value 0 converted to the type void* (see pointer to void type).[5] Since C23, a null pointer is represented with nullptr which is of type nullptr_t (originally introduced to C++11), providing a type safe null pointer.[6]

The C standard does not say that the null pointer is the same as the pointer to memory address 0, though that may be the case in practice. Dereferencing a null pointer is undefined behavior in C,[7] and a conforming implementation is allowed to assume that any pointer that is dereferenced is not null.

In practice, dereferencing a null pointer may result in an attempted read or write from memory that is not mapped, triggering a segmentation fault or memory access violation. This may manifest itself as a program crash, or be transformed into a software exception that can be caught by program code. There are, however, certain circumstances where this is not the case. For example, in x86 real mode, the address 0000:0000 is readable and also usually writable, and dereferencing a pointer to that address is a perfectly valid but typically unwanted action that may lead to undefined but non-crashing behavior in the application; if a null pointer is represented as a pointer to that address, dereferencing it will lead to that behavior. There are occasions when dereferencing a pointer to address zero is intentional and well-defined; for example, BIOS code written in C for 16-bit real-mode x86 devices may write the interrupt descriptor table (IDT) at physical address 0 of the machine by dereferencing a pointer with the same value as a null pointer for writing. It is also possible for the compiler to optimize away the null pointer dereference, avoiding a segmentation fault but causing other undesired behavior.[8]

In C++, while the NULL macro was inherited from C, the integer literal for zero has been traditionally preferred to represent a null pointer constant.[9] However, C++11 introduced the explicit null pointer constant nullptr and type nullptr_t to be used instead, providing a type safe null pointer. nullptr and type nullptr_t were later introduced to C in C23.

Other languages

edit

In some programming language environments (at least one proprietary Lisp implementation, for example),[citation needed] the value used as the null pointer (called nil in Lisp) may actually be a pointer to a block of internal data useful to the implementation (but not explicitly reachable from user programs), thus allowing the same register to be used as a useful constant and a quick way of accessing implementation internals. This is known as the nil vector.

In languages with a tagged architecture, a possibly null pointer can be replaced with a tagged union which enforces explicit handling of the exceptional case; in fact, a possibly null pointer can be seen as a tagged pointer with a computed tag.

Programming languages use different literals for the null pointer. In Python, for example, a null value is called None. In Java and C#, the literal null is provided as a literal for reference types. In Pascal and Swift, a null pointer is called nil. In Eiffel, it is called a void reference.

Null dereferencing

edit

Because a null pointer does not point to a meaningful object, an attempt to dereference (i.e., access the data stored at that memory location) a null pointer usually (but not always) causes a run-time error or immediate program crash. MITRE lists the null pointer error as one of the most commonly exploited software weaknesses.[10]

  • In C, dereferencing a null pointer is undefined behavior.[7] Many implementations cause such code to result in the program being halted with an access violation, because the null pointer representation is chosen to be an address that is never allocated by the system for storing objects. However, this behavior is not universal. It is also not guaranteed, since compilers are permitted to optimize programs under the assumption that they are free of undefined behavior. This behaviour is the same in C++, as there is no null pointer exception in the C++ language. On platforms such as Unix-like systems and Windows with the Visual Studio compiler, an access violation causes a C/C++ SIGSEGV signal to be issued. Although in C/C++ null dereferences are not exceptions which can be caught in C++ try/catch blocks, it is possible to "catch" such an access violation by using (std::)signal() in C/C++ to specify a handler to be called when that signal is issued.
  • In D, much like C++, a null pointer dereference results in a segmentation fault.
  • In Delphi and many other Pascal implementations, the constant nil represents a null pointer to the first address in memory which is also used to initialize managed variables. Dereferencing it raises an external OS exception which is mapped onto a Pascal EAccessViolation exception instance if the System.SysUtils unit is linked in the uses clause.
  • In Java, access to a null reference (null) causes a NullPointerException (NPE), which can be caught by error handling code, but the preferred practice is to ensure that such exceptions never occur.
  • In Lisp, nil is a first class object. By convention, (first nil) is nil, as is (rest nil). So dereferencing nil in these contexts will not cause an error, but poorly written code can get into an infinite loop.
  • In .NET and C#, access to null reference (null) causes a NullReferenceException to be thrown. Although catching these is generally considered bad practice, this exception type can be caught and handled by the program.
  • In Objective-C, messages may be sent to a nil object (which is a null pointer) without causing the program to be interrupted; the message is simply ignored, and the return value (if any) is nil or 0, depending on the type.[11]
  • In Python, dereferencing None raises an AttributeError, as NoneType has no (user-facing) methods or attributes defined.
  • In Rust, dereferencing a null pointer (std::ptr::null()) in an unsafe block results in undefined behaviour, which usually results in a segmentation fault or corrupted memory.
  • Before the introduction of Supervisor Mode Access Prevention (SMAP), a null pointer dereference bug could be exploited by mapping page zero into the attacker's address space and hence causing the null pointer to point to that region. This could lead to code execution in some cases.[12]

Mitigation

edit

While there could be languages with no nulls, most do have the possibility of nulls so there are techniques to avoid or aid debugging null pointer dereferences.[13] Bond et al.[13] suggest modifying the Java Virtual Machine (JVM) to keep track of null propagation.

There are three levels of handling null references, in order of effectiveness:

  1. languages with no null;
  2. languages that can statically analyse code to avoid the possibility of null dereference at run time;
  3. if null dereference can occur at runtime, tools that aid debugging.

Pure functional languages are an example of level 1 since no direct access is provided to pointers and all code and data is immutable. User code running in interpreted or virtual-machine languages generally does not suffer the problem of null pointer dereferencing.[dubiousdiscuss]

Where a language does provide or utilise pointers which could become void, it is possible to avoid runtime null dereferences by providing compilation-time checking via static analysis or other techniques, with syntactic assistance from language features such as those seen in the Eiffel programming language with Void safety[14] to avoid null dereferences, D,[15] and Rust.[16]

In some languages analysis can be performed using external tools, but these are weak compared to direct language support with compiler checks since they are limited by the language definition itself.

The last resort of level 3 is when a null reference occurs at runtime, debugging aids can help.

History

edit

In 2009, Tony Hoare stated[2][17] [18] that he invented the null reference in 1965 as part of the ALGOL W language. In that 2009 reference Hoare describes his invention as a "billion-dollar mistake":

I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.

See also

edit

Notes

edit
  1. ^ "CWE-476: NULL Pointer Dereference". MITRE.
  2. ^ a b Tony Hoare (2025-08-06). "Null References: The Billion Dollar Mistake". InfoQ.com.
  3. ^ ISO/IEC 9899, clause 6.3.2.3, paragraph 4.
  4. ^ ISO/IEC 9899, clause 7.17, paragraph 3: NULL... which expands to an implementation-defined null pointer constant...
  5. ^ ISO/IEC 9899, clause 6.3.2.3, paragraph 3.
  6. ^ "WR14-N3042: Introduce the nullptr constant". open-std.org. 2025-08-06. Archived from the original on December 24, 2022.
  7. ^ a b ISO/IEC 9899, clause 6.5.3.2, paragraph 4, esp. footnote 87.
  8. ^ Lattner, Chris (2025-08-06). "What Every C Programmer Should Know About Undefined Behavior #1/3". blog.llvm.org. Archived from the original on 2025-08-06. Retrieved 2025-08-06.
  9. ^ Stroustrup, Bjarne (March 2001). "Chapter 5:
    The const qualifier (§5.4) prevents accidental redefinition of NULL and ensures that NULL can be used where a constant is required.". The C++ Programming Language (14th printing of 3rd ed.). United States and Canada: Addison–Wesley. p. 88. ISBN 0-201-88954-4.
  10. ^ "CWE-476: NULL Pointer Dereference". MITRE.
  11. ^ The Objective-C 2.0 Programming Language, section "Sending Messages to nil".
  12. ^ "OS X exploitable kernel NULL pointer dereference in AppleGraphicsDeviceControl"
  13. ^ a b Bond, Michael D.; Nethercote, Nicholas; Kent, Stephen W.; Guyer, Samuel Z.; McKinley, Kathryn S. (2007). "Tracking bad apples". Proceedings of the 22nd annual ACM SIGPLAN conference on Object oriented programming systems and applications - OOPSLA '07. p. 405. doi:10.1145/1297027.1297057. ISBN 9781595937865. S2CID 2832749.
  14. ^ "Void-safety: Background, definition, and tools". Retrieved 2025-08-06.
  15. ^ Bartosz Milewski. "SafeD – D Programming Language". Retrieved 17 July 2014.
  16. ^ "Fearless Security: Memory Safety". Archived from the original on 8 November 2020. Retrieved 4 November 2020.
  17. ^ Tony Hoare (2025-08-06). "Presentation: "Null References: The Billion Dollar Mistake"". InfoQ.com.
  18. ^ Contieri, Maxi (2025-08-06). "Code Smell 304 - Null Pointer Exception". Maximiliano Contieri - Software Design. Retrieved 2025-08-06.

References

edit
  • Joint Technical Committee ISO/IEC JTC 1, Subcommittee SC 22, Working Group WG 14 (2025-08-06). International Standard ISO/IEC 9899 (PDF) (Committee Draft).{{cite book}}: CS1 maint: multiple names: authors list (link) CS1 maint: numeric names: authors list (link)
虚岁24岁属什么生肖 白细胞计数偏低是什么意思 左肺上叶肺大泡是什么意思 肾结石发作有什么症状 龟头炎什么症状
女人严重口臭挂什么科 小脚趾麻木是什么原因 放大镜是什么镜 儿童呕吐吃什么药 复查是什么意思
球是什么意思 刮痧有什么作用 鳌是什么意思 以纯属于什么档次 为什么糙米越吃血糖越高
jeans是什么意思 16岁能做什么工作 以纯属于什么档次 决明子泡水喝有什么功效 左侧卵巢内无回声是什么意思
十二月二十三是什么星座hcv7jop7ns2r.cn 为什么会得麦粒肿hcv8jop8ns8r.cn 维生素B1有什么副作用hcv8jop7ns1r.cn 小意思是什么意思hcv8jop4ns1r.cn 梦见自己的衣服丢了是什么意思hcv9jop1ns2r.cn
头皮屑大块是什么原因hcv9jop2ns1r.cn 吃东西感觉口苦是什么原因hcv8jop1ns2r.cn 嗯嗯嗯是什么意思hcv8jop8ns8r.cn 夏至节气吃什么helloaicloud.com 福建人喜欢吃什么fenrenren.com
青瓜和黄瓜有什么区别hcv8jop4ns7r.cn ems是什么意思gysmod.com 日照有什么好吃的hcv8jop1ns7r.cn 尿有味是什么原因hcv9jop2ns7r.cn 龙延香是什么naasee.com
脑供血不足用什么药效果最好hcv8jop7ns0r.cn 疏风解表的意思是什么hcv7jop6ns3r.cn lv什么牌子hcv8jop6ns9r.cn 待产包需要准备什么hcv9jop2ns4r.cn 利字五行属什么hcv9jop5ns4r.cn
百度