Bug #2169

mod_compress segfaults if there is no etag

Added by aalmenar almost 5 years ago. Updated over 4 years ago.

Status:FixedStart date:2010-03-08
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:mod_compress
Target version:1.4.27
Missing in 1.5.x:Yes

Description

Hi, i downloaded lighttpd 1.4.26 and put the following in my lighttpd.conf

static-file.etags = "disable"
etag.use-inode = "disable"
etag.use-mtime = "disable"
etag.use-size = "disable"

With this lighttpd on the first request segfaults, but if i only change etag.use-size to enable, or comment it out, lighttpd works flawlessly. This issue arised because i need to totally remove etags on all requests.

Associated revisions

Revision 2723
Added by stbuehler over 4 years ago

[mod_compress] Fix segfault when etags are disabled (fixes #2169)

History

#1 Updated by aalmenar almost 5 years ago

This feature is important if you have a load-balanced farm of lighttpd servers, serving the same files, on each request from each server, the Etags are different using the same file.

#2 Updated by stbuehler almost 5 years ago

  • Status changed from New to Need Feedback

I couldn't reproduce the segfault. Please provide a backtrace.

#3 Updated by aalmenar almost 5 years ago

I have used stable web servers packages from your PPA. Tested this on Ubuntu 9.10 and 8.04.

I get this on dmesg: lighttpd13635: segfault at 00000000 eip 08063bd2 esp bfb7b080 error 4

Also, i have all etags disabled and enable compress is when it getss broken, disabling compress.* options it does not segfault's.

compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ("text/plain", "text/html", "application/x-javascript", "application/javascript", "text/css", "text/xml", "application/xhtml+xml")
compress.max-filesize = 5120

#4 Updated by stbuehler almost 5 years ago

  • Subject changed from Disabling all etag features in lighttpd makes it segfault to mod_compress segfaults if there is no etag
  • Category set to mod_compress
  • Status changed from Need Feedback to Assigned
  • Target version changed from 1.4.x to 1.4.27
  • Missing in 1.5.x changed from No to Yes
  • This still wasn't a backtrace. Although i could now reproduce it myself, this is something important - you should learn how to produce one yourself, especially if you don't provide your complete config.
  • compress requires an etag to cache compressed files on disk, we won't change that
  • you really should keep mtime (last-modified header...) and size (obviously) synchronized, so there is no need to disable them for etag.

I think i will let mod_compress silently fail to cache the result on disk if you disabled etags.

#5 Updated by aalmenar almost 5 years ago

  • Target version changed from 1.4.27 to 1.4.x

Could explain a little bit over keeping mtime and size synchronized ?, all files are accesible over a NBD stored on one location, so mtime and size will be the same for every webserver...

#6 Updated by stbuehler almost 5 years ago

  • Target version changed from 1.4.x to 1.4.27

So if the etag is only computed from mtime and size it will be the same for all webservers, as long as the webservers are using the same algorithm.

Please don't change target version without good reasons.

#7 Updated by aalmenar almost 5 years ago

Now i understand. But some file get generated locally on each machine for faster local reading, so mtimes will not be the same on every machine, reading mod_compress.c, i don't understand why it has to use ETag and Last-Modified if it's configured to not use it ?, I use mod_expire to configure the expire time. Also Last-Modified should be allowed to be disabled.

#8 Updated by aalmenar almost 5 years ago

Also the failure is related due to an integer underflow:

(gdb) p
$4 = {ptr = 0x0, used = 0, size = 0}
(gdb) bt
#0  0x08063ce0 in etag_mutate (mut=0x80c6678, etag=0x812d0d0) at etag.c:43
#1  0x00705d28 in ?? () from /usr/lib/lighttpd/mod_compress.so
#2  0x080632f8 in plugins_call_handle_subrequest_start (srv=0x6, con=0x80c6330) at plugin.c:265
#3  0x08050b56 in http_response_prepare (srv=0x8074008, con=0x80c6330) at response.c:722
#4  0x08054572 in connection_state_machine (srv=0x8074008, con=0x80c6330) at connections.c:1435
#5  0x0805581c in network_server_handle_fdevent (s=0x8074008, context=0x80b5c70, revents=1) at network.c:52
#6  0x0804f87a in main (argc=4, argv=0xbffff7c4) at server.c:1446
(gdb) print etag
$5 = (buffer *) 0x812d0d0
(gdb) print *etag
$6 = {ptr = 0x0, used = 0, size = 0}
(gdb) print etag->used -1
$7 = 4294967295
(gdb) quit

#9 Updated by stbuehler almost 5 years ago

mod_compress needs a way to know if the cached file is still valid, and it is using etag for this. so no etag => no cache in mod_compress (you can still use mod_compress, but not with the cache).
And i don't recommend using the size alone for etag, as you perhaps sometimes change your files without changing the size.

good job on the backtrace; that is always a good start to fix problems with segfauls and aborts.

#10 Updated by aalmenar almost 5 years ago

I think cache can be used, but internally, on the server, ETag should not be transfered to the user accesing the page (Since i set the Expires to be "access plus 10 years" or something like that. But if i configure to remove Etags, i mean from the server response not if used for cache internally.

#11 Updated by stbuehler over 4 years ago

  • Status changed from Assigned to Fixed
  • % Done changed from 0 to 100

Applied in changeset r2723.

Also available in: Atom