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

[BUG]Fails to compile on AIX 7.2 with gcc (10.3.0 to be precise) #326

Open
KavetiRohith opened this issue Nov 5, 2024 · 5 comments
Open

Comments

@KavetiRohith
Copy link

Describe the bug
Fails to compile on AIX 7.2 with GCC.
tried to build from master and 4.99.3 tag which is the latest
with the following errors:

To Reproduce
Steps to reproduce the behavior:

  1. Run ./Configure aixgcc with defaults and then make
  2. See error
[root@xyz]: make
        (cd lib; make DEBUG="" CFGF="-DHASIPv6 -DHASSTAT64 -DHAS_JFS2 -I/lsof/lib/dialects/aix/aix5 -fms-extensions -maix64 -DAIX_KERNBITS=64 -DAIXA=1 -DAIXV=7200 -DHAS_STRFTIME -DLSOF_VSTR=\"7.2.0.0\"")
        gcc  -DHASIPv6 -DHASSTAT64 -DHAS_JFS2 -I/lsof/lib/dialects/aix/aix5 -fms-extensions -maix64 -DAIX_KERNBITS=64 -DAIXA=1 -DAIXV=7200 -DHAS_STRFTIME -DLSOF_VSTR="7.2.0.0"  -I.. -I../include -Idialects/aix  -c ckkv.c
In file included from /usr/include/sys/ptrace.h:28,
                 from /usr/include/sys/proc.h:43,
                 from /usr/include/sys/aacct.h:22,
                 from /usr/include/sys/vfs.h:33,
                 from /usr/include/sys/vnode.h:51,
                 from ../dlsof.h:65,
                 from common.h:253,
                 from ckkv.c:31:
/usr/include/sys/thread.h:1039:2: error: unknown type name 'ptr32'
 1039 |  ptr32  errnop_addr;
      |  ^~~~~
/usr/include/sys/thread.h:1050:2: error: unknown type name 'ptr64'
 1050 |  ptr64  thread_control_p;
      |  ^~~~~
/usr/include/sys/thread.h:1051:2: error: unknown type name 'ptr32'
 1051 |  ptr32  prbase;
      |  ^~~~~
/usr/include/sys/thread.h:1052:2: error: unknown type name 'ptr32'
 1052 |  ptr32  credp;
      |  ^~~~~
In file included from ../dlsof.h:65,
                 from common.h:253,
                 from ckkv.c:31:
/usr/include/sys/vnode.h:921:9: error: unknown type name 'ptr64'
  921 |         ptr64 buf;          /* output buffer for attachment info  */
      |         ^~~~~
In file included from /usr/include/procinfo.h:44,
                 from ../dlsof.h:67,
                 from common.h:253,
                 from ckkv.c:31:
/usr/include/sys/user.h:673:2: error: unknown type name 'ptr64'
  673 |  ptr64 addr[16];
      |  ^~~~~
/usr/include/sys/user.h:703:2: error: unknown type name 'ptr64'
  703 |  ptr64    U_signal[NSIG64+NISIG]; /* pointers to signal handlers*/
      |  ^~~~~
make: The error code from the last command is 1.


Stop.
make: The error code from the last command is 2.


Stop.

Expected behavior
Successful Compilation...

Environment (please complete the following information):

  • OS: [AIX 7.2]
  • lsof Version: [e.g. both 4.99.3 and master]
  • Origin: [git]

Additional context
I was eventually able to get it to compile with this patch and removing -DHAS_STRFTIME from the Makefile

