Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Spellcheck soundex infinite loop?

Quote Reply
Spellcheck soundex infinite loop?

First of all, I wanted to say how much we like Gossamer Forum, we've been using it for a good while now on our site and we really like it. : )

One little issue recently, I found that when I tried to "spell check" a message that started with "Ahh" (as in "Ahh, that makes sense") the browser wouldn't respond and the CPU usage for the perl process (on FreeBSD) would slowly climb up towards 100%.

Now, I don't know if this is just something with our install or what, but we had a quick look through the code and it seems things were getting caught up in /admin/GT/SpellCheck.pm around line 232 where it says:

# else we are in the good interval, we need to rewind till
# we are at the beginning of the interval. while (not $search_sound cmp $sound) {

sysseek $self->{SOUNDEX}, ($current * $record_size), 0;
sysread $self->{SOUNDEX}, $sound, 4;

It seems like the soundex value for our word was "A000" and that $current was going from 0 to 1 to -1 and lower forever (or at least until I killed the process).

Anyway, adding a line in the middle that says "if ($current < 0) { last; }" seemed to fix it, but I really don't know all that much about how all the spellcheck code works so I just wanted to make sure that wouldn't break anything else, or check if there was something else I should change. Any thoughts or comments on this issue?

Note: The only other non-standard thing about our setup is we recently upgraded from 1.1.4 to 1.1.8.
Quote Reply
Re: [dave-itools] Spellcheck soundex infinite loop? In reply to
Ahh , that is weird....

... but it doesn't happen on this installation.

Seriously, I have no idea but Jason might know.

Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [dave-itools] Spellcheck soundex infinite loop? In reply to

That's very strange! Can you do me a favour, and look in admin/GForum/SpellCheck.pm and look for:

my $mispeeled = $sp->check_words(\@check_words);

and above that put:

use Data::Dumper;
warn "Checking ", Dumper(\@check_words), "\n";

and let me know what it says. I just tried spellchecking 'Ahh' and it came up ok.


Gossamer Threads Inc.
Quote Reply
Re: [Alex] Spellcheck soundex infinite loop? In reply to
Well I had reduced my message down to just "Ahh" and found that was the cause of the error. So the code reports:

Checking $VAR1 = [ 'ahh' ];

I did a little more checking and it looks as though it might be trying to sysseek to a negative position and my version of perl doesn't like that (v5.6.1 built for i386-freebsd), although I'm not really sure. You could confirm that by print out the value of (current * record_size) in between these lines.

sysseek $self->{SOUNDEX}, ($current * $record_size), 0;

The same runs fine on my local machine, but not on my freebsd box.