undefined behavior指令检测指编译器编译时即插入某些指令来检测程序的怪异行为.

但编译器本身并不对这样的行为进行处理.处理它是程序员的任务,需要写一些对应这些行为的"驱动".

通过定义__ubsan_handle_*()这样的函数来进行处理.

现在x86已经开始支持这种异常行为的处理,通过引导参数来指定内核处理哪些异常的程序行为:

ubsan_handle=OEAINVBSLF,其中

O - different kinds of overflows
E - negation overflow, division overflow, division by zero.
A - misaligned memory access.
I - load from/store to an object with insufficient space.
N - null argument declared with nonnull attribute,
    returned null from function which never returns null, null ptr dereference.
V - variable size array with non-positive length
B - out-of-bounds memory accesses.
S - shifting out-of-bounds.
L - load of invalid value (value out of range for the enum type, loading other then 0/1 to bool type)
F - call to function through pointer with incorrect function type(gcc还不支持)

要求gcc 4.9以上

系统消息 若觉得内容不错,请点击左上角的"赞"图标,以优化网站的内容呈现。 另外,请及时验证注册邮箱,否则收不到21QA发出的红包。 官方Q群:250203055

asked 31 Oct '14, 20:19

perr's gravatar image

perr
406364151

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link: [text](http://url.com/ "title")
  • image: ![alt](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×85
×8

question asked: 31 Oct '14, 20:19

question was seen: 851 times

last updated: 31 Oct '14, 20:19

powered by O*S*Q*A

粤ICP备14040061号-1