diff --git a/lib/common.h b/lib/common.h
index 6014510..d6dbf50 100644
--- a/lib/common.h
+++ b/lib/common.h
@@ -1488,8 +1488,10 @@ struct lsof_context {
 #    define DCstate (ctx->dev_cache_state)
 #    define DCunsafe (ctx->dev_cache_unsafe)
 /* name list */
+#    if defined(HASNLIST)
 #    define Nl (ctx->name_list)
 #    define Nll (ctx->name_list_size)
+#    endif
 #    define Nmlst (ctx->name_list_path)
 #    define Memory (ctx->core_file_path)
 /* procfs */
diff --git a/lib/dialects/aix/dlsof.h b/lib/dialects/aix/dlsof.h
index b7a5aff..1bfd27a 100644
--- a/lib/dialects/aix/dlsof.h
+++ b/lib/dialects/aix/dlsof.h
@@ -62,6 +62,15 @@
 #        define _KERNEL 1
 #    endif /* !defined(_KERNEL) */

+
+#ifndef ptr32
+typedef void *ptr32;
+#endif
+
+#ifndef ptr64
+typedef void *ptr64;
+#endif
+
 #    include <sys/vnode.h>
 #    include <sys/file.h>
 #    include <procinfo.h> /* <procinfo.h> #includes <sys/user.h> */
diff --git a/lib/dialects/aix/dproto.h b/lib/dialects/aix/dproto.h
index 70b1568..fcb7332 100644
--- a/lib/dialects/aix/dproto.h
+++ b/lib/dialects/aix/dproto.h
@@ -50,7 +50,6 @@ extern int readj2lino(struct lsof_context *ctx, struct gnode *ga, struct l_ino *

 extern int getchan(char *p);
 extern int is_file_named(struct lsof_context *ctx, char *p, enum vtype ty, chan_t ch, int ic);
-extern char isglocked(struct lsof_context *ctx, struct gnode *ga);
 extern int readlino(struct lsof_context *ctx, struct gnode *ga, struct l_ino *li);
 extern struct l_vfs *readvfs(struct lsof_context *ctx, struct vnode *vn);

however, some functionality is broken I see - "vnode at X has no gnode\n" while I don't see any of these issues when I compile from 6ca5d32. I want to use the recent release as I would like to use some of the new library functionality in another project.

[root@xyz]: sudo ./lsof
COMMAND        PID   USER  FD   TYPE             DEVICE           SIZE/OFF   NODE NAME
                 0   root cwd   0000                                              vnode at 0xf1000c03f0420420 has no gnode\n
init             1   root cwd   0000                                              vnode at 0xf1000c03f0420420 has no gnode\n
init             1   root   0u  0000                               0t25272        vnode at 0xf1000c03f04a8420 has no gnode\n
shlap64    1311356   root cwd   0000                                              vnode at 0xf1000c03f0420420 has no gnode\n
syncd      1835712   root cwd   0000                                              vnode at 0xf1000c03f0420420 has no gnode\n
syncd      1835712   root   0r  0000                                   0t0        vnode at 0xf1000c01c02a1250 has no gnode\n
syncd      1835712   root   1w  0000                                   0t0        vnode at 0xf1000c01c02a1250 has no gnode\n
syncd      1835712   root   2w  0000                                   0t0        vnode at 0xf1000c01c02a1250 has no gnode\n
biod       2228724   root cwd   0000                                              vnode at 0xf1000c03f0420420 has no gnode\n
biod       2228724   root   0r  0000                                   0t0        vnode at 0xf1000c01c02a1250 has no gnode\n
biod       2228724   root   1w  0000                                   0t0        vnode at 0xf1000c01c02a1190 has no gnode\n
biod       2228724   root   2w  0000                                   0t0        vnode at 0xf1000c01c02a1190 has no gnode\n
errdemon   2294420   root cwd   0000                                              vnode at 0xf1000c03f06d1c20 has no gnode\n
errdemon   2294420   root   0u  0000                                   0t0        vnode at 0xf1000c01c02a1250 has no gnode\n
errdemon   2294420   root   1u  0000                                   0t0        vnode at 0xf1000c01c02a1250 has no gnode\n
errdemon   2294420   root   2u  0000                                   0t0        vnode at 0xf1000c01c02a1250 has no gnode\n
errdemon   2294420   root   3r  0000                                   0t0        vnode at 0xf1000c01c02a11f0 has no gnode\n
errdemon   2294420   root   4r  0000                              0t587504        vnode at 0xf1000c01c02a1010 has no gnode\n
errdemon   2294420   root   5u  0000                                  0t32        vnode at 0xf1000c03f0817420 has no gnode\n
errdemon   2294420   root   6r  0000                                   0t0        vnode at 0xf1000c03f0857420 has no gnode\n
errdemon   2294420   root   7u  0000                                  0t32        vnode at 0xf1000c03f0817420 has no gnode\n
srcmstr    2360014   root cwd   0000                                              vnode at 0xf1000c03f0420420 has no gnode\n
srcmstr    2360014   root   0r  0000                                   0t0        vnode at 0xf1000c01c02a1250 has no gnode\n
srcmstr    2360014   root   1w  0000                                   0t0        vnode at 0xf1000c01c02a1250 has no gnode\n
srcmstr    2360014   root   2w  0000                                   0t0        vnode at 0xf1000c01c02a1250 has no gnode\n

Any help is appreciated.

Thank You.

@jiegec
Copy link
Contributor

jiegec commented Nov 5, 2024

I don't have AIX (virtual) machines now, but the patch looks good to me. For the vnode at X has no gnode error, does it appear on earlier version of lsof?

@KavetiRohith
Copy link
Author

It doesn't appear on earlier versions

@jiegec
Copy link
Contributor

jiegec commented Nov 5, 2024

It doesn't appear on earlier versions

If you have time, could you do a git bisect? It may be a regression somewhere introduced by refactoring.

@KavetiRohith
Copy link
Author

I did git bisect The build issues started at commit cab786c - Library part5

@jiegec
Copy link
Contributor

jiegec commented Nov 6, 2024

I did git bisect The build issues started at commit cab786c - Library part5

Thank you! But I am unable to find the culprit. The commit does not touch the code generating the vnode at %s has no gnode error.

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

2 participants