* Incorrect replacement of TYPE_METHODS with TYPE_FIELDS causing segfault.
@ 2022-06-08 4:47 Zopolis0
2022-06-08 7:02 ` Xi Ruoyao
0 siblings, 1 reply; 3+ messages in thread
From: Zopolis0 @ 2022-06-08 4:47 UTC (permalink / raw)
To: gcc-help
While compiling gcj on my mstermerge branch (
https://github.com/Zopolis4/gcj/tree/mstermerge) it breaks on, amongst
other things, an internal compiler error:
echo ../../../../gcj/libjava/classpath/lib/java/lang/ref/*.class >
java/lang/ref.list
echo ../../../../gcj/libjava/classpath/lib/java/lang/reflect/*.class >
java/lang/reflect.list
In file included from <built-in>:31:
../../../../gcj/libjava/java/lang/Object.java: internal compiler error:
tree check: expected function_decl, have field_decl in layout_class_method,
at java/class.cc:2627
In file included from <built-in>:63:
java/lang/Object.java: internal compiler error: tree check: expected
function_decl, have field_decl in layout_class_method, at java/class.cc:2627
I believe that this error is due to the following incorrect code at line
2589 at gcc/java/class.cc:
for (tree method_decl = TYPE_FIELDS (this_class);
Before it was removed, this line was:
for (method_decl = TYPE_METHODS (this_class);
But I have since modified it (
https://github.com/Zopolis4/gcj/commit/1f38bc896a704290ca0b742c60c60a88d5e1fb07#diff-bf49cdc948b20b9f25afd3fbb36922a10e979a55ff9600b3b51d0ec54175b752L2592)
in accordance with 5aaa8fb40681ee66282d73dab8c8eccbf5ee0518
Given that this was incorrect, what would be the correct way to replace
this instance of TYPE_METHODS? Were all my replacements of TYPE_METHODS in
gcc/java/class.cc wrong?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Incorrect replacement of TYPE_METHODS with TYPE_FIELDS causing segfault.
2022-06-08 4:47 Incorrect replacement of TYPE_METHODS with TYPE_FIELDS causing segfault Zopolis0
@ 2022-06-08 7:02 ` Xi Ruoyao
2022-06-08 8:13 ` Zopolis0
0 siblings, 1 reply; 3+ messages in thread
From: Xi Ruoyao @ 2022-06-08 7:02 UTC (permalink / raw)
To: Zopolis0, gcc-help
On Wed, 2022-06-08 at 14:47 +1000, Zopolis0 via Gcc-help wrote:
/* snip */
> java/lang/Object.java: internal compiler error: tree check: expected
> function_decl, have field_decl in layout_class_method, at java/class.cc:2627
>
> I believe that this error is due to the following incorrect code at line
> 2589 at gcc/java/class.cc:
> for (tree method_decl = TYPE_FIELDS (this_class);
>
> Before it was removed, this line was:
> for (method_decl = TYPE_METHODS (this_class);
>
> But I have since modified it (
> https://github.com/Zopolis4/gcj/commit/1f38bc896a704290ca0b742c60c60a88d5e1fb07#diff-bf49cdc948b20b9f25afd3fbb36922a10e979a55ff9600b3b51d0ec54175b752L2592)
> in accordance with 5aaa8fb40681ee66282d73dab8c8eccbf5ee0518
>
> Given that this was incorrect, what would be the correct way to replace
> this instance of TYPE_METHODS? Were all my replacements of TYPE_METHODS in
> gcc/java/class.cc wrong?
5aaa8fb is not a simple replacement. For example:
/* If there are user-defined methods, they are deemed non-trivial. */
- for (tmp = TYPE_METHODS (type); tmp; tmp = TREE_CHAIN (tmp))
- if (!DECL_ARTIFICIAL (tmp))
+ for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
+ if (TREE_CODE (TREE_TYPE (fld)) == METHOD_TYPE && !DECL_ARTIFICIAL (fld))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
return true;
I think you need to check if the field is really a method like this.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Incorrect replacement of TYPE_METHODS with TYPE_FIELDS causing segfault.
2022-06-08 7:02 ` Xi Ruoyao
@ 2022-06-08 8:13 ` Zopolis0
0 siblings, 0 replies; 3+ messages in thread
From: Zopolis0 @ 2022-06-08 8:13 UTC (permalink / raw)
To: Xi Ruoyao; +Cc: gcc-help
Do I need the TREE_CODE there? Would TREE_TYPE (fld)) == METHOD_TYPE not
work?
On Wed, Jun 8, 2022 at 5:02 PM Xi Ruoyao <xry111@xry111.site> wrote:
> On Wed, 2022-06-08 at 14:47 +1000, Zopolis0 via Gcc-help wrote:
>
> /* snip */
>
> > java/lang/Object.java: internal compiler error: tree check: expected
> > function_decl, have field_decl in layout_class_method, at
> java/class.cc:2627
> >
> > I believe that this error is due to the following incorrect code at line
> > 2589 at gcc/java/class.cc:
> > for (tree method_decl = TYPE_FIELDS (this_class);
> >
> > Before it was removed, this line was:
> > for (method_decl = TYPE_METHODS (this_class);
> >
> > But I have since modified it (
> >
> https://github.com/Zopolis4/gcj/commit/1f38bc896a704290ca0b742c60c60a88d5e1fb07#diff-bf49cdc948b20b9f25afd3fbb36922a10e979a55ff9600b3b51d0ec54175b752L2592
> )
> > in accordance with 5aaa8fb40681ee66282d73dab8c8eccbf5ee0518
> >
> > Given that this was incorrect, what would be the correct way to replace
> > this instance of TYPE_METHODS? Were all my replacements of TYPE_METHODS
> in
> > gcc/java/class.cc wrong?
>
> 5aaa8fb is not a simple replacement. For example:
>
> /* If there are user-defined methods, they are deemed non-trivial. */
> - for (tmp = TYPE_METHODS (type); tmp; tmp = TREE_CHAIN (tmp))
> - if (!DECL_ARTIFICIAL (tmp))
> + for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
> + if (TREE_CODE (TREE_TYPE (fld)) == METHOD_TYPE && !DECL_ARTIFICIAL
> (fld))
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> return true;
>
> I think you need to check if the field is really a method like this.
> --
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-08 8:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 4:47 Incorrect replacement of TYPE_METHODS with TYPE_FIELDS causing segfault Zopolis0
2022-06-08 7:02 ` Xi Ruoyao
2022-06-08 8:13 ` Zopolis0
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).