public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR79814
@ 2017-04-21 12:04 Richard Biener
  2017-04-25  9:36 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2017-04-21 12:04 UTC (permalink / raw)
  To: gcc-patches


The following fixes uninitialized uses in pass_manager::pass_manager
which causes bootstrap failure when a fix for PR2972 is applied.

Bootstrap and regtest in progress on x86_64-unknown-linux-gnu
(together with the 2972 fix).

Richard.

2017-04-21  Richard Biener  <rguenther@suse.de>

	PR bootstrap/79814
	* pass_manager.h (pass_manager::operator new): Remove.
	(pass_manager::operator delete): Likewise.
	* passes.c (pass_manager::operator new): Remove.
	(pass_manager::operator delete): Likewise.
	(pass_manager::pass_manager): Zero individual pass members.

Index: gcc/pass_manager.h
===================================================================
*** gcc/pass_manager.h	(revision 247049)
--- gcc/pass_manager.h	(working copy)
*************** class context;
*** 47,55 ****
  class pass_manager
  {
  public:
-   void *operator new (size_t sz);
-   void operator delete (void *ptr);
- 
    pass_manager (context *ctxt);
    ~pass_manager ();
  
--- 47,52 ----
Index: gcc/passes.c
===================================================================
*** gcc/passes.c	(revision 247049)
--- gcc/passes.c	(working copy)
*************** pass_manager::register_pass (struct regi
*** 1528,1546 ****
  				        -> all_passes
  */
  
- void *
- pass_manager::operator new (size_t sz)
- {
-   /* Ensure that all fields of the pass manager are zero-initialized.  */
-   return xcalloc (1, sz);
- }
- 
- void
- pass_manager::operator delete (void *ptr)
- {
-   free (ptr);
- }
- 
  pass_manager::pass_manager (context *ctxt)
  : all_passes (NULL), all_small_ipa_passes (NULL), all_lowering_passes (NULL),
    all_regular_ipa_passes (NULL),
--- 1528,1533 ----
*************** pass_manager::pass_manager (context *ctx
*** 1549,1554 ****
--- 1536,1556 ----
  {
    opt_pass **p;
  
+   /* Zero-initialize pass members.  */
+ #define INSERT_PASSES_AFTER(PASS)
+ #define PUSH_INSERT_PASSES_WITHIN(PASS)
+ #define POP_INSERT_PASSES()
+ #define NEXT_PASS(PASS, NUM) PASS ## _ ## NUM = NULL
+ #define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM)
+ #define TERMINATE_PASS_LIST(PASS)
+ #include "pass-instances.def"
+ #undef INSERT_PASSES_AFTER
+ #undef PUSH_INSERT_PASSES_WITHIN
+ #undef POP_INSERT_PASSES
+ #undef NEXT_PASS
+ #undef NEXT_PASS_WITH_ARG
+ #undef TERMINATE_PASS_LIST
+ 
    /* Initialize the pass_lists array.  */
  #define DEF_PASS_LIST(LIST) pass_lists[PASS_LIST_NO_##LIST] = &LIST;
    GCC_PASS_LISTS

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

* Re: [PATCH] Fix PR79814
  2017-04-21 12:04 [PATCH] Fix PR79814 Richard Biener
@ 2017-04-25  9:36 ` Andreas Schwab
  2017-04-25  9:43   ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2017-04-25  9:36 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Apr 21 2017, Richard Biener <rguenther@suse.de> wrote:

> The following fixes uninitialized uses in pass_manager::pass_manager
> which causes bootstrap failure when a fix for PR2972 is applied.

This fails to properly initialize the pass_manager instance, causing cc1
to crash later.

Program received signal SIGSEGV, Segmentation fault.
0x4000000000b417c1 in hash_table<hash_map<nofree_string_hash, opt_pass*, simple_hashmap_traits<default_hash_traits<nofree_string_hash>, opt_pass*> >::hash_entry, xcallocator>::find_with_hash (this=0x2000000000988140 <_IO_2_1_stderr_>, 
    comparable=@0x600ffffffffee790: 0x60000000002f3870 "tree-omplower", 
    hash=1802803413) at ../../gcc/hash-map.h:57
57          static bool is_empty (const hash_entry &e) { return Traits::is_empty (e); }
(gdb) bt
#0  0x4000000000b417c1 in hash_table<hash_map<nofree_string_hash, opt_pass*, simple_hashmap_traits<default_hash_traits<nofree_string_hash>, opt_pass*> >::hash_entry, xcallocator>::find_with_hash (this=0x2000000000988140 <_IO_2_1_stderr_>, 
    comparable=@0x600ffffffffee790: 0x60000000002f3870 "tree-omplower", 
    hash=1802803413) at ../../gcc/hash-map.h:57
#1  0x4000000000b28e30 in hash_map<nofree_string_hash, opt_pass*, simple_hashmap_traits<default_hash_traits<nofree_string_hash>, opt_pass*> >::get (
    k=@0x600ffffffffee790: 0x60000000002f3870 "tree-omplower", 
    this=0x2000000000988140 <_IO_2_1_stderr_>) at ../../gcc/hash-map.h:150
#2  gcc::pass_manager::register_pass_name (this=0x60000000002ea0c0, 
    pass=0x60000000002e7750, name=0x60000000002f3870 "tree-omplower")
    at ../../gcc/passes.c:857
#3  0x4000000000b29850 in gcc::pass_manager::register_one_dump_file (
    this=0x60000000002ea0c0, pass=0x60000000002e7750) at ../../gcc/passes.c:827
#4  0x4000000000b29b00 in gcc::pass_manager::register_dump_files (
    this=0x60000000002ea0c0, pass=0x60000000002e7750) at ../../gcc/passes.c:839
#5  0x4000000000b3f4b0 in gcc::pass_manager::pass_manager (
    this=0x60000000002ea0c0, ctxt=<optimized out>) at ../../gcc/passes.c:1607
#6  0x400000000049f110 in gcc::context::context (this=0x60000000002a2f00)
    at ../../gcc/context.c:39
#7  0x400000000017def0 in general_init (init_signals=<optimized out>, 
    argv0=<optimized out>) at ../../gcc/toplev.c:1159
#8  toplev::main (this=0x600ffffffffef0e0, argc=2, argv=0x600ffffffffef388)
    at ../../gcc/toplev.c:2089
#9  0x4000000000183e90 in main (argc=2, argv=0x600ffffffffef388)
    at ../../gcc/main.c:39
(gdb) f 5
#5  0x4000000000b3f4b0 in gcc::pass_manager::pass_manager (
    this=0x60000000002ea0c0, ctxt=<optimized out>) at ../../gcc/passes.c:1607
1607      register_dump_files (all_lowering_passes);
(gdb) p m_name_to_pass_map
$13 = (hash_map<nofree_string_hash, opt_pass*, simple_hashmap_traits<default_hash_traits<nofree_string_hash>, opt_pass*> > *) 0x2000000000988140 <_IO_2_1_stderr_>

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH] Fix PR79814
  2017-04-25  9:36 ` Andreas Schwab
@ 2017-04-25  9:43   ` Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2017-04-25  9:43 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: gcc-patches

On Tue, 25 Apr 2017, Andreas Schwab wrote:

> On Apr 21 2017, Richard Biener <rguenther@suse.de> wrote:
> 
> > The following fixes uninitialized uses in pass_manager::pass_manager
> > which causes bootstrap failure when a fix for PR2972 is applied.
> 
> This fails to properly initialize the pass_manager instance, causing cc1
> to crash later.
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x4000000000b417c1 in hash_table<hash_map<nofree_string_hash, opt_pass*, simple_hashmap_traits<default_hash_traits<nofree_string_hash>, opt_pass*> >::hash_entry, xcallocator>::find_with_hash (this=0x2000000000988140 <_IO_2_1_stderr_>, 
>     comparable=@0x600ffffffffee790: 0x60000000002f3870 "tree-omplower", 
>     hash=1802803413) at ../../gcc/hash-map.h:57
> 57          static bool is_empty (const hash_entry &e) { return Traits::is_empty (e); }
> (gdb) bt
> #0  0x4000000000b417c1 in hash_table<hash_map<nofree_string_hash, opt_pass*, simple_hashmap_traits<default_hash_traits<nofree_string_hash>, opt_pass*> >::hash_entry, xcallocator>::find_with_hash (this=0x2000000000988140 <_IO_2_1_stderr_>, 
>     comparable=@0x600ffffffffee790: 0x60000000002f3870 "tree-omplower", 
>     hash=1802803413) at ../../gcc/hash-map.h:57
> #1  0x4000000000b28e30 in hash_map<nofree_string_hash, opt_pass*, simple_hashmap_traits<default_hash_traits<nofree_string_hash>, opt_pass*> >::get (
>     k=@0x600ffffffffee790: 0x60000000002f3870 "tree-omplower", 
>     this=0x2000000000988140 <_IO_2_1_stderr_>) at ../../gcc/hash-map.h:150
> #2  gcc::pass_manager::register_pass_name (this=0x60000000002ea0c0, 
>     pass=0x60000000002e7750, name=0x60000000002f3870 "tree-omplower")
>     at ../../gcc/passes.c:857
> #3  0x4000000000b29850 in gcc::pass_manager::register_one_dump_file (
>     this=0x60000000002ea0c0, pass=0x60000000002e7750) at ../../gcc/passes.c:827
> #4  0x4000000000b29b00 in gcc::pass_manager::register_dump_files (
>     this=0x60000000002ea0c0, pass=0x60000000002e7750) at ../../gcc/passes.c:839
> #5  0x4000000000b3f4b0 in gcc::pass_manager::pass_manager (
>     this=0x60000000002ea0c0, ctxt=<optimized out>) at ../../gcc/passes.c:1607
> #6  0x400000000049f110 in gcc::context::context (this=0x60000000002a2f00)
>     at ../../gcc/context.c:39
> #7  0x400000000017def0 in general_init (init_signals=<optimized out>, 
>     argv0=<optimized out>) at ../../gcc/toplev.c:1159
> #8  toplev::main (this=0x600ffffffffef0e0, argc=2, argv=0x600ffffffffef388)
>     at ../../gcc/toplev.c:2089
> #9  0x4000000000183e90 in main (argc=2, argv=0x600ffffffffef388)
>     at ../../gcc/main.c:39
> (gdb) f 5
> #5  0x4000000000b3f4b0 in gcc::pass_manager::pass_manager (
>     this=0x60000000002ea0c0, ctxt=<optimized out>) at ../../gcc/passes.c:1607
> 1607      register_dump_files (all_lowering_passes);
> (gdb) p m_name_to_pass_map
> $13 = (hash_map<nofree_string_hash, opt_pass*, simple_hashmap_traits<default_hash_traits<nofree_string_hash>, opt_pass*> > *) 0x2000000000988140 <_IO_2_1_stderr_>
> 
> Andreas.

I am testing

2017-04-25  Richard Biener  <rguenther@suse.de>

	PR middle-end/80509
	* passes.c (pass_manager::pass_manager): Initialize
	m_name_to_pass_map.

Index: gcc/passes.c
===================================================================
--- gcc/passes.c	(revision 247147)
+++ gcc/passes.c	(working copy)
@@ -1532,7 +1532,7 @@ pass_manager::pass_manager (context *ctx
 : all_passes (NULL), all_small_ipa_passes (NULL), all_lowering_passes (NULL),
   all_regular_ipa_passes (NULL),
   all_late_ipa_passes (NULL), passes_by_id (NULL), passes_by_id_size (0),
-  m_ctxt (ctxt)
+  m_ctxt (ctxt), m_name_to_pass_map (NULL)
 {
   opt_pass **p;
 

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

end of thread, other threads:[~2017-04-25  9:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21 12:04 [PATCH] Fix PR79814 Richard Biener
2017-04-25  9:36 ` Andreas Schwab
2017-04-25  9:43   ` Richard Biener

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).