This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH antimony] c: fix stack overflow in array generation

Message ID
DKIM signature
Download raw message
Patch: +3 -3
To generate the array, we're calling generate_type on top-level type
that came to this function which *IS* an array. That creates an infinite
loop and thus causing a stack overflow.

The fix is simple, use type that the array holds (e.g. Int) and not the
type of array itself (which is Array<Int> in this case).
 src/generator/c.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/generator/c.rs b/src/generator/c.rs
index 178de85..7d7618d 100644
--- a/src/generator/c.rs
+++ b/src/generator/c.rs
@@ -53,13 +53,13 @@ pub(super) fn generate_type(t: Either<Variable, Option<Type>>) -> String {
            Type::Any => "void *".into(),
            Type::Bool => "bool".into(),
            Type::Struct(_) => todo!(),
            Type::Array(_) => match name {
            Type::Array(t) => match name {
                Some(n) => format!(
                    "{T} {N}[]",
                    T = generate_type(Either::Right(Some(t))),
                    T = generate_type(Either::Right(Some(*t))),
                    N = n
                None => format!("{}[]", generate_type(Either::Right(Some(t)))),
                None => format!("{}[]", generate_type(Either::Right(Some(*t)))),
        None => "void".into(),

[antimony/patches/ci.yml] build failed

Message ID
<20210226064141.6184-1-yyp@disroot.org> (view parent)
DKIM signature
Download raw message
antimony/patches/ci.yml: FAILED in 2m20s

[c: fix stack overflow in array generation][0] from [Alexey Yerin][1]

[0]: https://lists.sr.ht/~garritfra/antimony/patches/20582
[1]: mailto:yyp@disroot.org

✗ #440220 FAILED antimony/patches/ci.yml https://builds.sr.ht/~garritfra/job/440220
Reply to thread Export thread (mbox)