From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: rafael@kernel.org, daniel.lezcano@linaro.org
Cc: rui.zhang@intel.com, lukasz.luba@arm.com,
jacob.jun.pan@linux.intel.com, jserv@ccns.ncku.edu.tw,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tmon: Fix undefined behavior in left shift
Date: Mon, 1 Sep 2025 23:00:40 +0800 [thread overview]
Message-ID: <aLW1GEpKXVLo1Oue@visitorckw-System-Product-Name> (raw)
In-Reply-To: <20250901144756.1179834-1-visitorckw@gmail.com>
On Mon, Sep 01, 2025 at 10:47:56PM +0800, Kuan-Wei Chiu wrote:
> Using 1 << j when j reaches 31 triggers undefined behavior because
> the constant 1 is of type int, and shifting it left by 31 exceeds
> the range of signed int. UBSAN reports:
>
> tmon.c:174:54: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
>
I forgot to mention in the commit message that the UBSAN report was
triggered when running sudo ./tmon -l. Let me know if you'd like me
to include that detail, and I can update and resend as v2.
Regards,
Kuan-Wei
next prev parent reply other threads:[~2025-09-01 15:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-01 14:47 [PATCH] tmon: Fix undefined behavior in left shift Kuan-Wei Chiu
2025-09-01 15:00 ` Kuan-Wei Chiu [this message]
2025-10-29 6:57 ` Kuan-Wei Chiu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aLW1GEpKXVLo1Oue@visitorckw-System-Product-Name \
--to=visitorckw@gmail.com \
--cc=daniel.lezcano@linaro.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jserv@ccns.ncku.edu.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox