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
You have to used global labels for subroutines, then all is fine.
leo
> 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
> 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