Skip to contentSkip to conversation

package/qemu: fix crash with uClibc-ng

PATCH New unixmania at gmail.com 3 participants 5 messages Oct 19, 2019 – Oct 30, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/qemu: fix crash with uClibc-ng

From: Carlos Santos <[email protected]>

On uClibc-ng sysconf(_SC_LEVEL1_{I,D}CACHE_LINESIZE) returns -1, which is a valid result, meaning that the limit is indeterminate. Add a patch that handles this situation using fallback values instead of crashing due to an assertion failure.

Upstream status:
https://lists.nongnu.org/archive/html/qemu-devel/2019-10/msg04115.html

---
 ...fix-crash-when-compiling-with-uClibc.patch | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch
package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch new file +43 -0
new file mode 100644
index 0000000000..d1b9e35709
@@ -0,0 +1,43 @@
+From d82b8540ecaf3cb09a033e4971d8645d3343211e Mon Sep 17 00:00:00 2001
+From: Carlos Santos <[email protected]>
+Date: Wed, 16 Oct 2019 22:27:30 -0300
+Subject: [PATCH] util/cacheinfo: fix crash when compiling with uClibc
+
+uClibc defines _SC_LEVEL1_ICACHE_LINESIZE and _SC_LEVEL1_DCACHE_LINESIZE
+but the corresponding sysconf calls returns -1, which is a valid result,
+meaning that the limit is indeterminate.
+
+Handle this situation using the fallback values instead of crashing due
+to an assertion failure.
+
+Signed-off-by: Carlos Santos <[email protected]>
+---
+ util/cacheinfo.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/util/cacheinfo.c b/util/cacheinfo.c
+index ea6f3e99bf..d94dc6adc8 100644
+--- a/util/cacheinfo.c
++++ b/util/cacheinfo.c
+@@ -93,10 +93,16 @@ static void sys_cache_info(int *isize, int *dsize)
+ static void sys_cache_info(int *isize, int *dsize)
+ {
+ # ifdef _SC_LEVEL1_ICACHE_LINESIZE
+-    *isize = sysconf(_SC_LEVEL1_ICACHE_LINESIZE);
++    int tmp_isize = (int) sysconf(_SC_LEVEL1_ICACHE_LINESIZE);
++    if (tmp_isize > 0) {
++        *isize = tmp_isize;
++    }
+ # endif
+ # ifdef _SC_LEVEL1_DCACHE_LINESIZE
+-    *dsize = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
++    int tmp_dsize = (int) sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
++    if (tmp_dsize > 0) {
++        *dsize = tmp_dsize;
++    }
+ # endif
+ }
+ #endif /* sys_cache_info */
+-- 
+2.18.1
+
Signature · 1 line
2.18.1
#1 lore raw

PATCH 1/1 package/qemu: fix crash with uClibc-ng

Quoted 7 lines · On Fri, 18 Oct 2019 23:09:28 -0300 unixmania at gmail.com wrote:

From: Carlos Santos <[email protected]>

On uClibc-ng sysconf(_SC_LEVEL1_{I,D}CACHE_LINESIZE) returns -1, which is a valid result, meaning that the limit is indeterminate. Add a patch that handles this situation using fallback values instead of crashing due to an assertion failure.

Quoted 8 lines

Upstream status:

   https://lists.nongnu.org/archive/html/qemu-devel/2019-10/msg04115.html
---
 ...fix-crash-when-compiling-with-uClibc.patch | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 package/qemu: fix crash with uClibc-ng

Quoted 20 lines · Thomas Petazzoni
Quoted 7 lines · On Fri, 18 Oct 2019 23:09:28 -0300 unixmania at gmail.com wrote:

From: Carlos Santos <[email protected]>

On uClibc-ng sysconf(_SC_LEVEL1_{I,D}CACHE_LINESIZE) returns -1, which is a valid result, meaning that the limit is indeterminate. Add a patch that handles this situation using fallback values instead of crashing due to an assertion failure.

Quoted 8 lines

Upstream status:

   https://lists.nongnu.org/archive/html/qemu-devel/2019-10/msg04115.html
---
 ...fix-crash-when-compiling-with-uClibc.patch | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch
Quoted 7 lines

Applied to master, thanks.

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Still appears as "New" in patchwork: https://patchwork.ozlabs.org/patch/1179727/

Signature · 1 line
Carlos Santos <[email protected]>
#3 lore raw

PATCH 1/1 package/qemu: fix crash with uClibc-ng

Quoted 6 lines · On Mon, 21 Oct 2019 11:28:55 -0300 Carlos Santos <[email protected]> wrote:
Quoted 6 lines
Quoted 3 lines
 ...fix-crash-when-compiling-with-uClibc.patch | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 package/qemu/3.1.1/0003-util-cacheinfo-fix-crash-when-compiling-with-uClibc.patch  

Applied to master, thanks.

Quoted 7 lines
Quoted 5 lines

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Still appears as "New" in patchwork: https://patchwork.ozlabs.org/patch/1179727/

Thanks for reporting, I fixed the patch state. I guess I got distracted by some $reallife interruption :-)

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 1/1 package/qemu: fix crash with uClibc-ng

In reply to unixmania at gmail.com
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"unixmania" == unixmania <[email protected]> writes:

From: Carlos Santos <[email protected]>
On uClibc-ng sysconf(_SC_LEVEL1_{I,D}CACHE_LINESIZE) returns -1, which is a valid result, meaning that the limit is indeterminate. Add a patch that handles this situation using fallback values instead of crashing due to an assertion failure.

Quoted 4 lines

Upstream status:

   https://lists.nongnu.org/archive/html/qemu-devel/2019-10/msg04115.html

Committed to 2019.02.x and 2019.08.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard