Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000128 [libFirm] tarval minor always 2013-11-15 16:07 2016-01-03 03:28
Reporter zwinkau View Status public  
Assigned To
Priority low Resolution fixed  
Status closed   Product Version development
Summary 0000128: long overflow
Description Symptom: The "long l" variable in sc_val_to_long might shift-left-overflow, which is undefined behavior in C. Detected by clang -fsanitize=undefined.

Also, the tarval_is_long function seems to forget about the signed bit of long.

I pushed a branch, which make this problem obvious:
http://pp.info.uni-karlsruhe.de/git/libFirm/commit/?h=fix-signed-shift-overflow&id=685a5066804662ea70b9d65e824d7cce1324f2e4 [^]

Using get_tarval_long is probably a bad idea in most cases. For example, it changes between 32bit and 64bit architectures. Lots of code should better use get_tarval_uint64. Maybe we need a get_tarval_int64 as well?
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0000190)
zwinkau (manager)
2013-11-18 15:16

As of c70a5c32db6855fb750c708e4e35bf2b6d0f024f clang -fsanitize=undefined does not complain anymore for cparser+libfirm in our testsuite.

The tarval_is_long case is open, but the solution is unclear.
(0000191)
zwinkau (manager)
2013-11-21 10:01

tarval_is_long will not be fixed for now, since many code actually depends on the weird behavior.
(0000192)
zwinkau (manager)
2013-11-21 10:02

It is ugly but works

- Issue History
Date Modified Username Field Change
2013-11-15 16:07 zwinkau New Issue
2013-11-18 15:16 zwinkau Note Added: 0000190
2013-11-21 10:01 zwinkau Note Added: 0000191
2013-11-21 10:02 zwinkau Note Added: 0000192
2013-11-21 10:02 zwinkau Status new => closed
2013-11-21 10:02 zwinkau Resolution open => fixed
2013-11-21 10:02 zwinkau Fixed in Version => development
2014-01-30 19:24 Matze Status closed => resolved
2016-01-03 03:28 Matze Status resolved => closed


Mantis 1.1.5[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker