屏幕截图_20221229_162814

Comment From: sundb

Please use English to describe your issue and provide the OS you are using.

Comment From: CJM88888

When I build redis with version 7.0.7, an error occurs in networking.o,My OS is liux armv7l.

Comment From: sundb

@CJM88888 Thx, Can you also give the output of uname -a and gcc -v.

Comment From: CJM88888

thx,

Comment From: CJM88888

B308651C-CD14-40BC-8347-B1F27467C78D

Comment From: sundb

@CJM88888 Could you add #include <limits.h> at the top of networking.c. It seems that the IOV_MAX define on openwrk is not in sys/uio.h.

Comment From: CJM88888

@sundb Thank you, I tried your method, but still reported the error again 屏幕截图_20221230_143520

Comment From: sundb

@CJM88888 How did you get your compilation environment? Because I tested it in the openwrk VM and OK, maybe you can help me so I can test it locally.

Comment From: CJM88888

@sundb My compilation environment is based on gcc and tcl in entware

Comment From: CJM88888

@sundb Thank you for your help, here is my whole process of compiling. 屏幕截图_20221230_154457 屏幕截图_20221230_154520

Comment From: sundb

@CJM88888 Please use the following two pathes to see if work.

diff --git a/deps/hiredis/sds.c b/deps/hiredis/sds.c
index 114fa49a..b82e5a3a 100644
--- a/deps/hiredis/sds.c
+++ b/deps/hiredis/sds.c
@@ -723,6 +723,9 @@ hisds hi_sdstrim(hisds s, const char *cset) {
  * s = hi_sdsnew("Hello World");
  * hi_sdsrange(s,1,-1); => "ello World"
  */
+#ifndef SSIZE_MAX
+#  define SSIZE_MAX    ((ssize_t)(SIZE_MAX >> 1))
+#endif
 int hi_sdsrange(hisds s, ssize_t start, ssize_t end) {
     size_t newlen, len = hi_sdslen(s);
     if (len > SSIZE_MAX) return -1;
diff --git a/src/networking.c b/src/networking.c
index 054bca6a..297d7a74 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -1777,7 +1777,7 @@ client *lookupClientByID(uint64_t id) {
  * and 'nwritten' is an output parameter, it means how many bytes server write
  * to client. */
 static int _writevToClient(client *c, ssize_t *nwritten) {
-    struct iovec iov[IOV_MAX];
+    struct iovec iov[sysconf(_SC_IOV_MAX)];
     int iovcnt = 0;
     size_t iov_bytes_len = 0;
     /* If the static reply buffer is not empty,

Comment From: CJM88888

@sundb sorry i'm executing that code maybe i need to add parameters but i don't know where the parameters should be added.

Comment From: CJM88888

A32B33C8-3472-4664-AE1B-55D739AE26BA

Comment From: sundb

1) Add following code before hi_sdsrange in deps/hiredis/sds.c.

#ifndef SSIZE_MAX
#  define SSIZE_MAX    ((ssize_t)(SIZE_MAX >> 1))
#endif

2) Change struct iovec iov[IOV_MAX]; to struct iovec iov[sysconf(_SC_IOV_MAX)];

Comment From: CJM88888

@sundb Sorry, I really don't know how to modify it, can you modify the code for me? Then I'll copy it. sds.c.txt

Comment From: sundb

fix.zip Cover deps/hiredis/sds.c with sds.c and cover src/networking.c with networking.c.

Comment From: CJM88888

@sundbThank you, I also reported an error after overwriting according to the method you gave, as shown in the figure. 屏幕截图_20221231_091300

Comment From: sundb

@CJM88888 I wonder why you have redis.h in network.c, after 3.0 redis.h had been renamed to server.h.

Comment From: CJM88888

@sundb Because after I replaced the file you gave, there were many errors reported, and when I replaced it, the system did not prompt me that I was replacing the file, and an error was reported, so I replaced it from the 3.0 package. I just found out now.

Comment From: CJM88888

8444A6C0-22FA-4023-9110-C614C800649D

Comment From: sundb

Can you just search networking.c and replace struct iovec iov[IOV_MAX]; with struct iovec iov[sysconf(_SC_IOV_MAX)];

Comment From: CJM88888

@sundb Happy New Year, after I tried your method, I generated a 1kb notworking.d file, but still reported an error. 屏幕截图_20230101_004036

Comment From: sundb

@CJM88888 Happy New Year, Could you email(sundbcn@gmail.com) me your sds.c and networking.c, I will fix them and get back to you.

Comment From: CJM88888

@sundb Thank you, the email has been sent.

Comment From: CJM88888

@sundb Big brother, the network was successfully resolved, but a config error was reported. 屏幕截图_20230101_212137

Comment From: CJM88888

@sundb Here is my config file fix_zip.zip

Comment From: sundb

config.c.zip Please try again with replacing config.c.

Comment From: CJM88888

Thank you, I tried to replace the config.c file and reported the following error. 屏幕截图_20230102_060052

Comment From: sundb

config.c.zip Please try this config.c

Comment From: CJM88888

@sundb Thank you, I tried the config.c file you gave me. The error is as follows. 屏幕截图_20230102_135936

Comment From: sundb

@CJM88888 so embarrassing, Could you send me a zip of your /usr/include directory to my email?

Comment From: CJM88888

@sundb Ok I have sent, please note the query.

Comment From: CJM88888

@sundb Blocked due to security reasons, can only be sent via github. include.zip

Comment From: sundb

@CJM88888 Could you also give the output of gcc -E -dM - </dev/null

Comment From: CJM88888

@sundb 屏幕截图_20230103_095028 屏幕截图_20230103_095044 屏幕截图_20230103_095103 屏幕截图_20230103_095125 屏幕截图_20230103_095140 屏幕截图_20230103_095153 屏幕截图_20230103_094621

Comment From: sundb

config.zip @CJM88888 Please try again.

Comment From: CJM88888

@sundb 屏幕截图_20230103_115500

Comment From: sundb

config.zip @CJM88888 One more try.

Comment From: CJM88888

@sundb Now report this error big brother [Makefile:403: redis-check-aof.o] error 屏幕截图_20230103_160507

Comment From: sundb

redis-check-aof.zip CJM88888 Yes, because I only fixed the config.c. But I didn't do it right, normally we need to #include <limits.h>, I changed it to #include <bits/posix1_lim.h>, I'm wondering why #include <bits/posix1_lim.h> in limits.h is not working.

Comment From: CJM88888

@sundb 屏幕截图_20230103_184029

Comment From: sundb

Because lack of /bin/install, perhaps you can ignore it first. Now you can run with ./src/redis-server

Comment From: CJM88888

@sundb thanks!

Comment From: sundb

@CJM88888 Although the compilation problem has been solved, I am using some hacks to solve it, I still wonder why can not find these definitions, maybe you can help us to find where the problem is.

Comment From: CJM88888

@sundb Ok, you say, I can help you find the problem.

Comment From: CJM88888

@sundb Brother, I have executed make install and then tried to open redis and an error occurred. 屏幕截图_20230103_223057

Comment From: sundb

@CJM88888 Because your environment cann't find libatomic, you can use ldd . /src/redis-server to see if there are any missing dependencies, and then manually install them.

Comment From: CJM88888

@sundb 屏幕截图_20230104_104527

Comment From: sundb

Sorry for my mistake, one more space. ldd ./src/redis-server

Comment From: CJM88888

@sundb Big brother, I seem to have found a few dependencies, is libatomic.so.1 missing => not found? 屏幕截图_20230104_111029

Comment From: sundb

@CJM88888 Yes, you need to fix this dependency manually.

Comment From: CJM88888

@sundb Thank you, sir. After I installed the dependencies, it has been running successfully. You can tell me how I can help you find undefined problems as you said later. 屏幕截图_20230104_112945

Comment From: sundb

@CJM88888 I don't have any idea yet, maybe I'll write some test code and then I'll need you to verify it for me.

Comment From: CJM88888

@sundb ok, send it to me after you write it.

Comment From: CJM88888

@sundb Big brother, when I tried to rewrite a new redis program, an error occurred, because I used it in mosdns and there was a cycle of saving, so I want to upgrade it.

Comment From: sundb

@CJM88888 I can't see the images you posted.

Comment From: CJM88888

@sundb 屏幕截图_20230301_110229 屏幕截图_20230301_110430

Comment From: sundb

@CJM88888 Does it back to the previous question? do you try https://github.com/redis/redis/issues/11663#issuecomment-1369489313?

Comment From: CJM88888

@sundb I also get the same error after trying to replace the file.

Comment From: CJM88888

@sundb

Comment From: CJM88888

@sundb 屏幕截图 2023-03-02 113720

Comment From: sundb

@CJM88888 You can add #include <bits/posix1_lim.h> to the top of networking.c

Comment From: CJM88888

@sundb I tried adding it, but the error still persists. 屏幕截图 2023-03-02 122737

Comment From: sundb

fmacros.zip Please overwrite this file and try again.

Comment From: CJM88888

Redis 使用make构建出现了报错 @sundb I get the same error after trying the file.

Comment From: sundb

@CJM88888 Please run the following code and give the output.

#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
#include <limits.h>

int main() {
    printf("__linux__: %d\n", __linux__);

#ifdef __USE_POSIX
    printf("SSIZE_MAX: %ld\n", SSIZE_MAX);
#else
    printf("__USE_POSIX undefined\n");
#endif

#ifdef __USE_XOPEN
    printf("IOV_MAX: %d\n", IOV_MAX);
#else
    printf("__USE_XOPEN undefined\n");
#endif

    return 1;
}

Comment From: CJM88888

@sund I ran the code, but this doesn't seem to get an answer. 屏幕截图 2023-03-03 191020

Comment From: sundb

test.zip command: gcc test.c -o test && ./test

Comment From: CJM88888

@sundb Hello, the result is as follows. 屏幕截图 2023-03-03 213217

Comment From: CJM88888

@sundb 屏幕截图 2023-03-03 213502

Comment From: sundb

@CJM88888 I guess that the system you use is not POSIX. I can fix the compile problem, but I'm not sure if there will be any side effects. Please use the follwoing fixes. fix.zip

Comment From: CJM88888

@sundb I tried the modified file you gave me and got the error output below. 屏幕截图 2023-03-07 164737

Comment From: sundb

fix.zip Please try this.

Comment From: CJM88888

@sundb Here's what I got after trying your config file. 屏幕截图 2023-03-09 135421

Comment From: sundb

redis-check-aof.zip Try this.

Comment From: CJM88888

@sundb Hi, I tried the new config file and got the build error as below. 屏幕截图 2023-03-09 150910

Comment From: sundb

Please see this comment https://github.com/redis/redis/issues/11663#issuecomment-1369631528

Comment From: CJM88888

@sundb Thank you for your help, I successfully used it.

Comment From: CJM88888

@sundb Hello. My warning log after starting redis, I tried this modification, but I can't find /etc/sysctl.conf, my redis service is not running normally. 屏幕截图 2023-03-13 200058

Comment From: sundb

@CJM88888 Have you try sysctl?

Comment From: CJM88888

@sundb hello, i didn't find sysctl

Comment From: sundb

@CJM88888 I'm not expect with the system you using and can't install it locallly, or you could find some documents about this. BTW, these warnings don't matter, so maybe you can ignore these.

Comment From: CJM88888

@sundb Thank you. I compiled and installed it locally. It may be a problem with the system version. I can use it normally now, but this kind of warning often appears in the log.