Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory corruption #84

Closed
Misiur opened this issue Mar 2, 2016 · 2 comments
Closed

Memory corruption #84

Misiur opened this issue Mar 2, 2016 · 2 comments

Comments

@Misiur
Copy link
Contributor

Misiur commented Mar 2, 2016

#include <a_samp>

static const
    Test[2][][2] = {
        { { 1, 2 } },
        { { 2, 3 } }
    }
;

main()
{
    printf("%d", Test[1][0][1]);
}
[debug] Run time error 22: "AMX not initialized (or doubly initialized)"
Script[gamemodes/ytest2.amx]: Run time error 22: "AMX not initialized (or doubly initialized)"

Small change of adding array size to the 2nd dimension works tho.

@YashasSamaga
Copy link
Member

YashasSamaga commented Feb 13, 2017

This is causing an assertion to fail if I use a debug build of the compiler.

This assertion got triggered when I compiled v3.10.2 source too. So it is not from my PR 152.

The compiler is pushing the wrong address for "%d". The array data and the array dereference code is correct.

The compiler adds the same number of numbers (and the same numbers) to the literal queue in both the cases but the size variable turns out to be different.

Here is the problem,
https://github.com/Zeex/pawn/blob/master/source/compiler/sc1.c#L2460

The compiler assumes that an array with more than 2 dimensions will never appear.

#153

@Zeex
Copy link
Member

Zeex commented May 1, 2017

Closing this because #153 has been merged into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants