After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 164262 - Crashes (segfault SIGSEGV in/usr/lib/libmozjs.so) on some javascript, Mozilla doesn't, PPC only?
Crashes (segfault SIGSEGV in/usr/lib/libmozjs.so) on some javascript, Mozilla...
Status: VERIFIED INCOMPLETE
Product: galeon
Classification: Deprecated
Component: general
1.3.18
Other Linux
: Normal normal
: ---
Assigned To: galeon-maint
galeon-maint
Depends on:
Blocks:
 
 
Reported: 2005-01-16 16:41 UTC by Loïc Minier
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GDB backtrace (17.48 KB, text/plain)
2005-01-18 19:02 UTC, Juergen Kreileder
  Details
JS Arena Fix (2.95 KB, patch)
2005-01-19 14:26 UTC, Juergen Kreileder
none Details | Review

Description Loïc Minier 2005-01-16 16:41:52 UTC
Hi,
Galeon crashes with some javascript, for examples on the links of the second
part of this site:
<http://secunia.com/multiple_browsers_window_injection_vulnerability_test/>

Sadly, I could not reproduce this behavior on i386, and the submitter of this
bug in the Debian BTS (this is <http://bugs.debian.org/285404>) claims this is
PPC specific.

I asked someone on IRC to reproduce on PPC, and he couldn't.

The submitter sent the following backtrace made with Debian package 1.3.18-2:
Program received signal SIGSEGV, Segmentation fault.

Thread 16384 (LWP 24311)

  • #0 js_ExecuteRegExp
    from /usr/lib/libmozjs.so
  • #1 js_BoyerMooreHorspool
    from /usr/lib/libmozjs.so
  • #2 js_BoyerMooreHorspool
    from /usr/lib/libmozjs.so
  • #23 js_BoyerMooreHorspool
    from /usr/lib/libmozjs.so
  • #24 js_BoyerMooreHorspool
    from /usr/lib/libmozjs.so
  5 Thread 98308 (LWP 24422)  0x0e3b0888 in nanosleep ()
   from /lib/libpthread.so.0
  4 Thread 32771 (LWP 24335)  0x0e3b0888 in nanosleep ()
   from /lib/libpthread.so.0
  3 Thread 16386 (LWP 24318)  0x0e0d1580 in poll () from /lib/libc.so.6
  2 Thread 32769 (LWP 24317)  0x0e0d1580 in poll () from /lib/libc.so.6
* 1 Thread 16384 (LWP 24311)  0x0ddae44c in js_ExecuteRegExp ()
   from /usr/lib/libmozjs.so

The submitter couldn't reproduce with mozilla-browser or epiphany-browser.

I wonder how it is possible that Galeon segfaults so deep in a libmozjs lib,
belonging to mozilla-browser, and not mozilla-browser.

May be you have an idea?

I fear to ask the submitter for a recompilation of the mozilla package with
debugging symbols, and I don't have a PPC with Debian right now, do you have
access to a Debian PPC box?

Thanks!

[Category: general, please change to "Mozilla interaction" if necessary]
Comment 1 Juergen Kreileder 2005-01-17 01:04:42 UTC
As noted in the original Debian bug report: The strange thing is, I only get the
crash if Galeon was started from GNOME's applications menu or a launcher on the
GNOME panel.  If Galeon gets started from a terminal everything works fine.
Comment 2 Crispin Flowerday (not receiving bugmail) 2005-01-17 22:35:59 UTC
Hmm, to be honest I've no idea with this, is possible, a debug backtrace is
needed, without it, I'm not entirely sure what we can do about this :-(
Comment 3 Loïc Minier 2005-01-18 07:51:37 UTC
Juergen, could you please run the following to get a debug version of galeon:
apt-get install build-essential devscripts
apt-get install build-dep galeon
mkdir tmp-galeon && cd tmp-tmp-galeon
apt-get source galeon
cd galeon-1.3.19
DEB_BUILD_OPTIONS="nostrip noopt" debuild

You should then get a "./debian/tmp/usr/bin/galeon" which has debug symbols,
could you then provide a backtrace with debugging symbols ("thread apply all bt
full").

Thanks!
Comment 4 Juergen Kreileder 2005-01-18 19:02:30 UTC
Created attachment 36202 [details]
GDB backtrace

The backtrace doesn't look that interesting.

Anyhow, using a debug build of mozilla shows an assertion failure (_q >= _p, at
jsregexp.c:2864) in JS_ARENA_ALLOCATE_CAST.  Closer inspection shows that _p +
_nb overflows (0xffffe184 + 8000 == 0xc4).  Somehow that only happens when
Galeon is started from the GNOME panel, otherwise the values are only close to
overflowing (0xfffffe44).
Comment 5 Juergen Kreileder 2005-01-18 20:33:49 UTC
The crash only happens with ppc64 kernels.  With ppc32 kernels it just goes from
7xxxxxxx to 8xxxxxxx (when using the default CONFIG_TASK_SIZE of 0x80000000).
Comment 6 Loïc Minier 2005-01-19 09:46:04 UTC
I tried talking through this on #debian-devel, and it seems:
- it could be the stack, thoughts:
  . vorlon already saw deep stack traces in galeon (70 / 80 calls)
  . might be limited somehow
  . strange that the BT says "corrupt stack?"
- it could be something else, it isn't explicitely segfaulting in the stack, and
we should find out what exactly segfaults

The two actions suggested are:
- try with higher ulimit, what does "ulimit" report?
- try with a ppc64 kernel with CONFIG_STACK_SIZE 0x80000000

Juergen, do you think you could try this?

Thanks!
Comment 7 Juergen Kreileder 2005-01-19 14:26:20 UTC
Created attachment 36241 [details] [review]
JS Arena Fix

> The two actions suggested are:
> - try with higher ulimit, what does "ulimit" report?

That won't help, the stack grows in the other direction.

> - try with a ppc64 kernel with CONFIG_STACK_SIZE 0x80000000

No, the TASK_SIZE (not STACK...) for 32-bit processes on ppc64 kernels is
hardcoded to 4G minus one page (compared to 2G on ppc32 kernels) and all apps
should work fine with that.  (BTW, this problem might be reproducible with
32-bit mozilla builds on x86_64 too.)

The real problem is broken pointer arithmetic in the jsarena code: It should
use "lowerbound > upperbound - size" instead of "lowerbound + size >
upper_bound".

I've attached a patch which fixes the problem for me.  The relevant parts are
the JS_ARENA_ALLOCATE_CAST and JS_ArenaAllocate changes.  I've also modified
JS_ARENA_GROW_CAST because it looked wrong too but that part wasn't needed to
get it working.  There might be more issues like that in the JS arena code, the
Mozilla guys probably should make a review.

So you can close this bug, it's a mozilla problem.  You might want to open a
bug at bugzilla.mozilla.org.  It would be nice if the patch got added to
Debian's mozilla before upstream gets around to fix it.
Comment 8 Loïc Minier 2005-01-19 14:40:44 UTC
Ok, thanks for your patch and time!
Comment 9 Loïc Minier 2005-01-19 15:06:13 UTC
There was a close-enough looking bug in the Mozilla BTS at:
https://bugzilla.mozilla.org/show_bug.cgi?id=270878

I've added your patch (with your name) in the report and linked to this bug and
the Debian bug.

(I'm closing this bug.)
Comment 10 Juergen Kreileder 2005-01-19 15:33:47 UTC
Hm, that's some other bug.  Stack direction is OK in my case.

Sorry if I caused some confusion with "the stack grows in the other direction."
What I meant was: Raising the maximum stack size limit won't help because it
enlarges the stack in the wrong direction (towards lower addresses).  The stack
still would start at the same address and there still wouldn't be more memory
for the pool (which would just hide the problem anyway).  The only effect is
that it would be possible to get more stack frames on the stack.  But it won't
have any effect on the overflow I see, the pool still would start on the same
address and the overflow still would happen at the same point.  It's really just
a case of bad pointer arithmetic.
Comment 11 Loïc Minier 2005-01-19 15:51:19 UTC
Ah sorry, I understood the underlying problem was pointer arithmetic, but I
thought that was related to the stack being too small in some way.

I'm sorry to ask to subscribe to another bugzilla again, but could you please
subscribe to the upstream Mozilla bug and explain this?  It would lessen the
chances of me getting in the way...  :-/