We are faced out with a situation when java application with profiling won't start with the error "predefined port <port> is already opened", but from OS point of view there are not any opened ports with <port> number (netstat, lsof etc). Error reproduced some time, and then suddenly leave off although we didn't change any parameters in configuration.
We were trying to see what happens in system calls. There is unsuccessful attempt:
Code: Select all
...
[pid 3461] shmget(0x42341491, 4, IPC_CREAT|0666) = 622595
[pid 3461] shmat(622595, 0, SHM_RND) = ?
[pid 3461] open("/proc/3274", O_RDONLY) = 7
[pid 3461] close(7) = 0
[pid 3461] shmget(0x4234148e, 524288, IPC_CREAT|0666) = 491524
[pid 3461] shmat(491524, 0, SHM_RND) = ?
[pid 3461] write(3, "11.0.10 - 1.375: shmem 4234148E: OK\n", 36) = 36
[pid 3461] write(3, "11.0.10 - 1.376: Cannot start: predefined port 40000 is already "..., 71) = 71
...
Code: Select all
...
[pid 3505] shmget(0x42341491, 4, IPC_CREAT|0666) = 622595
[pid 3505] shmat(622595, 0, SHM_RND) = ?
[pid 3505] open("/proc/3274", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 3505] shmget(0x4234148e, 524288, IPC_CREAT|0666) = 491524
[pid 3505] shmat(491524, 0, SHM_RND) = ?
[pid 3505] write(3, "11.0.10 - 1.264: shmem 4234148E: OK\n", 36) = 36
[pid 3505] lseek(5, 56138597, SEEK_SET) = 56138597
...
It seems like YJP is storing pair "<port> - <pid>" in shared memory and if directory /proc/<pid> exists -- generates the error message mentioned above.
Looks like there is a bug, if application with <pid> exists profiler won't start despite the fact that port is not used.
Please find "steps to reproduce" below:
1. Start any java application with profiling (-agentlib:yjpagent=port=<port>);
2. Find the <pid> of the application ;
3. Stop application;
4. Start any application with the same pid, for example you can use simple script:
Code: Select all
#!/bin/bash
[ x$1 = x ] && exit 254
new_p(){
[ $1 -eq $BASHPID ] && read -p "$BASHPID"
}
while true; do (new_p $1); done
Is that known issue? Do you have any plans to fix it?