[dev] [sbase] expr segmentation fault

From: ruivlea <ruivlea_AT_protonmail.com>
Date: Mon, 22 Jan 2024 20:11:42 +0000

Hello,

After sbase commits:
- 270ca025ce236885e3177cd7acfd2cfbdf6e36a5
  expr: don't evaluate matched substr as a number
- e50d533d598dbe284e225e2ee52ed5f76a6e6f6a
  expr: treat expressions as strs until evaluation

I fail to build linux using sbase
due to expr segmentation fault:

Linux Makefile line 1301 and 1304:
if [ $(SUBLEVEL) -gt 255 ]; then \
        echo \#define LINUX_VERSION_CODE $(shell \
        expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \
else \
        echo \#define LINUX_VERSION_CODE $(shell \
        expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
fi; \

Then i change those lines without expr:
if [ $(SUBLEVEL) -gt 255 ]; then \
        echo \#define LINUX_VERSION_CODE \
        $$(($(VERSION) * 65536 + $(PATCHLEVEL) * 256 + 255)); \
else \
        echo \#define LINUX_VERSION_CODE \
        $$(($(VERSION) * 65536 + $(PATCHLEVEL) * 256 + $(SUBLEVEL))); \
fi;

With that changes, linux successfully built.

expr segfault when doing this kind of operation:
expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL))

Current expr can't do more than 1 operation.
Little test:
- With current sbase:
expr 2 \* 3 + 1
Segmentation fault

- With sbase before those commits:
expr 2 \* 3 + 1
7

- With current sbase:
expr 2 \* 3
6

- With sbase before those commits:
expr 2 \* 3
6
Received on Mon Jan 22 2024 - 21:11:42 CET

This archive was generated by hypermail 2.3.0 : Mon Jan 22 2024 - 21:24:08 CET