mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Arkadiusz Sienkiewicz <sienkiewiczarkadiusz@gmail.com>
To: dalias@libc.org
Cc: musl@lists.openwall.com
Subject: Re: aio_cancel segmentation fault for in progress write requests
Date: Fri, 7 Dec 2018 17:04:07 +0100	[thread overview]
Message-ID: <CAO=yjR1xdDHijaCAv0UpCKZCXBmyL_21SGBOQjQd+Z9dmjb2aw@mail.gmail.com> (raw)
In-Reply-To: <20181207154419.GD23599@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 3337 bytes --]

Ok, maybe stacktrace is misleading due to some problem in GDB. However,
that doesn't explain why I'm getting segmentation fault when I execute test
program without gdb. Also commenting aio_cancel line will "fix" seg fault,
so that function is most probable culprit.

pt., 7 gru 2018 o 16:44 Rich Felker <dalias@libc.org> napisał(a):

> On Fri, Dec 07, 2018 at 01:52:31PM +0100, Arkadiusz Sienkiewicz wrote:
> > 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.
>
> This is not correct:
>
> >
> > (gdb) r
> > Starting program: ~/aioWrite
> > [New LWP 70321]
> >
> > Program received signal ?, Unknown signal.
> > [Switching to LWP 70321]
>
> This just shows that the aio thread received the cancellation request.
> It's not a crash or a problem. However, gdb's reporting of it as
> "Unknown signal" and inability to pass it on correctly indicates that
> something is wrong with the gdb on your system. I've hit this issue a
> lot but it works on some systems and I don't recall what the
> cause/difference behind it is. We should work to figure that out and
> get an appropriate fix in distros that are affected.
>
>
> > #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;
> > }
>
> I just tried this test and it works for me on 32-bit x86. I'll try
> some other systems and see if I can reproduce the issue. It could be a
> bug in the test but I didn't see anything obviously wrong with it.
>
> Rich
>

[-- Attachment #2: Type: text/html, Size: 4280 bytes --]

  reply	other threads:[~2018-12-07 16:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-07 12:52 Arkadiusz Sienkiewicz
2018-12-07 15:44 ` Rich Felker
2018-12-07 16:04   ` Arkadiusz Sienkiewicz [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAO=yjR1xdDHijaCAv0UpCKZCXBmyL_21SGBOQjQd+Z9dmjb2aw@mail.gmail.com' \
    --to=sienkiewiczarkadiusz@gmail.com \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).