[prev in list] [next in list] [prev in thread] [next in thread] 

List:       aspell-user
Subject:    [pspell-user] pspell-ispell bug: example-c.c
From:       Melvin Hadasht <melvin.hadasht () free ! fr>
Date:       2001-11-29 6:48:05
Message-ID: 20011129154411.568f51b0.melvin.hadasht () free ! fr
[Download RAW message or body]

[this mail was also sent few days ago to pspell-devel, but I think it was not
the right ML. Sorry for that]

Hi,

I think I stumbled on a bug in pspell-ispell. When using pspell
library with the pspell-ispell module (i.e. selecting a
dictionary that is only available as an ispell dictionary), I
get segfault in my mailer (sylpheed-claws). I tested it with 2
differents ispell dictionaries (en & de). If I use instead an
aspell dictionary, then it does not segfault. It is triggered
when finishing composing i.e. after calling
delete_pspell_manager *but* it seems not to happen within the
pspell code. Under gdb I can't trigger the bug, but if I use
the dumped core, gdb says it happens just on the function call
following the delete_pspell_manager.

So I tried the example-c.c found in the pspell source to test
if the problem is from the (my) mailer implementation of the
spell checker of if it is indeed a pspell-ispell bug :

I used the latest pspell (.12.2) and pspell-ispell (.12) with
gcc-2.95.2 on linux 2.4.13, libtool 1.4

1. Testing pspell-.12.2/example/example-c.c :
compiling it and using it with an ispell dictionary is OK. I
made sure I haven't an aspell version of the used dictionary
(language)

2. I modified the example so it will iterate (I join a patch on
this mail (example-c-loop.c)) : I just put 'main' in a function
'mmain' and looping on it : 

int main (...) {

 while (1) {
	printf ("%d\n",mmain (...)) // <- mmain is the old main       
                            // function from the example       
getchar();  }
}


When I run it with an ispell dictionary I get a segmentation
fault after the call to mmain. Running the example with an
aspell dictionary does not segfault. Running within gdb and
with ispell it segfaults in an input/output C-function (IIRC
__getc__). But stepping through the program does not trigger
the segfault. I can send the backtrace, but as I think it is
something to do with module dynamic loading / unloading, the
backtrace won't help.

Now the funny thing : if I comment out the 'getchar', then the
loop runs almost ok without segfault. The first iteration is
ok,  *but* then on the next I get a negative (-1) exit values
from mmain with an error 'Select on Ispell process returned an
error.'. The next loop can have the same error or it can run
ok.

I don't know if this sounds clear, sorry, english is not my
first language.

But try the example-c-loop.c (patch joined in this mail, apply
in pspell-.12.2/example/ with : patch -p0 <
example-c-loop.c.patch), and you will see.

What suggests me it's a pspell-ispell error is that everything
goes ok if I use a dictionary that is available in the aspell
format but if I use an ispell dictionary the problems rise.

Can someone please help me shedding the light on this ? I can't
figure out where the problem is. 

(aspell is slower than ispell and some users with old boxes
want to use ispell with the mailer, and as I am the author of
the spell checker code in this mailer...)

Feel free to ask more details.


-- 
Melvin Hadasht




["example-c-loop.c.patch" (text/plain)]

*** example-c.c	Sat Nov 25 21:49:18 2000
--- example-c-loop.c	Tue Nov 27 01:39:41 2001
***************
*** 2,8 ****
  #include <stdio.h>
  #include <string.h>
  #include <pspell/pspell.h>
- 
  static void print_word_list(PspellManager * manager, 
  			    const PspellWordList *wl) 
  {
--- 2,7 ----
***************
*** 24,31 ****
    }
  }
  
  int main(int argc, const char *argv[]) {
! 
    PspellCanHaveError * ret;
    PspellManager * manager;
    int have;
--- 23,36 ----
    }
  }
  
+ int mmain (int argc, const char *argv[]); 
  int main(int argc, const char *argv[]) {
!     while (1) {
! 	printf ("%d\n",mmain (argc, argv));
! 	getchar();
!     }
! }
! int mmain (int argc, const char *argv[]) {
    PspellCanHaveError * ret;
    PspellManager * manager;
    int have;
***************
*** 44,49 ****
--- 49,55 ----
  
    if (argc >= 3 && argv[2][0] != '-')
      pspell_config_replace(config, "spelling", argv[2]);
+   
  
    if (argc >= 4 && argv[3][0] != '-')
      pspell_config_replace(config, "jargon", argv[3]);
***************
*** 62,76 ****
    manager = to_pspell_manager(ret);
    config = pspell_manager_config(manager);
  
!   fputs("Using: ",                                      stdout);
!   fputs(pspell_config_retrieve(config, "language-tag"), stdout);
!   fputs("-",                                            stdout);
!   fputs(pspell_config_retrieve(config, "spelling"),     stdout);
!   fputs("-",                                            stdout);
!   fputs(pspell_config_retrieve(config, "jargon"),       stdout);
!   fputs("-",                                            stdout);
!   fputs(pspell_config_retrieve(config, "module"),       stdout);
!   fputs("\n\n",                                         stdout);
     
    puts("Type \"h\" for help.\n");
  
--- 68,82 ----
    manager = to_pspell_manager(ret);
    config = pspell_manager_config(manager);
  
!   puts("Using: ");
!   puts(pspell_config_retrieve(config, "language-tag"));
!   puts("-");
!   puts(pspell_config_retrieve(config, "spelling"));
!   puts("-");
!   puts(pspell_config_retrieve(config, "jargon"));
!   puts("-");
!   puts(pspell_config_retrieve(config, "module"));
!   puts("\n\n");
     
    puts("Type \"h\" for help.\n");
  


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic