You are not logged in.
hi,
I'm writing a simple man2html CGI script :
#!/bin/bash
printf 'Content-type: text/html\n\n'
echo '<!doctype html>'
exec 2>&1
set -x
zcat /usr/share/man/man1/man.1.gz | groff -man -Thtml -
set +x
this script works well on Debian.
here's what I get on Archlinux:
+ zcat /usr/share/man/man1/man.1.gz
+ groff -man -Thtml - /srv/http/cgi-bin/test: line 7: 94180 Done zcat /usr/share/man/man1/man.1.gz 94181 Segmentation fault (core dumped) | groff -man -Thtml -
+ set +x
I have other CGI scripts that work as intended.
Last edited by N_BaH (2021-11-18 18:00:13)
Offline
So…? Maybe look at the coredump?
https://wiki.archlinux.org/title/Core_d … _core_dump
Offline
here's what I get from gdb backtrace
Reading symbols from /usr/bin/groff...
(No debugging symbols found in /usr/bin/groff)
[New LWP 143950]
Core was generated by `groff -man -Thtml'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f14035b34c7 in __strchr_sse2 () from /usr/lib/libc.so.6
(gdb) bt
#0 0x00007f14035b34c7 in __strchr_sse2 () from /usr/lib/libc.so.6
#1 0x00005642eaf6aa7a in ?? ()
#2 0x00005642eaf6ad0e in ?? ()
#3 0x00005642eaf6af35 in ?? ()
#4 0x00005642eaf621b1 in ?? ()
#5 0x00007f140353cb25 in __libc_start_main () from /usr/lib/libc.so.6
#6 0x00005642eaf6293e in ?? ()
(gdb)
but it doesn't tell me much.
do you need more?
btw, there's one big difference between Debian and Arch installations : the former uses apache2, the latter uses lighttpd.
Offline
It crashes in the sse2 implementation of strchr
Can you reproduce this interactively
zcat /usr/share/man/man1/man.1.gz | groff -man -Thtml -
zcat /usr/share/man/man1/man.1.gz > /tmp/man.1; groff -man -Thtml /tmp/man.1
And on a hunch
localectl
locale
locale -a
Offline
interactively, `zcat | groff' work fine, as using an intermediate file.
here's the result of additional commands :
$ localectl
System Locale: LANG=fr_FR.UTF-8
VC Keymap: fr-latin9
X11 Layout: n/a
$ locale
LANG=fr_FR.UTF-8
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=
$ locale -a
C
fr_FR.utf8
nl_NL.utf8
POSIX
$
Offline
Locale looks fine - does running your script interactively crash?
What if you don't redirect stderr into stdout?
Offline
in a terminal, the script works perfectly.
I redirected stderr because nothing appeared in browser.
if I don't, I have no man page, and no error message in browser.
Offline
Can you
zcat /usr/share/man/man3/strchr.3.gz | groff -man -Thtml - # shorter file …
zcat /usr/share/man/man3/strchr.3.gz | groff -man -Tascii - # … and less effort
Offline
they both cause segmentation fault.
Last edited by N_BaH (2021-11-10 17:01:31)
Offline
Do you use the cgi or the fastcgi module?
System is fully updated? No partital updates?
Offline
cgi module is cgi (no fastcgi).
system is fully updated; non partial update.
Last edited by N_BaH (2021-11-10 22:23:13)
Offline
I installed apache2 using simple cgi_mod on an lxc machine, and finally made the script work in the container.
so, the problem seems to come from lighttpd...
Offline
finally made the script work in the container
?
Is lighttpd also a container installation??
Because in that case it is *faaaaaar* more likely the container and the contained glibc…
Offline
no, lighttpd is on hardware.
Offline
as it seems to be a lighttpd issue, should I close this thread and open a new one under "Networking, Server and Protection" section?
Offline
It's not network related but programming & scripting is false as well, since it's not about your script either.
If you suffix the script .sh and assign that to /usr/bin/bash, does it still segfault?
https://wiki.archlinux.org/title/Lighttpd#CGI
Offline
assigning .sh to /usr/bin/bash doesn't change a thing : it still "segfaults".
here's /etc/lighttpd/lighttpd.conf :
# See /usr/share/doc/lighttpd
# and http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions
server.port = 80
server.username = "http"
server.groupname = "http"
server.document-root = "/srv/http"
server.errorlog = "/var/log/lighttpd/error.log"
dir-listing.activate = "enable"
index-file.names = ( "index.html", "cgi-bin/accueil" )
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".css" => "text/css",
".js" => "application/x-javascript",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".gif" => "image/gif",
".png" => "image/png",
"" => "application/octet-stream"
)
server.modules += ( "mod_userdir" )
userdir.path = "public_html"
server.modules += ( "mod_cgi" )
cgi.assign = (
".sh" => "/usr/bin/bash" #this doesn't change wrong behaviour
)
#$HTTP["url"] =~ "^(/~[^/]+)?/cgi-bin/" { #this is default config found on internet; it works with other CGI shell scripts.
# cgi.assign = ("" => "")
#}
# PDF view files instead of downloading
#https://azgtech.wordpress.com/2011/01/26/force-download-pdf-using-lighttpd/
#https://stackoverflow.com/questions/6293893/how-do-i-force-files-to-open-in-the-browser-instead-of-downloading-pdf
server.modules += ( "mod_setenv" )
$HTTP["url"] =~ "(.*)\.pdf" {
mimetype.assign = (".pdf" =>"application/pdf")
setenv.add-response-header = ( "Content-Disposition" => "inline" )
}
# Redirection
$HTTP["host"] == "machine_name" {
$HTTP["url"] =~ "^/$" {
url.redirect = ( "" => "/cgi-bin/home" )
url.rediect-code = 302
}
}
Last edited by N_BaH (2021-11-12 14:13:20)
Offline
silly me !
groff uses so many "sub programs", I remember that I tested PATH variable, though.
I probably didn't refresh browser's cache.
so, I set PATH to /usr/local/sbin:/usr/local/bin:/usr/bin, and I don't have segfault any more.
thnak you for your time, and sorry for such a simple error.
Offline