mailing list of musl libc
 help / color / mirror / code / Atom feed
* aio_cancel segmentation fault for in progress write requests
@ 2018-12-07 12:52 Arkadiusz Sienkiewicz
  2018-12-07 15:44 ` Rich Felker
  0 siblings, 1 reply; 22+ messages in thread
From: Arkadiusz Sienkiewicz @ 2018-12-07 12:52 UTC (permalink / raw)
  To: musl


[-- Attachment #1.1: Type: text/plain, Size: 3306 bytes --]

Hi,

I'm experiencing segmentation fault when I invoke aio_cancel on request
which is in EINPROGRESS state. This happens only with libc muls (used
version - 1.1.12-r8) and only on one (dual Intel Xeon Gold 6128) of few
computers I've tried it on - please let me know if you need more
information about that machine. Attached is very simple program
(aioWrite.cpp) that reproduces this problem.

alpine-tmp-0:~$ ./aioWrite
Segmentation fault (core dumped)

Bt from gdb shows problem is in aio_cancel.

(gdb) r
Starting program: ~/aioWrite
[New LWP 70321]

Program received signal ?, Unknown signal.
[Switching to LWP 70321]
__cp_end () at src/thread/x86_64/syscall_cp.s:29
29    src/thread/x86_64/syscall_cp.s: No such file or directory.
(gdb) bt
#0  __cp_end () at src/thread/x86_64/syscall_cp.s:29
#1  0x00007ffff7dc6919 in __syscall_cp_c (nr=18, u=<optimized out>,
v=<optimized out>, w=<optimized out>, x=<optimized out>, y=<optimized out>,
z=0) at src/thread/pthread_cancel.c:37
#2  0x00007ffff7dcc0df in pwrite (fd=fd@entry=3, buf=buf@entry=0x7ffffff81900,
size=size@entry=512512, ofs=ofs@entry=0) at src/unistd/pwrite.c:7
#3  0x00007ffff7d8974e in io_thread_func (ctx=<optimized out>) at
src/aio/aio.c:240
#4  0x00007ffff7dc7293 in start (p=0x7ffff7ff4ab0) at
src/thread/pthread_create.c:145
#5  0x00007ffff7dc6072 in __clone () at src/thread/x86_64/clone.s:21
Backtrace stopped: frame did not save the PC
(gdb) info threads
  Id   Target Id         Frame
* 2    LWP 70321 "aioWrite" __cp_end () at src/thread/x86_64/syscall_cp.s:29
  1    LWP 70317 "aioWrite" __wait (addr=addr@entry=0x7ffff7ff49f8,
waiters=waiters@entry=0x0, val=val@entry=-1, priv=<optimized out>,
priv@entry=1) at src/thread/__wait.c:14
(gdb) thread 1
[Switching to thread 1 (LWP 70317)]
#0  __wait (addr=addr@entry=0x7ffff7ff49f8, waiters=waiters@entry=0x0,
val=val@entry=-1, priv=<optimized out>, priv@entry=1) at
src/thread/__wait.c:14
14    src/thread/__wait.c: No such file or directory.
(gdb) bt
#0  __wait (addr=addr@entry=0x7ffff7ff49f8, waiters=waiters@entry=0x0,
val=val@entry=-1, priv=<optimized out>, priv@entry=1) at
src/thread/__wait.c:14
#1  0x00007ffff7d89b30 in aio_cancel (fd=<optimized out>,
cb=0x7ffffff04640) at src/aio/aio.c:356
#2  0x0000000000400c54 in main () at aioWrite.cpp:45
(gdb)

In other application (which code I cannot share) I was able to get more
detailed trace for main thread, narrowing problem to pthread_kill call.

Program received signal ?, Unknown signal.
[Switching to LWP 70293]
__cp_end () at src/thread/x86_64/syscall_cp.s:29
29    src/thread/x86_64/syscall_cp.s: No such file or directory.
(gdb) thread 1
[Switching to thread 1 (LWP 60762)]
#0  0x00007ffff7dc7ac4 in pthread_kill (t=t@entry=0x7ffff7fdeab0,
sig=sig@entry=33) at src/thread/pthread_kill.c:7
7    src/thread/pthread_kill.c: No such file or directory.
(gdb) bt
#0  0x00007ffff7dc7ac4 in pthread_kill (t=t@entry=0x7ffff7fdeab0,
sig=sig@entry=33) at src/thread/pthread_kill.c:7
#1  0x00007ffff7dc69eb in pthread_cancel (t=0x7ffff7fdeab0) at
src/thread/pthread_cancel.c:99
#2  0x00007ffff7d89b1d in aio_cancel (fd=<optimized out>, cb=0xf4e180) at
src/aio/aio.c:355

Operating system is containerized alpine linux:
Linux alpine-tmp-0 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC
2018 x86_64 Linux

Best Regards,

[-- Attachment #1.2: Type: text/html, Size: 3716 bytes --]

[-- Attachment #2: aioWrite.cpp --]
[-- Type: text/x-c++src, Size: 1193 bytes --]

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <aio.h>

#define TNAME "aio_write/1-1.c"

int main() {
  char tmpfname[256];
  #define BUF_SIZE 512512
  char buf[BUF_SIZE];
  char check[BUF_SIZE+1];
  int fd;
  struct aiocb aiocb;
  int err;
  int ret;

  snprintf(tmpfname, sizeof(tmpfname), "pts_aio_write_1_1_%d", getpid());
  unlink(tmpfname);
  fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR);
  if (fd == -1) {
    printf(TNAME " Error at open(): %s\n", strerror(errno));
    exit(1);
  }

  unlink(tmpfname);

  memset(buf, 0xaa, BUF_SIZE);
  memset(&aiocb, 0, sizeof(struct aiocb));
  aiocb.aio_fildes = fd;
  aiocb.aio_buf = buf;
  aiocb.aio_nbytes = BUF_SIZE;

  if (aio_write(&aiocb) == -1) {
    printf(TNAME " Error at aio_write(): %s\n", strerror(errno));
    close(fd);
    exit(2);
  }

  int cancellationStatus = aio_cancel(fd, &aiocb);
  printf (TNAME " cancelationStatus : %d\n", cancellationStatus);

  /* Wait until completion */
  while (aio_error (&aiocb) == EINPROGRESS);

  close(fd);
  printf ("Test PASSED\n");
  return 0;
}

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-12-17 17:29 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-07 12:52 aio_cancel segmentation fault for in progress write requests Arkadiusz Sienkiewicz
2018-12-07 15:44 ` Rich Felker
2018-12-07 16:04   ` Arkadiusz Sienkiewicz
2018-12-07 16:52     ` Orivej Desh
2018-12-07 16:52     ` Rich Felker
2018-12-07 17:31       ` A. Wilcox
2018-12-07 18:26         ` Rich Felker
2018-12-07 19:05           ` A. Wilcox
2018-12-07 20:07             ` Rich Felker
2018-12-07 19:13           ` A. Wilcox
2018-12-07 20:21             ` Rich Felker
2018-12-07 20:35             ` Markus Wichmann
2018-12-07 21:12               ` Rich Felker
2018-12-07 22:51               ` A. Wilcox
2018-12-07 23:50                 ` Rich Felker
2018-12-07 20:06           ` Florian Weimer
2018-12-07 20:14             ` Rich Felker
2018-12-08 16:18               ` Florian Weimer
2018-12-10  9:05                 ` Arkadiusz Sienkiewicz
2018-12-12  0:36                   ` Rich Felker
2018-12-17 14:21                     ` Arkadiusz Sienkiewicz
2018-12-17 17:29                       ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).