Bug 217789 - FreeBSD 11 panic nginx, probably sendfile problem
Summary: FreeBSD 11 panic nginx, probably sendfile problem
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.0-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Gleb Smirnoff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-14 18:27 UTC by freebsd
Modified: 2019-07-20 06:45 UTC (History)
2 users (show)

See Also:


Attachments
First time (12.31 KB, image/png)
2017-03-14 18:27 UTC, freebsd
no flags Details
Second time (21.99 KB, image/png)
2017-03-14 18:28 UTC, freebsd
no flags Details
Third time (12.31 KB, image/png)
2017-03-16 08:22 UTC, freebsd
no flags Details
proposed patch (560 bytes, patch)
2017-03-24 03:07 UTC, Gleb Smirnoff
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description freebsd 2017-03-14 18:27:43 UTC
Created attachment 180823 [details]
First time

Got FreeBSD 11 panic 2 times.

In both cases got same stack backtrace. See attachment.

+1 attachment in nginx's trac
https://trac.nginx.org/nginx/ticket/1217

FreeBSD XXX 11.0-RELEASE-p7 FreeBSD 11.0-RELEASE-p7 #0 r312555: Sat Jan 21 01:54:58 MSK 2017 root@YYYY:/usr/obj/usr/src/sys/IHEAD11 amd64
Comment 1 freebsd 2017-03-14 18:28:43 UTC
Created attachment 180824 [details]
Second time
Comment 2 Gleb Smirnoff freebsd_committer 2017-03-14 19:59:30 UTC
Hi!

Can you please update to stable/11. There was a bugfix to sendfile, and it might be related to your problem.

If problem reproduces on stable/11, I need you to obtain kernel core file.
Comment 3 freebsd 2017-03-14 20:02:30 UTC
(In reply to Gleb Smirnoff from comment #2)

Could you give patch against 11.0-RELEASE?
I will rebuild the kernel.
Comment 4 Gleb Smirnoff freebsd_committer 2017-03-14 20:13:56 UTC
https://svnweb.freebsd.org/base?view=revision&revision=306685

Should apply cleanly.
Comment 5 freebsd 2017-03-16 08:22:25 UTC
Problem repeated.
Comment 6 freebsd 2017-03-16 08:22:57 UTC
Created attachment 180862 [details]
Third time
Comment 7 freebsd 2017-03-16 10:30:26 UTC
(In reply to Gleb Smirnoff from comment #4)

Patch not helped.

It is production server, i can not expirement with kernel debugging.

I disabled sendfile in nginx and enable aio instead.
Comment 8 Gleb Smirnoff freebsd_committer 2017-03-16 19:34:18 UTC
If you don't want to obtain kernel core, then I can't help. Sorry.
Comment 9 Gleb Smirnoff freebsd_committer 2017-03-24 03:07:54 UTC
Created attachment 181119 [details]
proposed patch

Hi! Please try this patch.
Comment 10 commit-hook freebsd_committer 2017-03-24 16:02:04 UTC
A commit references this bug:

Author: glebius
Date: Fri Mar 24 16:01:20 UTC 2017
New revision: 315910
URL: https://svnweb.freebsd.org/changeset/base/315910

Log:
  Make sendfile(2) more robust against file change.  This fixes a possible
  crash when the file shrinks.  This also fixes sendfile(2) not sending more
  data in a case when the file grows, and the request is open-ended or
  specifies a size that is greater than old file size.

  PR:		217789
  Reviewed by:	gallatin
  MFC after:	10 days

Changes:
  head/sys/kern/kern_sendfile.c
Comment 11 freebsd 2017-03-29 11:02:31 UTC
(In reply to Gleb Smirnoff from comment #9)
It works. Four days, no panic.
Comment 12 commit-hook freebsd_committer 2017-04-03 00:46:41 UTC
A commit references this bug:

Author: glebius
Date: Mon Apr  3 00:46:32 UTC 2017
New revision: 316431
URL: https://svnweb.freebsd.org/changeset/base/316431

Log:
  Merge r315910:
    Make sendfile(2) more robust against file change.  This fixes a possible
    crash when the file shrinks.  This also fixes sendfile(2) not sending more
    data in a case when the file grows, and the request is open-ended or
    specifies a size that is greater than old file size.

    PR:           217789
    Reviewed by:  gallatin

Changes:
_U  stable/11/
  stable/11/sys/kern/kern_sendfile.c