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

illegal instruction #12719

Closed
sundq opened this issue Sep 2, 2022 · 2 comments
Closed

illegal instruction #12719

sundq opened this issue Sep 2, 2022 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@sundq
Copy link

sundq commented Sep 2, 2022

Zig Version

0.10.0-dev.3838+77f31ebbb

Steps to Reproduce

my os is linux:Linux sundaqing 5.10.29-amd64-desktop #2 SMP Mon Apr 26 09:48:13 CST 2021 x86_64 GNU/Linux

#include <stdio.h>
#include <stdint.h>


/// type of racoon_message_obersver_s
typedef struct racoon_message_obersver_s racoon_message_obersver_t;

struct racoon_message_obersver_s
{
    const char *name;


    uint32_t ob_msgid;

    int link;
};

int main(int argc, const char *argv[])
{
	int x = &(((racoon_message_obersver_t *)0)->link); /// dump
	return 0;
}

Expected Behavior

run normal

Actual Behavior

compile with 'zig cc' and dump for illegal instruction

@sundq sundq added the bug Observed behavior contradicts documented or intended behavior label Sep 2, 2022
@sundq sundq changed the title illegal instruction when use linux link list illegal instruction Sep 2, 2022
@leecannon
Copy link
Contributor

leecannon commented Sep 2, 2022

https://github.com/ziglang/zig/wiki/zig-cc-compatibility-with-clang#ubsan-and-sigill-illegal-instruction

Zig has ubsan on in safe modes.

Your program has UB (dereferencing a null pointer), if you build it with clang with the -fsanitize=undefined flag the same thing will happen, although a better error will be displayed.

@Vexu
Copy link
Member

Vexu commented Sep 2, 2022

Related #5163

@Vexu Vexu closed this as completed Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants