Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubsan: jerryscript/jerry-core/ecma/base/ecma-helpers-number.c:700:51: runtime error: left shift of negative value -8 #4702

Closed
Cancelll opened this issue Jun 30, 2021 · 0 comments

Comments

@Cancelll
Copy link

JerryScript revision

ccc1525

Build platform

Ubuntu 20.04.1 LTS (Linux 5.4.0-74-generic x86_64)

Build steps
readonly FLAGS=(
  "-g -O1 -fsanitize=address,undefined -fno-sanitize-recover=undefined,address"
)
cmake -D CMAKE_C_FLAGS="${FLAG}" -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX:PATH="${INSTALL_DIR}" "${SRC_FOLDER}"
make
make install
Test case
for (; j = 1; j *= -8) {}
Output
jerryscript/jerry-core/ecma/base/ecma-helpers-number.c:700:51: runtime error: left shift of negative value -8
Expected behavior

According to C99 standard (6.5.7/4):

The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with
zeros. If E1 has an unsigned type, the value of the result is E1 × 2 E2 , reduced modulo
one more than the maximum value representable in the result type. If E1 has a signed
type and nonnegative value, and E1 × 2 E2 is representable in the result type, then that is
the resulting value; otherwise, the behavior is undefined.

batizdaniel added a commit to batizdaniel/jerryscript that referenced this issue Dec 22, 2021
This patch fixes jerryscript-project#4703
This patch fixes jerryscript-project#4702

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu
batizdaniel added a commit to batizdaniel/jerryscript that referenced this issue Dec 22, 2021
This patch fixes jerryscript-project#4703
This patch fixes jerryscript-project#4702

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu
batizdaniel added a commit to batizdaniel/jerryscript that referenced this issue Dec 22, 2021
This patch fixes jerryscript-project#4703
This patch fixes jerryscript-project#4702

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant