unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
@ 2007-03-06  6:30 Hongyi Zhao
  2007-03-06  7:02 ` Kenichi Handa
  2007-03-06  8:06 ` Kenichi Handa
  0 siblings, 2 replies; 49+ messages in thread
From: Hongyi Zhao @ 2007-03-06  6:30 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: Emacs Devel

[-- Attachment #1: Type: text/plain, Size: 2250 bytes --]

Dear Handa San,

Now, I meet the same thing that I reported to you two days ago.  I debug 
it under gdb according to your guidance.  I describe the problem as 
follows and sent you a sample file as well as the corresponding debug 
informations:

-------------------------------------------------------
The description of my problem:

First, the build parameters of Emacs Unicode 2 is as follows:

===============
% cd EMACS_BUILD_TREE
% ./configure --prefix=/usr \
--x-includes=/usr/include/X11 --x-libraries=/usr/lib/X11 \
--enable-font-backend --enable-asserts \
--enable-locallisppath=/usr/share/emacs/site-lisp:/etc/emacs-snapshot/site-start.d 
\
--enable-largefile --with-pop --with-sound \
--with-x=yes --with-x-toolkit=gtk --with-toolkit-scroll-bars \
--with-xpm --with-jpeg --with-tiff --with-gif --with-png \
--with-freetype  --with-xft --with-xim \
--with-kerberos --with-kerberos5 --with-hesiod
% make bootstrap
===============

The following is my problem, may it be clear for you to understand:

In my sample file *sample-file.mp*, which is metapost file.  I open it·
in emacs by using the meta-mode to edit it.  The parameters I used to open 
Emacs is: *--enable-font-backend -fn "Dejavu Sans Mono-14"*.

When I open the file, then I use the *M-%* and *!* to replace all the 
*-* (the character is in Half shape) into *-* (the character is in Full 
shape) or vice versa and do this thing again and again.  I mean, if the 
there have *-* (half shape) in my file, I replace all of them into *-* 
(full shape) and then do the reverse replacements again and again; if 
there have *-* (full shape) in my file, I replace all of them into *-* 
(half shape) and then do the reverse replacements again and again.  Then 
I find that after some circles, the Emacs will be aborting 
abnormally.  The debug-results-gdb is my debug informations under 
gdb.
-----------------------------------------------------

P.S.  When I use the command *bt full*, I find so many debug 
informations, can I use a command to pipe these informations into a 
file.

Thanks in advance.
---
Hongyi Zhao (赵弘毅)
GnuPG DSA: 0xD108493B

老子道德经:第二十八章
知其白,守其黑,为天下式。
为天下式,常德不忒,复归于无极。

[-- Attachment #2: debug-info-of-emacs.tar.bz2 --]
[-- Type: application/octet-stream, Size: 5328 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-06  6:30 My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments Hongyi Zhao
@ 2007-03-06  7:02 ` Kenichi Handa
  2007-03-06  8:57   ` Hongyi Zhao
  2007-03-06  8:06 ` Kenichi Handa
  1 sibling, 1 reply; 49+ messages in thread
From: Kenichi Handa @ 2007-03-06  7:02 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: emacs-devel

In article <20070306063056.GA21948@debian-testing-hy.localdomain>, Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> Now, I meet the same thing that I reported to you two days ago.  I debug 
> it under gdb according to your guidance.  I describe the problem as 
> follows and sent you a sample file as well as the corresponding debug 
> informations:

Thank you for the info.

[...]
> In my sample file *sample-file.mp*, which is metapost file.  I open it·
> in emacs by using the meta-mode to edit it.  The parameters I used to open 
> Emacs is: *--enable-font-backend -fn "Dejavu Sans Mono-14"*.

> When I open the file, then I use the *M-%* and *!* to replace all the 
> *-* (the character is in Half shape) into *-* (the character is in Full 
> shape) or vice versa and do this thing again and again.  I mean, if the 
> there have *-* (half shape) in my file, I replace all of them into *-* 
> (full shape) and then do the reverse replacements again and again; if 
> there have *-* (full shape) in my file, I replace all of them into *-* 
> (half shape) and then do the reverse replacements again and again.  Then 
> I find that after some circles, the Emacs will be aborting 
> abnormally.  The debug-results-gdb is my debug informations under 
> gdb.

I did the same thing, but couldn't reproduce that bug.  I
also ran this function:
(defun temp ()
  (while t
    (goto-char 1)
    (replace-string "-" "\xFF0D")
    (sit-for 0.1)
    (goto-char 1)
    (replace-string "\xFF0D" "-")
    (sit-for 0.1)))
on sample-file.mp (by visitting it and typing ESC : (temp)
RET), but Emacs run's without error.

Could you please try the same thing by running Emacs without
"--enable-font-backend" arg?

> P.S.  When I use the command *bt full*, I find so many debug 
> informations, can I use a command to pipe these informations into a 
> file.

From Emacs, you can do this:

  M-x gdb RET .../src/emacs RET

Then the interation with gdb can be done in *gud-emacs*
buffer, thus you can easily save a proper part in a file.

---
Kenichi Handa
handa@m17n.org

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-06  6:30 My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments Hongyi Zhao
  2007-03-06  7:02 ` Kenichi Handa
@ 2007-03-06  8:06 ` Kenichi Handa
  2007-03-06  8:41   ` Hongyi Zhao
  2007-03-06 14:10   ` David Kastrup
  1 sibling, 2 replies; 49+ messages in thread
From: Kenichi Handa @ 2007-03-06  8:06 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: emacs-devel

By the way,

> abnormally.  The debug-results-gdb is my debug informations under 
> gdb.

It shows this info:

Breakpoint 1, abort () at emacs.c:431
431       kill (getpid (), SIGABRT);
(gdb) bt full
#0  abort () at emacs.c:431
No locals.
#1  0x08085a09 in try_window_id (w=0x8b927f0) at xdisp.c:15191

The function try_window_id has this code:

try_window_id (w)
     struct window *w;
{
[...]
  /* Update window_end_pos and window_end_vpos.  */
  if (first_unchanged_at_end_row
      && !last_text_row_at_end)
[...]
  else if (last_text_row_at_end)
[...]
  else if (last_text_row)
[...]
  else if (first_unchanged_at_end_row == NULL
	   && last_text_row == NULL
	   && last_text_row_at_end == NULL)
[...]
  else
    abort ();   <-- line 15191
[...]
}

So it's impossible to reach the line 15191 with any
combination of values of these three variables:

  first_unchanged_at_end_vpos
  last_text_row
  last_text_row_at_end

Is it GCC bug?  Which version of GCC have you used?

---
Kenichi Handa
handa@m17n.org

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-06  8:06 ` Kenichi Handa
@ 2007-03-06  8:41   ` Hongyi Zhao
  2007-03-06 12:38     ` Kenichi Handa
  2007-03-06 14:10   ` David Kastrup
  1 sibling, 1 reply; 49+ messages in thread
From: Hongyi Zhao @ 2007-03-06  8:41 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: Emacs Devel

On Tue, Mar 06, 2007 at 05:06:35PM +0900, Kenichi Handa wrote:
> Is it GCC bug?  Which version of GCC have you used?

See the following:

===================
hongyi@debian-testing-hy:~$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v 
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-mpfr --with-tune=i686 
--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
===================

Thanks.
---
Hongyi Zhao (赵弘毅)
GnuPG DSA: 0xD108493B

老子道德经:第十四章
执古之道,以御今之有。
能知古始,是谓道纪。

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-06  7:02 ` Kenichi Handa
@ 2007-03-06  8:57   ` Hongyi Zhao
  0 siblings, 0 replies; 49+ messages in thread
From: Hongyi Zhao @ 2007-03-06  8:57 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: Emacs Devel

[-- Attachment #1: Type: text/plain, Size: 1311 bytes --]

On Tue, Mar 06, 2007 at 04:02:51PM +0900, Kenichi Handa wrote:
> I did the same thing, but couldn't reproduce that bug.  I
> also ran this function:
> (defun temp ()
>   (while t
>     (goto-char 1)
>     (replace-string "-" "\xFF0D")
>     (sit-for 0.1)
>     (goto-char 1)
>     (replace-string "\xFF0D" "-")
>     (sit-for 0.1)))
> on sample-file.mp (by visitting it and typing ESC : (temp)
> RET), but Emacs run's without error.
> 
> Could you please try the same thing by running Emacs without
> "--enable-font-backend" arg?
> 
> > P.S.  When I use the command *bt full*, I find so many debug 
> > informations, can I use a command to pipe these informations into a 
> > file.
> 
> From Emacs, you can do this:
> 
>   M-x gdb RET .../src/emacs RET
> 
> Then the interation with gdb can be done in *gud-emacs*
> buffer, thus you can easily save a proper part in a file.

I did it completely according to the above guidance, but the emacs 
aborted still.  Please see the attachments for detail.

Thanks in advance.

---
Hongyi Zhao (赵弘毅)
GnuPG DSA: 0xD108493B

老子道德经:第二十七章
善行无辙迹;善言无瑕谪;
善数不用筹策;善闭无关楗而不可开;善结无绳约而不可解。
是以圣人常善救人,故无弃人;常善救物,故无弃物。是谓袭明。

[-- Attachment #2: debug-in-gud-emacs.tar.bz2 --]
[-- Type: application/octet-stream, Size: 21394 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-06  8:41   ` Hongyi Zhao
@ 2007-03-06 12:38     ` Kenichi Handa
  2007-03-06 15:23       ` Hongyi Zhao
  0 siblings, 1 reply; 49+ messages in thread
From: Kenichi Handa @ 2007-03-06 12:38 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: emacs-devel

In article <20070306084130.GA5394@debian-testing-hy.localdomain>, Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

This is exactly the same version as mine.

[...]
> > Could you please try the same thing by running Emacs without
> > "--enable-font-backend" arg?
[...]
> I did it completely according to the above guidance, but the emacs 
> aborted still.  Please see the attachments for detail.

In debug-in-gud-emacs.tar.bz2, the file
debug-in-gdb-under-emacs doesn't contain the result of "bt
full" command.  Was it the same as the previous one?

You also included the file info-under-gud-emacs which is the
same as src/emacs.c.   What do you mean by it?

---
Kenichi Handa
handa@m17n.org

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-06  8:06 ` Kenichi Handa
  2007-03-06  8:41   ` Hongyi Zhao
@ 2007-03-06 14:10   ` David Kastrup
  2007-03-07  1:01     ` Kenichi Handa
  1 sibling, 1 reply; 49+ messages in thread
From: David Kastrup @ 2007-03-06 14:10 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: Hongyi Zhao, emacs-devel

Kenichi Handa <handa@m17n.org> writes:

> By the way,
>
>> abnormally.  The debug-results-gdb is my debug informations under 
>> gdb.
>
> It shows this info:
>
> Breakpoint 1, abort () at emacs.c:431
> 431       kill (getpid (), SIGABRT);
> (gdb) bt full
> #0  abort () at emacs.c:431
> No locals.
> #1  0x08085a09 in try_window_id (w=0x8b927f0) at xdisp.c:15191
>
> The function try_window_id has this code:
>
> try_window_id (w)
>      struct window *w;
> {
> [...]
>   /* Update window_end_pos and window_end_vpos.  */
>   if (first_unchanged_at_end_row
>       && !last_text_row_at_end)
> [...]
>   else if (last_text_row_at_end)
> [...]
>   else if (last_text_row)
> [...]
>   else if (first_unchanged_at_end_row == NULL
> 	   && last_text_row == NULL
> 	   && last_text_row_at_end == NULL)
> [...]
>   else
>     abort ();   <-- line 15191
> [...]
> }
>
> So it's impossible to reach the line 15191 with any
> combination of values of these three variables:
>
>   first_unchanged_at_end_vpos
>   last_text_row
>   last_text_row_at_end
>
> Is it GCC bug?  Which version of GCC have you used?

>From etc/DEBUG:

    ** When you are trying to analyze failed assertions, it will be
    essential to compile Emacs either completely without optimizations
    or at least (when using GCC) with the -fno-crossjumping option.
    Failure to do so may make the compiler recycle the same abort call
    for all assertions in a given function, rendering the stack
    backtrace useless for identifying the specific failed assertion.

-- 
David Kastrup

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-06 12:38     ` Kenichi Handa
@ 2007-03-06 15:23       ` Hongyi Zhao
  0 siblings, 0 replies; 49+ messages in thread
From: Hongyi Zhao @ 2007-03-06 15:23 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: Emacs Devel

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

On Tue, Mar 06, 2007 at 09:38:07PM +0900, Kenichi Handa wrote:
> In debug-in-gud-emacs.tar.bz2, the file
> debug-in-gdb-under-emacs doesn't contain the result of "bt
> full" command.  Was it the same as the previous one?
> 
> You also included the file info-under-gud-emacs which is the
> same as src/emacs.c.   What do you mean by it?

It is my mistake, just please see the attachment 
*the-exact-debug-info-use-gdb*.  Feel so sorry for this thing.
---
Hongyi Zhao (赵弘毅)
GnuPG DSA: 0xD108493B

老子道德经:第二章
是以圣人处无为之事,行不言之教;
万物作而弗始,生而弗有,为而弗恃,功成而不居。
夫唯弗居,是以不去。

[-- Attachment #2: the-exact-debug-info-use-gdb.tar.bz2 --]
[-- Type: application/octet-stream, Size: 6085 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-06 14:10   ` David Kastrup
@ 2007-03-07  1:01     ` Kenichi Handa
  2007-03-07  2:37       ` Nick Roberts
  0 siblings, 1 reply; 49+ messages in thread
From: Kenichi Handa @ 2007-03-07  1:01 UTC (permalink / raw)
  To: David Kastrup; +Cc: hongyi.zhao, emacs-devel

In article <86zm6q5upr.fsf@lola.quinscape.zz>, David Kastrup <dak@gnu.org> writes:

> >From etc/DEBUG:

>     ** When you are trying to analyze failed assertions, it will be
>     essential to compile Emacs either completely without optimizations
>     or at least (when using GCC) with the -fno-crossjumping option.
>     Failure to do so may make the compiler recycle the same abort call
>     for all assertions in a given function, rendering the stack
>     backtrace useless for identifying the specific failed assertion.

Ah!  Thank you for the info.  So, Hongyi, please try the
previous test with the emacs compiled as below:

% cd EMACS_BUILD_TREE/src
% rm xdisp.o
% make CFLAGS='-g -fno-crossjumping'

---
Kenichi Handa
handa@m17n.org

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-07  1:01     ` Kenichi Handa
@ 2007-03-07  2:37       ` Nick Roberts
  2007-03-07  3:56         ` Hongyi Zhao
  2007-03-07 17:25         ` My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments Richard Stallman
  0 siblings, 2 replies; 49+ messages in thread
From: Nick Roberts @ 2007-03-07  2:37 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: hongyi.zhao, emacs-devel

 > Ah!  Thank you for the info.  So, Hongyi, please try the
 > previous test with the emacs compiled as below:
 > 
 > % cd EMACS_BUILD_TREE/src
 > % rm xdisp.o
 > % make CFLAGS='-g -fno-crossjumping'

Evidently cross-jumping is only enabled with -O2 or higher so

make CFLAGS=-g

should work.  The current default for Emacs is "-g -O2".  I think it should
be "-g" for CVS Emacs, but I think that we might have had this discussion
on the mailing list before.


-- 
Nick                                           http://www.inet.net.nz/~nickrob

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-07  2:37       ` Nick Roberts
@ 2007-03-07  3:56         ` Hongyi Zhao
  2007-03-07  4:01           ` Nick Roberts
  2007-03-07  4:58           ` Kenichi Handa
  2007-03-07 17:25         ` My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments Richard Stallman
  1 sibling, 2 replies; 49+ messages in thread
From: Hongyi Zhao @ 2007-03-07  3:56 UTC (permalink / raw)
  To: Nick Roberts; +Cc: Emacs Devel, Kenichi Handa

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

On Wed, Mar 07, 2007 at 03:37:08PM +1300, Nick Roberts wrote:
>  > Ah!  Thank you for the info.  So, Hongyi, please try the
>  > previous test with the emacs compiled as below:
>  > 
>  > % cd EMACS_BUILD_TREE/src
>  > % rm xdisp.o
>  > % make CFLAGS='-g -fno-crossjumping'
> 
> Evidently cross-jumping is only enabled with -O2 or higher so
> 
> make CFLAGS=-g
> 
> should work.  The current default for Emacs is "-g -O2".  I think it should
> be "-g" for CVS Emacs, but I think that we might have had this discussion
> on the mailing list before.

But, both of the settings with CFLAGS on my case cann't work, please see 
the debug errors for detail.

---
Hongyi Zhao (赵弘毅)
GnuPG DSA: 0xD108493B

老子道德经:第五十八章
其无正,正复为奇,善复为妖。
人之迷,其日固久!
是以圣人方而不割,
廉而不刿,直而不肆,光而不耀。

[-- Attachment #2: debug-error-CFLAGS.tar.bz2 --]
[-- Type: application/octet-stream, Size: 11052 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-07  3:56         ` Hongyi Zhao
@ 2007-03-07  4:01           ` Nick Roberts
  2007-03-07  4:58             ` Hongyi Zhao
  2007-03-07  4:58           ` Kenichi Handa
  1 sibling, 1 reply; 49+ messages in thread
From: Nick Roberts @ 2007-03-07  4:01 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: Emacs Devel, Kenichi Handa

 > >  > % cd EMACS_BUILD_TREE/src
 > >  > % rm xdisp.o
 > >  > % make CFLAGS='-g -fno-crossjumping'
 > > 
 > > Evidently cross-jumping is only enabled with -O2 or higher so
 > > 
 > > make CFLAGS=-g
 > > 
 > > should work.  The current default for Emacs is "-g -O2".  I think it should
 > > be "-g" for CVS Emacs, but I think that we might have had this discussion
 > > on the mailing list before.
 > 
 > But, both of the settings with CFLAGS on my case cann't work, please see 
 > the debug errors for detail.

This will probably work:

make distclean
configure CFLAGS=-g
make

but it seems excessive as you probably only need -fno-crossjumping in xdisp.o.
You could try

rm xdisp.o
make

Do ^C after the compile string is printed e.g

gcc -c -D_BSD_SOURCE   -Demacs -DHAVE_CONFIG_H -DUSE_LUCID  -I. -I/home/nickrob/emacs/src -D_BSD_SOURCE -I/usr/include/alsa -g -O2 xdisp.c
                                            ^^^^^^
edit it like this:

gcc -c -D_BSD_SOURCE   -Demacs -DHAVE_CONFIG_H -DUSE_LUCID  -I. -I/home/nickrob/emacs/src -D_BSD_SOURCE -I/usr/include/alsa -g xdisp.c
                                            ^^
to compile for xdisp.o, then do `make' to get your executable


-- 
Nick                                           http://www.inet.net.nz/~nickrob

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-07  4:01           ` Nick Roberts
@ 2007-03-07  4:58             ` Hongyi Zhao
  2007-03-07  5:10               ` Nick Roberts
  0 siblings, 1 reply; 49+ messages in thread
From: Hongyi Zhao @ 2007-03-07  4:58 UTC (permalink / raw)
  To: Nick Roberts; +Cc: Emacs Devel

[-- Attachment #1: Type: text/plain, Size: 370 bytes --]

On Wed, Mar 07, 2007 at 05:01:28PM +1300, Nick Roberts wrote:
> This will probably work:
> 
> make distclean
> configure CFLAGS=-g
> make

No, it doesn't work still.  Please see the debug info.

---
Hongyi Zhao (赵弘毅)
GnuPG DSA: 0xD108493B

老子道德经:第十五章
澹兮其若海,飂兮若无止。
孰能浊以静之徐清?
孰能安以动之徐生?

[-- Attachment #2: debug-error-configure-CFLAGS=-g.tar.bz2 --]
[-- Type: application/octet-stream, Size: 6839 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-07  3:56         ` Hongyi Zhao
  2007-03-07  4:01           ` Nick Roberts
@ 2007-03-07  4:58           ` Kenichi Handa
  2007-03-07  5:37             ` Display bug [Re: My Emacs unicode 2 crash again ...] Kenichi Handa
  1 sibling, 1 reply; 49+ messages in thread
From: Kenichi Handa @ 2007-03-07  4:58 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: nickrob, emacs-devel

In article <20070307035646.GA14561@debian-testing-hy.localdomain>, Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> > make CFLAGS=-g
> > 
> > should work.  The current default for Emacs is "-g -O2".  I think it should
> > be "-g" for CVS Emacs, but I think that we might have had this discussion
> > on the mailing list before.

> But, both of the settings with CFLAGS on my case cann't work, please see 
> the debug errors for detail.

It now shows the correct place of calling abort() as below,
and I can reproduce the bug by compiling Emacs with
--enable-asserts.

Breakpoint 1, abort () at emacs.c:431
(gdb) bt full
#0  abort () at emacs.c:431
No locals.
#1  0x0808a8ec in try_window_id (w=0x8867cc8) at xdisp.c:15132

  /* Update window_end_pos and window_end_vpos.  */
  if (first_unchanged_at_end_row
      && !last_text_row_at_end)
    {
      /* Window end line if one of the preserved rows from the current
	 matrix.  Set row to the last row displaying text in current
	 matrix starting at first_unchanged_at_end_row, after
	 scrolling.  */
      xassert (first_unchanged_at_end_row->displays_text_p);
      row = find_last_row_displaying_text (w->current_matrix, &it,
					   first_unchanged_at_end_row);
      xassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));

      w->window_end_pos = make_number (Z - MATRIX_ROW_END_CHARPOS (row));
      w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
      w->window_end_vpos
	= make_number (MATRIX_ROW_VPOS (row, w->current_matrix));
      xassert (w->window_end_bytepos >= 0);   <-- line 15132
      IF_DEBUG (debug_method_add (w, "A"));
    }

I'm now trying to find what is wrong.

---
Kenichi Handa
handa@m17n.org

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-07  4:58             ` Hongyi Zhao
@ 2007-03-07  5:10               ` Nick Roberts
  0 siblings, 0 replies; 49+ messages in thread
From: Nick Roberts @ 2007-03-07  5:10 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: Emacs Devel

 > > make distclean
 > > configure CFLAGS=-g
 > > make
 > 
 > No, it doesn't work still.  Please see the debug info.

OK, I didn't look at the attachment and thought you were saying it wasn't
compiling (You sent a single 30K text file as a compressed tar file attachment.
I think it's best to send such small files just as text, as they're easier to
read)

This looks different to what you had before:

before:
#1  0x08085a09 in try_window_id (w=0x8b927f0) at xdisp.c:15191

now:
#1  0x0808a8ec in try_window_id (w=0x8519d00) at xdisp.c:15132

I don't have a unicode emacs but 15191 - 15132 = 59.  If I go back 59
lines in my xdisp.c from the last fail it takes me to this line:

      xassert (w->window_end_bytepos >= 0);

but I'll leave it to Kenichi Handa to say more, as I know nothing about this
code.

-- 
Nick                                           http://www.inet.net.nz/~nickrob

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Display bug [Re: My Emacs unicode 2 crash again ...]
  2007-03-07  4:58           ` Kenichi Handa
@ 2007-03-07  5:37             ` Kenichi Handa
  2007-03-07  6:26               ` Hongyi Zhao
  0 siblings, 1 reply; 49+ messages in thread
From: Kenichi Handa @ 2007-03-07  5:37 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: nickrob, hongyi.zhao, emacs-devel

In article <E1HOoEX-0002hK-18@etlken.m17n.org>, Kenichi Handa <handa@m17n.org> writes:
> It now shows the correct place of calling abort() as below,
> and I can reproduce the bug by compiling Emacs with
> --enable-asserts.

> Breakpoint 1, abort () at emacs.c:431
> (gdb) bt full
> #0  abort () at emacs.c:431
> No locals.
> #1  0x0808a8ec in try_window_id (w=0x8867cc8) at xdisp.c:15132
[...]
>       xassert (w->window_end_bytepos >= 0);   <-- line 15132
>       IF_DEBUG (debug_method_add (w, "A"));
>     }

> I'm now trying to find what is wrong.

I found that the same bug can be reproduced even with Emacs
22 (latest CVS HEAD) when it is configured with
--enable-asserts.  Please try to build Emacs that way, and
run this code:

(defun temp ()
  (with-temp-buffer
    (switch-to-buffer (current-buffer))
    (insert "a-\n-\nd\n")
    (let ((nbsp (string (decode-char 'ucs #xa0))))
      (while t
	(goto-char 1)
	(replace-string "-" nbsp)
	(sit-for 0.1)
	(goto-char 1)
	(replace-string nbsp "-")
	(sit-for 0.1)))))

It just swaps "-" and NBSP repeatedly.  As the logic of the
function try_window_id is quite complicated, I still don't
understand what is wrong.  Could someone help?  FYI,

(gdb) run
[...]
Breakpoint 1, abort () at emacs.c:431
(gdb) up
#1  0x08086b40 in try_window_id (w=0x85df240) at xdisp.c:14983
(gdb) pp w->buffer
#<buffer  *temp*>
(gdb) pp current_buffer->name
" *temp*"
(gdb) p *current_buffer->text
$7 = {
  beg = 0x85bf3e0 "a-\n-", 
  gpt = 5, 
  z = 8, 
  gpt_byte = 5, 
  z_byte = 8, 
  gap_size = 13, 
  modiff = 6, 
  chars_modiff = 6, 
  save_modiff = 1, 
  overlay_modiff = 1, 
  beg_unchanged = 1, 
  end_unchanged = 3, 
  unchanged_modified = 4, 
  overlay_unchanged_modified = 1, 
  intervals = 0x0, 
  markers = 0x854d948
}
(gdb) p row->end.pos
$8 = {
  charpos = 8, 
  bytepos = 10
}
(gdb) p w->window_end_bytepos
$9 = -2
(gdb) 

It seems that the buffer now contains only ASCII
(i.e. "a-\n-\nd\n"), but row points to a data containing
multibyte characters (NBSP in this case).

---
Kenichi Handa
handa@m17n.org

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: Display bug [Re: My Emacs unicode 2 crash again ...]
  2007-03-07  5:37             ` Display bug [Re: My Emacs unicode 2 crash again ...] Kenichi Handa
@ 2007-03-07  6:26               ` Hongyi Zhao
  2007-03-07  6:40                 ` Kenichi Handa
  2007-03-07 17:26                 ` Richard Stallman
  0 siblings, 2 replies; 49+ messages in thread
From: Hongyi Zhao @ 2007-03-07  6:26 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: Emacs Devel

On Wed, Mar 07, 2007 at 02:37:39PM +0900, Kenichi Handa wrote:
> In article <E1HOoEX-0002hK-18@etlken.m17n.org>, Kenichi Handa <handa@m17n.org> writes:
> > It now shows the correct place of calling abort() as below,
> > and I can reproduce the bug by compiling Emacs with
> > --enable-asserts.

Yes, when I comile the Emacs without this configure arg 
*--enable-asserts*, the problem will disappear, and can running emacs with 
*--enable-font-backend -fn "Dejavu Sans Mono-14"* without this problem.  
But if I run emacs with *--enable-font-backend*, the emacs will crash 
still.

---
Hongyi Zhao (赵弘毅)
GnuPG DSA: 0xD108493B

老子道德经:第八十章
甘其食,美其服,安其居,乐其俗。
邻国相望,鸡犬之声相闻,
民至老死,不相往来。

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: Display bug [Re: My Emacs unicode 2 crash again ...]
  2007-03-07  6:26               ` Hongyi Zhao
@ 2007-03-07  6:40                 ` Kenichi Handa
  2007-03-07  7:38                   ` Hongyi Zhao
  2007-03-07 17:26                 ` Richard Stallman
  1 sibling, 1 reply; 49+ messages in thread
From: Kenichi Handa @ 2007-03-07  6:40 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: emacs-devel

In article <20070307062636.GA18279@debian-testing-hy.localdomain>, Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> Yes, when I comile the Emacs without this configure arg 
> *--enable-asserts*, the problem will disappear, and can running emacs with 
> *--enable-font-backend -fn "Dejavu Sans Mono-14"* without this problem.  
> But if I run emacs with *--enable-font-backend*, the emacs will crash 
> still.

??? Do you really mean that if Emacs is configured without
"--enable-asserts" arg, this has no problem:

% emacs --enable-font-backend -fn "Dejavu Sans Mono-14"

but, this crashes:

% emacs --enable-font-backend

If so, how does it crash?  In the same was as the previous
report?

---
Kenichi Handa
handa@m17n.org

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: Display bug [Re: My Emacs unicode 2 crash again ...]
  2007-03-07  6:40                 ` Kenichi Handa
@ 2007-03-07  7:38                   ` Hongyi Zhao
  0 siblings, 0 replies; 49+ messages in thread
From: Hongyi Zhao @ 2007-03-07  7:38 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: Emacs Devel

On Wed, Mar 07, 2007 at 03:40:35PM +0900, Kenichi Handa wrote:
> In article <20070307062636.GA18279@debian-testing-hy.localdomain>, Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> 
> > Yes, when I comile the Emacs without this configure arg 
> > *--enable-asserts*, the problem will disappear, and can running emacs with 
> > *--enable-font-backend -fn "Dejavu Sans Mono-14"* without this problem.  
> > But if I run emacs with *--enable-font-backend*, the emacs will crash 
> > still.
> 
> ??? Do you really mean that if Emacs is configured without
> "--enable-asserts" arg, 

Yep.

My configure args:

-------------
./configure --prefix=/usr \
--x-includes=/usr/include/X11 --x-libraries=/usr/lib/X11 \
--enable-font-backend \
--enable-locallisppath=/usr/share/emacs/site-lisp:/etc/emacs-snapshot/site-start.d 
\
--enable-largefile --with-pop --with-sound \
--with-x=yes --with-x-toolkit=gtk --with-toolkit-scroll-bars \
--with-xpm --with-jpeg --with-tiff --with-gif --with-png \
--with-freetype  --with-xft --with-xim \
--with-kerberos --with-kerberos5 --with-hesiod
-------------

>
> this has no problem:
> 
> % emacs --enable-font-backend -fn "Dejavu Sans Mono-14"
> 
> but, this crashes:
> 
> % emacs --enable-font-backend

I try both of the two ways to start emacs and do the *temp* fun again, 
but now both ways will run without problem.  Sigh!

---
Hongyi Zhao (赵弘毅)
GnuPG DSA: 0xD108493B

老子道德经:第三十八章
上仁为之而无以为,
上义为之而有以为,
上礼为之而莫之应,
则攘臂而扔之。

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-07  2:37       ` Nick Roberts
  2007-03-07  3:56         ` Hongyi Zhao
@ 2007-03-07 17:25         ` Richard Stallman
  2007-03-08  4:24           ` Eli Zaretskii
  1 sibling, 1 reply; 49+ messages in thread
From: Richard Stallman @ 2007-03-07 17:25 UTC (permalink / raw)
  To: Nick Roberts; +Cc: emacs-devel, hongyi.zhao, handa

    should work.  The current default for Emacs is "-g -O2".  I think it should
    be "-g" for CVS Emacs, but I think that we might have had this discussion
    on the mailing list before.

I use  -g -O0 -fno-inline  for best debugging.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: Display bug [Re: My Emacs unicode 2 crash again ...]
  2007-03-07  6:26               ` Hongyi Zhao
  2007-03-07  6:40                 ` Kenichi Handa
@ 2007-03-07 17:26                 ` Richard Stallman
  2007-03-08  3:50                   ` Hongyi Zhao
  1 sibling, 1 reply; 49+ messages in thread
From: Richard Stallman @ 2007-03-07 17:26 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: emacs-devel, handa

    Yes, when I comile the Emacs without this configure arg 
    *--enable-asserts*, the problem will disappear, and can running emacs with 
    *--enable-font-backend -fn "Dejavu Sans Mono-14"* without this problem.  
    But if I run emacs with *--enable-font-backend*, the emacs will crash 
    still.

Strange.  What about if you use -O0 but do not use --enable-asserts?

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: Display bug [Re: My Emacs unicode 2 crash again ...]
  2007-03-07 17:26                 ` Richard Stallman
@ 2007-03-08  3:50                   ` Hongyi Zhao
  2007-03-08 21:47                     ` Richard Stallman
  0 siblings, 1 reply; 49+ messages in thread
From: Hongyi Zhao @ 2007-03-08  3:50 UTC (permalink / raw)
  To: Richard Stallman; +Cc: Emacs Devel

On Wed, Mar 07, 2007 at 12:26:19PM -0500, Richard Stallman wrote:
>     Yes, when I comile the Emacs without this configure arg 
>     *--enable-asserts*, the problem will disappear, and can running emacs with 
>     *--enable-font-backend -fn "Dejavu Sans Mono-14"* without this problem.  
>     But if I run emacs with *--enable-font-backend*, the emacs will crash 
>     still.

If I run emacs with *--enable-font-backend*, some times it will crash, 
some times not,  it seems all at random.  And I find the gdb said 
*segment error* when it crashed.  But I havn't get the debug info for 
detail at that time, and till now, I cann't reproduce that crash.

> 
> Strange.  What about if you use -O0 but do not use --enable-asserts?

In this way, emacs won't crash.

---
Hongyi Zhao (赵弘毅)
GnuPG DSA: 0xD108493B

老子道德经:第十章
生之畜之,生而不有,
为而不恃,长而不宰,是谓玄德。

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-07 17:25         ` My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments Richard Stallman
@ 2007-03-08  4:24           ` Eli Zaretskii
  2007-03-08  4:50             ` Miles Bader
  2007-03-08  7:19             ` Stefan Monnier
  0 siblings, 2 replies; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-08  4:24 UTC (permalink / raw)
  To: rms; +Cc: nickrob, handa, hongyi.zhao, emacs-devel

> From: Richard Stallman <rms@gnu.org>
> Date: Wed, 07 Mar 2007 12:25:58 -0500
> Cc: emacs-devel@gnu.org, hongyi.zhao@gmail.com, handa@m17n.org
> 
>     should work.  The current default for Emacs is "-g -O2".  I think it should
>     be "-g" for CVS Emacs, but I think that we might have had this discussion
>     on the mailing list before.
> 
> I use  -g -O0 -fno-inline  for best debugging.

Lamentably, given the current attitude of the GCC maintainers, there's
no other way.  It looks like no one cares anymore about code
developers who need to debug and test the same code they eventually
ship at release time.  If you use GCC, you are forced to debug and
test with -O0, and then ship a program compiled with -O2 which you
didn't debug and test.

I couldn't convince GCC developers that debuggability is much more
important in the vast majority of cases than the extra 5%-7%
performance gains one gets by using all the tweaks -O2 does that
defeat debugging.  Sigh.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-08  4:24           ` Eli Zaretskii
@ 2007-03-08  4:50             ` Miles Bader
  2007-03-09 15:08               ` Eli Zaretskii
  2007-03-08  7:19             ` Stefan Monnier
  1 sibling, 1 reply; 49+ messages in thread
From: Miles Bader @ 2007-03-08  4:50 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:
> If you use GCC, you are forced to debug and test with -O0, and then
> ship a program compiled with -O2 which you didn't debug and test.

But that isn't true.  It sometimes takes extra work to debug because of
optimization, but it's not some kind of impossible burden.  Where the
best tradeoff lies is very much an individual thing.

> I couldn't convince GCC developers that debuggability is much more
> important in the vast majority of cases than the extra 5%-7%
> performance gains one gets by using all the tweaks -O2 does that
> defeat debugging.  Sigh.

Convince them to do what?  They give you a bazillion knobs which you can
use to tune the tradeoffs made to your liking.  You can argue about the
defaults, but -O2 _isn't the default_, and it's not even the default
with -O.  What would you have them change?

-Miles
-- 
"Whatever you do will be insignificant, but it is very important that
 you do it."  Mahatma Gandhi

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-08  4:24           ` Eli Zaretskii
  2007-03-08  4:50             ` Miles Bader
@ 2007-03-08  7:19             ` Stefan Monnier
  2007-03-09 15:20               ` Eli Zaretskii
  1 sibling, 1 reply; 49+ messages in thread
From: Stefan Monnier @ 2007-03-08  7:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: nickrob, emacs-devel, rms, hongyi.zhao, handa

> I couldn't convince GCC developers that debuggability is much more
> important in the vast majority of cases than the extra 5%-7%
> performance gains one gets by using all the tweaks -O2 does that
> defeat debugging.  Sigh.

I haven't followed any of gcc's development, but I do have to point out that
keeping track of source-line numbers through all compilation and
optimization phases is tremendously difficult and tiresome, even for
relatively simple optimizations.  And then
designing/understanding/generating/using debug info is itself a challenge.

So if you want reliable debuggability, avoid optimizations.


        Stefan

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: Display bug [Re: My Emacs unicode 2 crash again ...]
  2007-03-08  3:50                   ` Hongyi Zhao
@ 2007-03-08 21:47                     ` Richard Stallman
  0 siblings, 0 replies; 49+ messages in thread
From: Richard Stallman @ 2007-03-08 21:47 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: emacs-devel

    > Strange.  What about if you use -O0 but do not use --enable-asserts?

    In this way, emacs won't crash.

That seems to be a bug due to optimization.

The way to start to track this down is to try compiling various
source files with optimization and without optimization.  In most cases
you will see that a particular source file is the cause.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-08  4:50             ` Miles Bader
@ 2007-03-09 15:08               ` Eli Zaretskii
  2007-03-09 15:26                 ` Andreas Schwab
                                   ` (2 more replies)
  0 siblings, 3 replies; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-09 15:08 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel

> From: Miles Bader <miles.bader@necel.com>
> Date: Thu, 08 Mar 2007 13:50:42 +0900
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> > If you use GCC, you are forced to debug and test with -O0, and then
> > ship a program compiled with -O2 which you didn't debug and test.
> 
> But that isn't true.  It sometimes takes extra work to debug because of
> optimization, but it's not some kind of impossible burden.

I submit that it _is_ an all but impossible burden, since even the
traceback shows many arguments passed to functions as "optimized
out".  How can you debug a program if you cannot see with what
arguments were the offending functions called?

And then there are functions that are inlined just because GCC thinks
it's a good idea, which defeats your ability to put breakpoints (GDB
will put a breakpoint where you asked it to, but the breakpoint will
never break).  Even without inlining, some code rearrangements also
make it impossible or at least impractical to put breakpoints on
source lines whose code happened to be rearranged.  A typical (but not
the only) example is that GCC folds several `return' statements into
one opcode; putting a breakpoint on all but a single `return' out of
all those that were folded runs a very high risk of not breaking.  The
only workaround is to disassemble and put breakpoints on addresses,
not source lines.  That is not my idea of source-level debugging.

Stepping is unreliable with rearranged code, and it's very easy to
miss that one step where the suspected code gets _really_ executed.

Etc., etc.  And this is with GCC and GDB, the two flagships of the GNU
project, which I once used to be proud of using, and proud of showing
off to users of other compilers.  How sad.

> > I couldn't convince GCC developers that debuggability is much more
> > important in the vast majority of cases than the extra 5%-7%
> > performance gains one gets by using all the tweaks -O2 does that
> > defeat debugging.  Sigh.
> 
> Convince them to do what?

To be user-friendlier to developers who want to debug optimized code.

> They give you a bazillion knobs which you can use to tune the
> tradeoffs made to your liking.

That argument is invalid.  First, there's no information in the GCC
documentation that tells you which debug problems can be solved by
what GCC switch.  Moreover, some of the above ``features'' cannot be
disabled individually, only by falling back on -O1 or -O0.

I once suggested something like -Odebug, but since GCC developers are
generally unsympathetic to the kind of gripes I presented, the
suggestion was hardly noticed, and I don't hold my breath to see it
implemented any time soon.

Nor do I have any reason to hope that the GCC manual will be fixed to
at least tell how to defeat the most wacky optimizations, in a way
that would make this information easily comprehended by someone who is
not a compiler expert, just a developer looking for ways to debug her
program.

> You can argue about the defaults, but -O2 _isn't the default_

The default is -O0, which is useless.  Did you ever look at the
horribly inefficient code produced by -O0?

Anyway, -O2 _is_, in fact, a kind of default, since most (if not all)
GNU packages use -O2 in their default builds.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-08  7:19             ` Stefan Monnier
@ 2007-03-09 15:20               ` Eli Zaretskii
  0 siblings, 0 replies; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-09 15:20 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: nickrob, emacs-devel, rms, hongyi.zhao, handa

> Cc: rms@gnu.org,  nickrob@snap.net.nz,  handa@m17n.org,  hongyi.zhao@gmail.com,
> 	  emacs-devel@gnu.org
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Thu, 08 Mar 2007 02:19:41 -0500
> 
> I haven't followed any of gcc's development, but I do have to point out that
> keeping track of source-line numbers through all compilation and
> optimization phases is tremendously difficult and tiresome, even for
> relatively simple optimizations.  And then
> designing/understanding/generating/using debug info is itself a challenge.

I have no doubt that some optimizations cannot avoid hurting
debuggability.  But in the vast majority of programs, the extra 5%-7%
percent of performance those optimizations give you are too low a gain
to justify the terrible price developers need to pay for it.

> So if you want reliable debuggability, avoid optimizations.

The situation is not black and white.  With some cooperation, I'm
positive we could have had an option that enables only those
optimizations which do not severely hamper debugging.

If you ever needed to ship software to a paying customer, you know
that you cannot turn on optimizations only when you ship; you need to
perform the entire testing and QA cycle with the same compilation
options.  Your above suggestion means that the software will be
shipped with unoptimized code, and that is simply unacceptable for
many applications, for performance reasons.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-09 15:08               ` Eli Zaretskii
@ 2007-03-09 15:26                 ` Andreas Schwab
  2007-03-09 15:51                   ` Eli Zaretskii
  2007-03-09 15:56                   ` Eli Zaretskii
  2007-03-09 21:26                 ` Richard Stallman
  2007-03-09 22:59                 ` Stefan Monnier
  2 siblings, 2 replies; 49+ messages in thread
From: Andreas Schwab @ 2007-03-09 15:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Miles Bader, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> To be user-friendlier to developers who want to debug optimized code.

GCC gives all information it has to the debugger.  It's up to the debugger
to make best use of it.  But GCC can't invent information that does not
exist any more.  An incoming argument register that is subsequently
resused for something different simply does not contain the original value
any more.

> Anyway, -O2 _is_, in fact, a kind of default, since most (if not all)
> GNU packages use -O2 in their default builds.

Export CFLAGS=-O0 and most (if not all) GNU packages will use -O0 as their
default builds.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-09 15:26                 ` Andreas Schwab
@ 2007-03-09 15:51                   ` Eli Zaretskii
  2007-03-09 15:56                   ` Eli Zaretskii
  1 sibling, 0 replies; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-09 15:51 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: miles.bader, emacs-devel

> From: Andreas Schwab <schwab@suse.de>
> Cc: Miles Bader <miles.bader@necel.com>, emacs-devel@gnu.org
> Date: Fri, 09 Mar 2007 16:26:03 +0100
> 
> > Anyway, -O2 _is_, in fact, a kind of default, since most (if not all)
> > GNU packages use -O2 in their default builds.
> 
> Export CFLAGS=-O0 and most (if not all) GNU packages will use -O0 as their
> default builds.

You misunderstood me: I didn't describe _my_ problem; I know how to
compile with -O0.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-09 15:26                 ` Andreas Schwab
  2007-03-09 15:51                   ` Eli Zaretskii
@ 2007-03-09 15:56                   ` Eli Zaretskii
  1 sibling, 0 replies; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-09 15:56 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: miles.bader, emacs-devel

> From: Andreas Schwab <schwab@suse.de>
> Cc: Miles Bader <miles.bader@necel.com>, emacs-devel@gnu.org
> Date: Fri, 09 Mar 2007 16:26:03 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > To be user-friendlier to developers who want to debug optimized code.
> 
> GCC gives all information it has to the debugger.  It's up to the debugger
> to make best use of it.  But GCC can't invent information that does not
> exist any more.  An incoming argument register that is subsequently
> resused for something different simply does not contain the original value
> any more.

I wasn't arguing that GCC had bugs in how it produces the debug info.

I was arguing that there's no practical way for me to see a usable
backtrace in an optimized program.  No matter how you turn it, this
remains a sad fact.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-09 15:08               ` Eli Zaretskii
  2007-03-09 15:26                 ` Andreas Schwab
@ 2007-03-09 21:26                 ` Richard Stallman
  2007-03-10 19:18                   ` Eli Zaretskii
  2007-03-09 22:59                 ` Stefan Monnier
  2 siblings, 1 reply; 49+ messages in thread
From: Richard Stallman @ 2007-03-09 21:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: miles.bader, emacs-devel

I don't think that debugging with any specific optimizations is any
harder than it ever was.  What has perhaps changed is that GCC does
additional optimizations, some of which can confuse debugging in
additional ways.

    The situation is not black and white.  With some cooperation, I'm
    positive we could have had an option that enables only those
    optimizations which do not severely hamper debugging.

That might be a useful feature.  If someone wants to prepare an
argument for it, and send it in to gcc@gnu.org cc'ing me, I could
support it.  (I suggest showing me a draft to review before you sent it.)

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-09 15:08               ` Eli Zaretskii
  2007-03-09 15:26                 ` Andreas Schwab
  2007-03-09 21:26                 ` Richard Stallman
@ 2007-03-09 22:59                 ` Stefan Monnier
  2007-03-11 21:10                   ` Eli Zaretskii
  2 siblings, 1 reply; 49+ messages in thread
From: Stefan Monnier @ 2007-03-09 22:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Miles Bader, emacs-devel

> I once suggested something like -Odebug, but since GCC developers are
> generally unsympathetic to the kind of gripes I presented, the suggestion
> was hardly noticed, and I don't hold my breath to see it implemented any
> time soon.

I think -O (aka -O1) should be debug-friendly (so there shouldn't be any
need for -Odebug).


        Stefan

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-09 21:26                 ` Richard Stallman
@ 2007-03-10 19:18                   ` Eli Zaretskii
  0 siblings, 0 replies; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-10 19:18 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

> From: Richard Stallman <rms@gnu.org>
> CC: miles.bader@necel.com, emacs-devel@gnu.org
> Date: Fri, 09 Mar 2007 16:26:25 -0500
> 
> I don't think that debugging with any specific optimizations is any
> harder than it ever was.  What has perhaps changed is that GCC does
> additional optimizations, some of which can confuse debugging in
> additional ways.

As long as these additional optimizations are part of -O2, I'll
maintain that it's impractical to debug programs built with -O2.

>     The situation is not black and white.  With some cooperation, I'm
>     positive we could have had an option that enables only those
>     optimizations which do not severely hamper debugging.
> 
> That might be a useful feature.  If someone wants to prepare an
> argument for it, and send it in to gcc@gnu.org cc'ing me, I could
> support it.  (I suggest showing me a draft to review before you sent it.)

I'll try to do that (although my heart is broken by the outcomes of my
previous attempts to talk to them about this and other similar
issues).

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-09 22:59                 ` Stefan Monnier
@ 2007-03-11 21:10                   ` Eli Zaretskii
  2007-03-11 21:32                     ` David Kastrup
  2007-03-12 14:23                     ` Stefan Monnier
  0 siblings, 2 replies; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-11 21:10 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> Cc: Miles Bader <miles.bader@necel.com>,  emacs-devel@gnu.org
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Fri, 09 Mar 2007 17:59:53 -0500
> 
> I think -O (aka -O1) should be debug-friendly (so there shouldn't be any
> need for -Odebug).

I disagree.  -O1 selects optimizations based on how expensive they are
at compile time, not on how badly they disrupt debugging.  Many
optimizations that are part of -O2 do no harm at all to debugging, so
there's no reason to give them up.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-11 21:10                   ` Eli Zaretskii
@ 2007-03-11 21:32                     ` David Kastrup
  2007-03-11 21:56                       ` Eli Zaretskii
  2007-03-11 22:29                       ` Andreas Schwab
  2007-03-12 14:23                     ` Stefan Monnier
  1 sibling, 2 replies; 49+ messages in thread
From: David Kastrup @ 2007-03-11 21:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Stefan Monnier, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: Miles Bader <miles.bader@necel.com>,  emacs-devel@gnu.org
>> From: Stefan Monnier <monnier@iro.umontreal.ca>
>> Date: Fri, 09 Mar 2007 17:59:53 -0500
>> 
>> I think -O (aka -O1) should be debug-friendly (so there shouldn't be any
>> need for -Odebug).
>
> I disagree.  -O1 selects optimizations based on how expensive they are
> at compile time, not on how badly they disrupt debugging.  Many
> optimizations that are part of -O2 do no harm at all to debugging, so
> there's no reason to give them up.

Well, how about explicitly disabling a few debugging-unfriendly
options when we are compiling with -g?  One particularly nasty option
can be removed with -fno-cross-jumping: without that, post-mortem
analysis of failed assertions becomes rather erratic (backtraces point
to nonsensical places).  This has cost me a lot of grief once.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-11 21:32                     ` David Kastrup
@ 2007-03-11 21:56                       ` Eli Zaretskii
  2007-03-11 21:59                         ` David Kastrup
  2007-03-11 22:29                       ` Andreas Schwab
  1 sibling, 1 reply; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-11 21:56 UTC (permalink / raw)
  To: David Kastrup; +Cc: emacs-devel

> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,  emacs-devel@gnu.org
> From: David Kastrup <dak@gnu.org>
> Date: Sun, 11 Mar 2007 22:32:17 +0100
> 
> > I disagree.  -O1 selects optimizations based on how expensive they are
> > at compile time, not on how badly they disrupt debugging.  Many
> > optimizations that are part of -O2 do no harm at all to debugging, so
> > there's no reason to give them up.
> 
> Well, how about explicitly disabling a few debugging-unfriendly
> options when we are compiling with -g?

We've been through that in this thread: Miles suggested that a day or
two ago.  To which I replied that the GCC documentation doesn't give
you any useful information about which options to turn off to get a
reasonably debuggable program.  And there's no hope for anyone but a
GCC optimization expert to figure that out on her own.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-11 21:56                       ` Eli Zaretskii
@ 2007-03-11 21:59                         ` David Kastrup
  2007-03-12  4:14                           ` Eli Zaretskii
  0 siblings, 1 reply; 49+ messages in thread
From: David Kastrup @ 2007-03-11 21:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,  emacs-devel@gnu.org
>> From: David Kastrup <dak@gnu.org>
>> Date: Sun, 11 Mar 2007 22:32:17 +0100
>> 
>> > I disagree.  -O1 selects optimizations based on how expensive they are
>> > at compile time, not on how badly they disrupt debugging.  Many
>> > optimizations that are part of -O2 do no harm at all to debugging, so
>> > there's no reason to give them up.
>> 
>> Well, how about explicitly disabling a few debugging-unfriendly
>> options when we are compiling with -g?
>
> We've been through that in this thread: Miles suggested that a day or
> two ago.  To which I replied that the GCC documentation doesn't give
> you any useful information about which options to turn off to get a
> reasonably debuggable program.

So because we can't expect to get perfection with 100% certainty, we
should do nothing at all?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-11 21:32                     ` David Kastrup
  2007-03-11 21:56                       ` Eli Zaretskii
@ 2007-03-11 22:29                       ` Andreas Schwab
  2007-03-12  6:11                         ` Stephen J. Turnbull
  2007-03-12  7:04                         ` David Kastrup
  1 sibling, 2 replies; 49+ messages in thread
From: Andreas Schwab @ 2007-03-11 22:29 UTC (permalink / raw)
  To: David Kastrup; +Cc: Eli Zaretskii, Stefan Monnier, emacs-devel

David Kastrup <dak@gnu.org> writes:

> Well, how about explicitly disabling a few debugging-unfriendly
> options when we are compiling with -g?

-g must never change the generated code.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-11 21:59                         ` David Kastrup
@ 2007-03-12  4:14                           ` Eli Zaretskii
  0 siblings, 0 replies; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-12  4:14 UTC (permalink / raw)
  To: David Kastrup; +Cc: emacs-devel

> Cc: emacs-devel@gnu.org
> From: David Kastrup <dak@gnu.org>
> Date: Sun, 11 Mar 2007 22:59:38 +0100
> 
> >> 
> >> Well, how about explicitly disabling a few debugging-unfriendly
> >> options when we are compiling with -g?
> >
> > We've been through that in this thread: Miles suggested that a day or
> > two ago.  To which I replied that the GCC documentation doesn't give
> > you any useful information about which options to turn off to get a
> > reasonably debuggable program.
> 
> So because we can't expect to get perfection with 100% certainty, we
> should do nothing at all?

I don't think I meant that, but I don't understand what you are
suggesting we do, and how.  Please explain.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-11 22:29                       ` Andreas Schwab
@ 2007-03-12  6:11                         ` Stephen J. Turnbull
  2007-03-12 22:08                           ` Eli Zaretskii
  2007-03-12  7:04                         ` David Kastrup
  1 sibling, 1 reply; 49+ messages in thread
From: Stephen J. Turnbull @ 2007-03-12  6:11 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Eli Zaretskii, Stefan Monnier, emacs-devel

Andreas Schwab writes:

 > David Kastrup <dak@gnu.org> writes:
 > 
 > > Well, how about explicitly disabling a few debugging-unfriendly
 > > options when we are compiling with -g?
 > 
 > -g must never change the generated code.

./configure can!

Seems to me that a lot of projects would benefit from this.  Why not
codify the knowledge that we (well, "you", I know nothing about debug
vs optimization interference except that it exists) have in an aclocal
snippet, with a view to eventually including it in Autoconf?

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-11 22:29                       ` Andreas Schwab
  2007-03-12  6:11                         ` Stephen J. Turnbull
@ 2007-03-12  7:04                         ` David Kastrup
  1 sibling, 0 replies; 49+ messages in thread
From: David Kastrup @ 2007-03-12  7:04 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Eli Zaretskii, Stefan Monnier, emacs-devel

Andreas Schwab <schwab@suse.de> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> Well, how about explicitly disabling a few debugging-unfriendly
>> options when we are compiling with -g?
>
> -g must never change the generated code.

That's possibly a sensible rule for GCC, but I don't see that it is a
sensible rule for Emacs.

If you are afraid of behavior-changing options, one could use some
options like -fno-crossjumping both for the debugging and
non-debugging usage.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-11 21:10                   ` Eli Zaretskii
  2007-03-11 21:32                     ` David Kastrup
@ 2007-03-12 14:23                     ` Stefan Monnier
  2007-03-12 21:50                       ` Eli Zaretskii
  1 sibling, 1 reply; 49+ messages in thread
From: Stefan Monnier @ 2007-03-12 14:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> I disagree.  -O1 selects optimizations based on how expensive they are
> at compile time, not on how badly they disrupt debugging.

Really?  Says who?

I don't know if there's an official definition of what -O should be, but
AFAICT all it says is "please optimize this" in a very generic sense.
I.e. in a sense which implies that the user doesn't want to waste time
thinking about details such as which specific optimizations to enable and
which to disable.  It should "just work", so it should be as good as
possible while staying conservative (i.e. do not enable passes which have
a significant risk of resulting in slower code, or which may alter the
semantics of the code, or which may result in odd behavior in the debugger).
I would probably also include a notion of "avoid optimzation passes which
can take too much time (e.g. quadratic complexity or worse)", but it's
definitely not at the top of my list of requirements for the semantics of
"-O".


        Stefan

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-12 14:23                     ` Stefan Monnier
@ 2007-03-12 21:50                       ` Eli Zaretskii
  2007-03-13  1:33                         ` Stefan Monnier
  0 siblings, 1 reply; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-12 21:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> Cc: emacs-devel@gnu.org
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Mon, 12 Mar 2007 10:23:26 -0400
> 
> > I disagree.  -O1 selects optimizations based on how expensive they are
> > at compile time, not on how badly they disrupt debugging.
> 
> Really?  Says who?

Says the GCC manual:

     With `-O', the compiler tries to reduce code size and execution
     time, without performing any optimizations that take a great deal
     of compilation time.

But you don't need to believe this if you don't want to, just look at
the options enabled by -O2 and see how many of them have no relation
to debuggability whatsoever.  They are related to how expensive
(i.e. time-consuming and/or memory-consuming) those optimizations are
for the optimizer.

> I don't know if there's an official definition of what -O should be, but
> AFAICT all it says is "please optimize this" in a very generic sense.
> I.e. in a sense which implies that the user doesn't want to waste time
> thinking about details such as which specific optimizations to enable and
> which to disable.  It should "just work", so it should be as good as
> possible while staying conservative (i.e. do not enable passes which have
> a significant risk of resulting in slower code, or which may alter the
> semantics of the code, or which may result in odd behavior in the debugger).

Well, you are, of course entitled to your own notions, but FWIW the
GCC manual tells a different story:

    `-O2'
	 Optimize even more.  GCC performs nearly all supported
	 optimizations that do not involve a space-speed tradeoff.

IOW, -O2 does what you think -O1 should do (which goes a long way
toward explaining why so many project use -O2 as default).
Optimizations that involve space-speed tradeoff (a PC way of saying
you may lose as likely as win) are in -O3, while those that might
alter the semantics are (AFAIK) not in any -On option, you must turn
them on by hand (at your own risk).  The latter fact is not stated in
these very words, but is quite evident when one reads the manual.

Of course, this is all from reading the manual, so it might be
inaccurate and even plain wrong...

> I would probably also include a notion of "avoid optimzation passes which
> can take too much time (e.g. quadratic complexity or worse)", but it's
> definitely not at the top of my list of requirements for the semantics of
> "-O".

The above seems to show that it's definitely at the top of the GCC
developers' list.  Which I personally think is somewhat silly with
today's fast CPUs, but that's a different matter.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-12  6:11                         ` Stephen J. Turnbull
@ 2007-03-12 22:08                           ` Eli Zaretskii
  2007-03-13  3:36                             ` Stephen J. Turnbull
  0 siblings, 1 reply; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-12 22:08 UTC (permalink / raw)
  To: Stephen J. Turnbull; +Cc: emacs-devel

> From: "Stephen J. Turnbull" <stephen@xemacs.org>
> Cc: David Kastrup <dak@gnu.org>,
>     Eli Zaretskii <eliz@gnu.org>,
>     Stefan Monnier <monnier@iro.umontreal.ca>,
>     emacs-devel@gnu.org
> Date: Mon, 12 Mar 2007 15:11:32 +0900
> 
> Seems to me that a lot of projects would benefit from this.  Why not
> codify the knowledge that we (well, "you", I know nothing about debug
> vs optimization interference except that it exists) have in an aclocal
> snippet, with a view to eventually including it in Autoconf?

The problem is, again, that the list of -fxxx options that, if
disabled, will make the program much easier to debug, is not known
except to the few GCC developers.  So I don't think we know what to
put in aclocal.

If you mean to build a configure-time test that will try each -fxxx
option and somehow establish whether it does or does not disrupt
debugging, then I think this is too large a job, and it will
constantly bitrot due to -fxxx options being removed and added as GCC
is developed.

Or maybe you mean something else?

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-12 21:50                       ` Eli Zaretskii
@ 2007-03-13  1:33                         ` Stefan Monnier
  0 siblings, 0 replies; 49+ messages in thread
From: Stefan Monnier @ 2007-03-13  1:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>> > I disagree.  -O1 selects optimizations based on how expensive they are
>> > at compile time, not on how badly they disrupt debugging.
>> Really?  Says who?
> Says the GCC manual:

Oh, you're talking about what "is", I'm talking about what "should be".
Otherwise, we agree violently.


        Stefan

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-12 22:08                           ` Eli Zaretskii
@ 2007-03-13  3:36                             ` Stephen J. Turnbull
  2007-03-13  7:54                               ` David Kastrup
  0 siblings, 1 reply; 49+ messages in thread
From: Stephen J. Turnbull @ 2007-03-13  3:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii writes:

 > The problem is, again, that the list of -fxxx options that, if
 > disabled, will make the program much easier to debug, is not known

We already have one (-fno-cross-jumps or similar).  Others can be
added as people find out about them.  I'm simply saying that this
information should be available to *all* Emacs developers (eg, by
configuring with --marquis-de-sade-optimizations=no-thank-you), not
just to those who happen to read every post David makes.

 > except to the few GCC developers.

So ask them, once in a while, politely.  And if the gods smile and you
get a useful answer, put it in aclocal.  That's all I'm suggesting.
It's not a huge amount of work.

 > So I don't think we know what to put in aclocal.

Everything we'd like to put there?  No.  Tedious to maintain?
Probably, it will need to be gcc-version-dependent.  Better than
nothing?  Well, I think so.<wink>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-13  3:36                             ` Stephen J. Turnbull
@ 2007-03-13  7:54                               ` David Kastrup
  2007-03-13 21:24                                 ` Eli Zaretskii
  0 siblings, 1 reply; 49+ messages in thread
From: David Kastrup @ 2007-03-13  7:54 UTC (permalink / raw)
  To: Stephen J. Turnbull; +Cc: Eli Zaretskii, emacs-devel

"Stephen J. Turnbull" <stephen@xemacs.org> writes:

> Eli Zaretskii writes:
>
>  > The problem is, again, that the list of -fxxx options that, if
>  > disabled, will make the program much easier to debug, is not known
>
> We already have one (-fno-cross-jumps or similar).  Others can be
> added as people find out about them.  I'm simply saying that this
> information should be available to *all* Emacs developers (eg, by
> configuring with --marquis-de-sade-optimizations=no-thank-you), not
> just to those who happen to read every post David makes.

I've written this info into the file etc/DEBUG, too, but it would be
overoptimistic to assume that everybody reads that before starting
out.

I actually know no option with similarly devastating effects on
debugging productivity: if registers and values and stuff get
optimized away, that is basically a nuisance, but gdb tells you what
happens (at least with newer debug info formats, which value is where
is traced rather well).  I just fine-combed the other gcc options and
did not detect any option which would have the effect of leading the
debugging person to a completely wrong place: other stuff may make
debugging more adventurous, but as far as I can see, it will not cause
plausible lies from the debugger.

The crossjumps option ruins post-mortem debugging by very convincingly
making the backtrace point to the wrong failed assertion.  It does not
help to put a breakpoint on "abort" either.

It cost me several days of debugging once.

>  > So I don't think we know what to put in aclocal.

Well, not using -fno-crossjumping cost me several days of debugging,
it made me put the info in etc/DEBUG, and it cost another person a few
days before I again volunteered this information.

How much more wasted man-hours do you want, Eli, before "knowing" it
might be a good idea to use this by default?

Debugging failed assertions is not exactly a rare occurence.

I'd say what is good enough for etc/DEBUG is good enough for aclocal.
Of course, we'll need an autoconf check that this option is actually
supported by the gcc version in question.

-- 
David Kastrup

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
  2007-03-13  7:54                               ` David Kastrup
@ 2007-03-13 21:24                                 ` Eli Zaretskii
  0 siblings, 0 replies; 49+ messages in thread
From: Eli Zaretskii @ 2007-03-13 21:24 UTC (permalink / raw)
  To: David Kastrup; +Cc: stephen, emacs-devel

> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
> From: David Kastrup <dak@gnu.org>
> Date: Tue, 13 Mar 2007 08:54:09 +0100
> 
> I actually know no option with similarly devastating effects on
> debugging productivity: if registers and values and stuff get
> optimized away, that is basically a nuisance, but gdb tells you what
> happens (at least with newer debug info formats, which value is where
> is traced rather well).

If the optimized-away values are function call arguments, the fact
that GDB tells me they were optimized away doesn't help.  Inability to
produce a usable backtrace is a very serious roadblock for debugging,
not just some nuisance.

I have no idea whether there are options to prevent that, maybe not.
This is what I meant when I said we didn't know what to write.

> How much more wasted man-hours do you want, Eli, before "knowing" it
> might be a good idea to use this by default?

Why ask me?  I didn't suggest to put anything neither in DEBUG nor in
aclocal.  I will ask GCC developers to add a feature to turn off the
more problematic optimizations, and that's all.  And if you want to
add something somewhere, you don't need my blessing to install changes
in CVS.  (Maybe just not before the release, as configury is known to
be quite sensitive.)

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2007-03-13 21:24 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-06  6:30 My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments Hongyi Zhao
2007-03-06  7:02 ` Kenichi Handa
2007-03-06  8:57   ` Hongyi Zhao
2007-03-06  8:06 ` Kenichi Handa
2007-03-06  8:41   ` Hongyi Zhao
2007-03-06 12:38     ` Kenichi Handa
2007-03-06 15:23       ` Hongyi Zhao
2007-03-06 14:10   ` David Kastrup
2007-03-07  1:01     ` Kenichi Handa
2007-03-07  2:37       ` Nick Roberts
2007-03-07  3:56         ` Hongyi Zhao
2007-03-07  4:01           ` Nick Roberts
2007-03-07  4:58             ` Hongyi Zhao
2007-03-07  5:10               ` Nick Roberts
2007-03-07  4:58           ` Kenichi Handa
2007-03-07  5:37             ` Display bug [Re: My Emacs unicode 2 crash again ...] Kenichi Handa
2007-03-07  6:26               ` Hongyi Zhao
2007-03-07  6:40                 ` Kenichi Handa
2007-03-07  7:38                   ` Hongyi Zhao
2007-03-07 17:26                 ` Richard Stallman
2007-03-08  3:50                   ` Hongyi Zhao
2007-03-08 21:47                     ` Richard Stallman
2007-03-07 17:25         ` My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments Richard Stallman
2007-03-08  4:24           ` Eli Zaretskii
2007-03-08  4:50             ` Miles Bader
2007-03-09 15:08               ` Eli Zaretskii
2007-03-09 15:26                 ` Andreas Schwab
2007-03-09 15:51                   ` Eli Zaretskii
2007-03-09 15:56                   ` Eli Zaretskii
2007-03-09 21:26                 ` Richard Stallman
2007-03-10 19:18                   ` Eli Zaretskii
2007-03-09 22:59                 ` Stefan Monnier
2007-03-11 21:10                   ` Eli Zaretskii
2007-03-11 21:32                     ` David Kastrup
2007-03-11 21:56                       ` Eli Zaretskii
2007-03-11 21:59                         ` David Kastrup
2007-03-12  4:14                           ` Eli Zaretskii
2007-03-11 22:29                       ` Andreas Schwab
2007-03-12  6:11                         ` Stephen J. Turnbull
2007-03-12 22:08                           ` Eli Zaretskii
2007-03-13  3:36                             ` Stephen J. Turnbull
2007-03-13  7:54                               ` David Kastrup
2007-03-13 21:24                                 ` Eli Zaretskii
2007-03-12  7:04                         ` David Kastrup
2007-03-12 14:23                     ` Stefan Monnier
2007-03-12 21:50                       ` Eli Zaretskii
2007-03-13  1:33                         ` Stefan Monnier
2007-03-08  7:19             ` Stefan Monnier
2007-03-09 15:20               ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).