Skip to content

csmith fuzzing #1033

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

Merged
merged 1 commit into from
Sep 25, 2017
Merged

csmith fuzzing #1033

merged 1 commit into from
Sep 25, 2017

Conversation

e00E
Copy link
Contributor

@e00E e00E commented Sep 25, 2017

ref #969

An initial version of a script that fuzzes bindgen with csmith. I ran it for maybe 1000 iterations and it did not find something wrong. The programs generated by csmith are probably too simple type wise.

Here is an example output of what csmith generates:

/* --- Struct/Union Declarations --- */
union U2 {
   uint64_t  f0;
   const signed f1 : 18;
};

union U4 {
   const volatile signed f0 : 1;
   volatile int16_t  f1;
   int32_t  f2;
   int8_t * const  f3;
   volatile int64_t  f4;
};

union U5 {
   const int8_t * f0;
   volatile int8_t  f1;
   uint16_t  f2;
   unsigned f3 : 22;
};

/* --- GLOBAL VARIABLES --- */
static int8_t g_3[8] = {0x47L,0xE8L,0x47L,0x47L,0xE8L,0x47L,0x47L,0xE8L};
static int32_t g_25 = 0x3421AD7BL;
static union U5 g_40 = {0};/* VOLATILE GLOBAL g_40 */
static int32_t g_43[4][3] = {{(-10L),(-10L),(-10L)},{(-10L),(-10L),(-10L)},{(-10L),(-10L),(-10L)},{(-10L),($static int32_t * volatile g_42 = &g_43[0][0];/* VOLATILE GLOBAL g_42 */
static int32_t * volatile g_50 = &g_43[2][0];/* VOLATILE GLOBAL g_50 */
static int32_t g_53 = (-9L);
static union U4 g_57 = {0x9C113E7BL};/* VOLATILE GLOBAL g_57 */


/* --- FORWARD DECLARATIONS --- */
static union U4  func_1(void);
static int16_t  func_4(int32_t  p_5);
static int32_t  func_6(int32_t  p_7, union U2  p_8, int8_t * p_9);
static int32_t  func_10(uint32_t  p_11, int8_t * p_12, int8_t * p_13);
static int8_t * func_14(int32_t  p_15, union U2  p_16);
static union U2  func_28(const uint64_t  p_29, int8_t * p_30, uint32_t  p_31);
static union U5  func_34(uint32_t  p_35);

@fitzgen
Copy link
Member

fitzgen commented Sep 25, 2017

An initial version of a script that fuzzes bindgen with csmith. I ran it for maybe 1000 iterations and it did not find something wrong. The programs generated by csmith are probably too simple type wise.

Are there any knobs we can tweak to make the types more complex?

@fitzgen
Copy link
Member

fitzgen commented Sep 25, 2017

Regardless or current effectiveness, I think we should land this now so that others can continue to experiment with C-Smith and we have a canonical place to submit any improvements.

Thanks for looking into this @e00E ! Looking forward to more :)

@bors-servo r+

@bors-servo
Copy link

📌 Commit d5f8722 has been approved by fitzgen

@bors-servo
Copy link

⌛ Testing commit d5f8722 with merge f5b6e00...

bors-servo pushed a commit that referenced this pull request Sep 25, 2017
csmith fuzzing

ref #969

An initial version of a script that fuzzes bindgen with csmith. I ran it for maybe 1000 iterations and it did not find something wrong. The programs generated by csmith are probably too simple type wise.

Here is an example output of what csmith generates:
``` C
/* --- Struct/Union Declarations --- */
union U2 {
   uint64_t  f0;
   const signed f1 : 18;
};

union U4 {
   const volatile signed f0 : 1;
   volatile int16_t  f1;
   int32_t  f2;
   int8_t * const  f3;
   volatile int64_t  f4;
};

union U5 {
   const int8_t * f0;
   volatile int8_t  f1;
   uint16_t  f2;
   unsigned f3 : 22;
};

/* --- GLOBAL VARIABLES --- */
static int8_t g_3[8] = {0x47L,0xE8L,0x47L,0x47L,0xE8L,0x47L,0x47L,0xE8L};
static int32_t g_25 = 0x3421AD7BL;
static union U5 g_40 = {0};/* VOLATILE GLOBAL g_40 */
static int32_t g_43[4][3] = {{(-10L),(-10L),(-10L)},{(-10L),(-10L),(-10L)},{(-10L),(-10L),(-10L)},{(-10L),($static int32_t * volatile g_42 = &g_43[0][0];/* VOLATILE GLOBAL g_42 */
static int32_t * volatile g_50 = &g_43[2][0];/* VOLATILE GLOBAL g_50 */
static int32_t g_53 = (-9L);
static union U4 g_57 = {0x9C113E7BL};/* VOLATILE GLOBAL g_57 */

/* --- FORWARD DECLARATIONS --- */
static union U4  func_1(void);
static int16_t  func_4(int32_t  p_5);
static int32_t  func_6(int32_t  p_7, union U2  p_8, int8_t * p_9);
static int32_t  func_10(uint32_t  p_11, int8_t * p_12, int8_t * p_13);
static int8_t * func_14(int32_t  p_15, union U2  p_16);
static union U2  func_28(const uint64_t  p_29, int8_t * p_30, uint32_t  p_31);
static union U5  func_34(uint32_t  p_35);
```
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: fitzgen
Pushing f5b6e00 to master...

@bors-servo bors-servo merged commit d5f8722 into rust-lang:master Sep 25, 2017
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

Successfully merging this pull request may close these issues.

4 participants