carbon-lang icon indicating copy to clipboard operation
carbon-lang copied to clipboard

integer overflow in explorer

Open pk19604014 opened this issue 3 years ago • 3 comments
trafficstars

package P api;

fn Main() -> i32 { var count: i32 = 5; while (not (count == 0)) { count = count - 112722749; } return 0; }

$ bazel run explorer:explorer /tmp/crash.carbon ... interpreter.cpp:172:69: runtime error: signed integer overflow: -2141732226 - 112722749 cannot be represented in type 'int'

pk19604014 avatar Jun 03 '22 20:06 pk19604014

Not sure whether this should be caught and reported as a program error or left as is.

pk19604014 avatar Jun 03 '22 20:06 pk19604014

I think explorer should be catching this and reporting it as a runtime error, rather than leaving it to ubsan to diagnose.

zygoloid avatar Aug 25 '22 20:08 zygoloid

Thanks.

Relevant Discord discussion -- https://discord.com/channels/655572317891461132/763516049710120960/982378627968675930 One of recommendations was to look into llvm's APInt -- https://llvm.org/doxygen/classllvm_1_1APInt.html

pk19604014 avatar Aug 26 '22 12:08 pk19604014

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the inactive label. The long term label can also be added for issues which are expected to take time. This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Nov 25 '22 02:11 github-actions[bot]

The current explorer catches this as a runtime error

RUNTIME ERROR: /home/guille/test.carbon:6: integer overflow

I guess this issue can be closed now.

guille2718 avatar Oct 27 '23 12:10 guille2718

Yeah, looks like #2737 fixed this.

geoffromer avatar Oct 27 '23 23:10 geoffromer