Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #22645] IMCC Nested .subs cause segfaults

10 views
Skip to first unread message

Clinton A. Pierce

unread,
Jun 11, 2003, 8:15:21 PM6/11/03
to bugs-bi...@rt.perl.org
# New Ticket Created by "Clinton A. Pierce"
# Please include the string: [perl #22645]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22645 >


I'm exploring IMCC's ability to have nested subs. The following code:

.sub _main
.sub dummy
call inner1
call inner2
end
.end
.sub inner1
print "Inner1\n"
ret
.end
.sub inner2
print "Inner2\n"
ret
.end
end # safety?
.end
end # safety?

Causes IMCC to segfault. Asking IMCC to generate pasm produces reasonable
code:

dummy:
bsr inner1
bsr inner2
end
inner1:
print "Inner1\n"
ret
inner2:
print "Inner2\n"
ret
_main:
end
end


Leopold Toetsch

unread,
Jun 12, 2003, 3:35:18 AM6/12/03
to perl6-i...@perl.org
Clinton A. Pierce <bugs-...@netlabs.develooper.com> wrote:
> .sub _main
> .sub dummy
> call inner1
> call inner2

You have to used global labels for subroutines, then all is fine.

leo

Nicholas Clark

unread,
Jun 12, 2003, 10:30:27 AM6/12/03
to perl6-i...@perl.org, Leopold Toetsch
On Thu, Jun 12, 2003 at 12:15:21AM +0000, Clinton A. Pierce wrote:

> Causes IMCC to segfault. Asking IMCC to generate pasm produces reasonable
> code:

On Thu, Jun 12, 2003 at 09:35:18AM +0200, Leopold Toetsch wrote:
> Clinton A. Pierce <bugs-...@netlabs.develooper.com> wrote:

> > .sub _main
> > .sub dummy
> > call inner1
> > call inner2
>

> You have to used global labels for subroutines, then all is fine.

But being able to craft input that causes IMCC to segfault (actually
any form of segfault) is bad on principle, isn't it?

Nicholas Clark

Leopold Toetsch

unread,
Jun 12, 2003, 10:54:05 AM6/12/03
to Nicholas Clark, perl6-i...@perl.org
Nicholas Clark wrote:

> On Thu, Jun 12, 2003 at 09:35:18AM +0200, Leopold Toetsch wrote:

>>You have to used global labels for subroutines, then all is fine.
>
> But being able to craft input that causes IMCC to segfault (actually
> any form of segfault) is bad on principle, isn't it?


For sure. But this is slightly a different problem. The error happens at
runtime and can easily reproduced by this totally syntactically valid
program:

bsr -1
end

The error is caught at runtime only with the -b or -t switch. The same
holds of course for branching e.g. inside of an instruction or past the end.


> Nicholas Clark

leo

0 new messages