Repository navigation
[BUG]Fails to compile on AIX 7.2 with gcc (10.3.0 to be precise) #326
Copy link
Copy link
Closed
Description
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:
- Run ./Configure aixgcc with defaults and then make
- 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
jiegec commentedon 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 gnodeerror, does it appear on earlier version of lsof?KavetiRohith commentedon Nov 5, 2024
It doesn't appear on earlier versions
jiegec commentedon Nov 5, 2024
If you have time, could you do a
git bisect? It may be a regression somewhere introduced by refactoring.KavetiRohith commentedon Nov 6, 2024
I did
git bisectThe build issues started at commit cab786c - Library part5jiegec commentedon Nov 6, 2024
Thank you! But I am unable to find the culprit. The commit does not touch the code generating the
vnode at %s has no gnodeerror.sjejurkar-uptycs commentedon Jul 16, 2025
@jiegec I am also facing the same issue with latest master. Do you have any updates on this?
jiegec commentedon Jul 16, 2025
Nope, I don't have AIX environment anymore. Help is appreciated. Can you try the patch on your machine?
uptycs-rmack commentedon Oct 23, 2025
I've opened PR #338 to get LSOF building and working on AIX 7.2 again.
uptycs-rmack commentedon Oct 23, 2025
In addition to the context library changes the include ordering needed to be adjusted to ensure the very first time sys/inttypes.h was included it was with _KERNEL and __KERNEL_64 defined. Without this fix ulong32int64_t was 8 bytes when it actually needs to be 4 bytes because the kernel structs still use 32 bit fields even on 64 bit kernels.
uptycs-rmack commentedon Oct 23, 2025
Looking at @KavetiRohith's bisect result, I suspect the issue originated because of the addition of #include <stdio.h> to lsof.h.