Sunday, September 15, 2024

Re: w3m -dump_extra segfault

On Sun, Sep 15, 2024 at 07:31:50PM -0400, Jon Fineman wrote:
>
> Theo Buehler <tb@theobuehler.org> writes:
>
> > See https://marc.info/?l=openbsd-misc&m=172641752723332&w=2 for
> > background. In short: 'w3m -dump_extra https://lobste.rs' crashes and
> > that breaks this emacs plugin.
> >
> > The below reverts the code change from
> >
> > https://git.sr.ht/~rkta/w3m/commit/e933cf831f32fd4cf763c64aa60e51dbf025ec94
> >
> > and makes lobste.rs, duckduckgo and google work with M-x w3m-browse-url
> > in emacs. The problem is that the hack results in loadSomething() being
> > called with a NULL loadproc, which it doesn't know how to handle. No
> > idea how this was supposed to work...
> >
> > Thankfully the FreeBSD w3m maintainer posted a very detailed analysis to
> > https://todo.sr.ht/~rkta/w3m/59
> >
> > While the below diff makes the reported sites work, it may well break
> > other sites. So I'm unsure what the best course of action is. I can
> > commit this workaround, but maybe someone who is interested in using
> > w3m (from within emacs or not) could keep an eye on the issue and port
> > the proper fix (if upstream finds one).
> >
> > Index: Makefile
> > ===================================================================
> > RCS file: /cvs/ports/www/w3m/Makefile,v
> > diff -u -p -r1.105 Makefile
> > --- Makefile 18 Aug 2024 11:11:45 -0000 1.105
> > +++ Makefile 15 Sep 2024 19:58:31 -0000
> > @@ -4,6 +4,7 @@ C= 5ae3ef7cb20cd2209629ac0508c05206fd0d
> > DIST_TUPLE= srht rkta w3m $C .
> > WRKDIST= ${WRKDIR}/w3m-$C
> > DISTNAME= w3m-0.5.3pl20240810
> > +REVISION= 0
> >
> > CATEGORIES= www
> >
> > Index: patches/patch-file_c
> > ===================================================================
> > RCS file: patches/patch-file_c
> > diff -N patches/patch-file_c
> > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > +++ patches/patch-file_c 15 Sep 2024 19:59:09 -0000
> > @@ -0,0 +1,15 @@
> > +Revert e933cf831f32fd4cf763c64aa60e51dbf025ec94.
> > +See also https://todo.sr.ht/~rkta/w3m/59
> > +
> > +Index: file.c
> > +--- file.c.orig
> > ++++ file.c
> > +@@ -2263,8 +2263,6 @@ loadGeneralFile(char *path, ParsedURL *volatile curren
> > + }
> > + else if (w3m_dump & DUMP_FRAME)
> > + return NULL;
> > +- else
> > +- proc = NULL;
> > +
> > + if (t_buf == NULL)
> > + t_buf = newBuffer(INIT_BUFFER_WIDTH);
>
>
> Thanks for the research Theo.
>
> I deleted the ports w3m package added the patch and did a make install
> and verified the patched version of w3m was installed.

How did you verify this? Your pkg_info -Q output below suggests that
you have an unpatched w3m-image installed. Not sure how that happened
since you say you built it. Do you set FETCH_PACKAGES in /etc/mk.conf
by any chance?

I'd use

$ pkg_info | grep w3m
w3m-0.5.3pl20240810p0 pager/text-based web browser

The important bit being the p0.

To validate that you have a patched version try without emacs:

$ w3m -dump_extra https://lobste.rs >/dev/null

An unpatched w3m will show "Segmentation fault (core dumped)' and
a patched version should print nothing.

> However it still fails for me. One test session did get a little more
> output than before. I also tried non-image.
>
> Does it matter which emacs flavor of w3m you choose? I have mine set
> to:
> (setq mm-text-html-renderer 'gnus-w3m)

I had (require 'w3m-load) and tried with the gtk3 flavor of emacs.
Since it is a segfault in w3m, it should not matter what flavor you
use. (btw, the response you got on misc was on 7.5 with an older version
of w3m, which doesn't have this bug).

> pkg_info -Q w3m
> debug-w3m-0.5.3pl20240810
> debug-w3m-0.5.3pl20240810-image
> w3m-0.5.3pl20240810
> w3m-0.5.3pl20240810-image (installed)

This doesn't look right. The installed version should have a p0.
w3m-0.5.3pl20240810p0-image

> w3mir-1.0.10p0
>
>
> w3m --version
> w3m version w3m/0.5.3+git20230718, options lang=en,m17n,image,color,ansi-color,mouse,menu,cookie,ssl,ssl-verify,external-uri-loader,w3mmailer,nntp,gopher,ipv6,alarm,mark
>
>
> Location: https://lobste.rs/
> Cannot retrieve URL: https://lobste.rs
>
> /usr/local/bin/w3m exits with the code 11
>
> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
>
> Header information
>
> HTTP/1.1 200 OK
> Server: nginx
> Date: Sun, 15 Sep 2024 23:07:06 GMT
> Content-Type: text/html; charset=utf-8
> Content-Length: 0
> Connection: close
> x-frame-options: SAMEORIGIN
> x-xss-protection: 0
> x-content-type-options: nosniff
> x-permitted-cross-domain-policies: none
> referrer-policy: strict-origin-when-cross-origin
> link: ; rel=preload; as=style; nopush
> vary: Accept
> etag: W/"234ea776c1acda6bbc277c453ffefb7d"
> cache-control: max-age=0, private, must-revalidate
> feature-policy: accelerometer 'none'; autoplay 'none'; ambient-light-sensor 'none'; camera 'none'; encrypted-media 'none'; fullscreen 'none'; geolocation 'none'; gyroscope 'none'; idle_detection 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture 'none'; screen-wake-lock 'none'; serial 'none'; sync-xhr 'none'; usb 'none'; web-share 'none'
> set-cookie: lobster_trap=xT9flv0p8ggR%2Fvc00EZxwTqq9LszcpVVIl%2BPMqPOZbep59qHQvvCb2mbt%2FUXpxOAbpz1YwXeHZn5TzNU2%2BwyMEz4G7EQqS%2BHS4vtdB6g%2FymuLR%2F9e3iXDbyrxwB5MG%2Fzi9NyMJeYCXuw0gp0JKmr7lL%2FnjAHHN%2F9kx%2F1YEqUg2DWoa0dnWnTiIZmUPgkdTX3%2Bb36J9z7Ljs5y1yXAuNwXo3FvtdzZKmRjcIH75v0ZrWGs8BYdeOKFCLaOc4kZ3cozy%2FXJjQWMGxg77ZomCB6XnJZCgu6WppBdMnZ32S5nzmWOqhR0D21zaHV--Lhw5gpPflF6bcfQU--Wnwl9lwakIkks0AdnIdoiA%3D%3D; path=/; expires=Tue, 15 Oct 2024 23:07:06 GMT; secure; httponly; SameSite=Lax
> x-request-id: 8b15a5ea-0e4e-4738-8780-b414509f62d4
> strict-transport-security: max-age=63072000; includeSubDomains; preload
> Content-Security-Policy: frame-ancestors 'none'
> X-Robots-Tag: noai, noimageai
>

No comments:

Post a Comment