Skip to contentSkip to conversation

buffer overflow check bug

DISCUSSION Dan Carpenter 3 participants 5 messages Jun 18, 2012 – Jun 22, 2012 10 messages not in the archive Sparse checker

lore
Share & tools
lore
#10 lore raw
In reply to a message not in the archive

Gar... I have no idea. That seems like an issue in sparse.

Does anyone know why MOD_NORETURN gets set for:
extern void my_exit(const char*, ...) __attribute__ ((__noreturn__));

but not for:
extern __attribute__ ((__noreturn__)) void my_exit(const char*, ...);

GCC seems to accept both formats.

regards,
dan carpenter

#11 lore raw
Quoted 9 lines · Dan Carpenter

Gar... I have no idea. That seems like an issue in sparse.

Does anyone know why MOD_NORETURN gets set for:
extern void my_exit(const char*, ...) __attribute__ ((__noreturn__));

but not for:
extern __attribute__ ((__noreturn__)) void my_exit(const char*, ...);

GCC seems to accept both formats.

I wonder if the latter gets incorrectly parsed as though the attribute attached to "void" rather than "my_exit"?

- Josh Triplett

#12 lore raw
Quoted 6 lines · Josh Triplett
Quoted 5 lines · Dan Carpenter

Gar... I have no idea. That seems like an issue in sparse.

Does anyone know why MOD_NORETURN gets set for:
extern void my_exit(const char*, ...) __attribute__ ((__noreturn__));

Quoted 8 lines
Quoted 4 lines

but not for:
extern __attribute__ ((__noreturn__)) void my_exit(const char*, ...);

GCC seems to accept both formats.

I wonder if the latter gets incorrectly parsed as though the attribute attached to "void" rather than "my_exit"?

I put a:

	printf("%d %d token = %s\n", token->pos.line, token->pos.pos, token->ident->name);

in handle_attributes() and it only prints when the attribute is at the end.

regards,
dan carpenter

#13 lore raw
In reply to Dan Carpenter
Quoted 9 lines · Dan Carpenter

Gar... I have no idea. That seems like an issue in sparse.

Does anyone know why MOD_NORETURN gets set for:
extern void my_exit(const char*, ...) __attribute__ ((__noreturn__));

but not for:
extern __attribute__ ((__noreturn__)) void my_exit(const char*, ...);

GCC seems to accept both formats.

Which version of sparse are you using? Everything looks good to me here.

  extern void my_exit(const char*, ...) __attribute__ ((__noreturn__));
  extern __attribute__ ((__noreturn__)) void another_exit(const char*, ...);
  void foo(void) { my_exit(""); }
  void bar(void) { another_exit(""); }

My backend "splay" emits:

declare void @my_exit(i8*, ...) noreturn
declare void @another_exit(i8*, ...) noreturn
...

The noreturn attribute is set simply by:

  if (sym->ctype.modifiers & MOD_NORETURN)
      LLVMAddFunctionAttr(func, LLVMNoReturnAttribute);

- xi

#14 lore raw
Quoted 7 lines · Xi Wang
Quoted 5 lines · Dan Carpenter

Gar... I have no idea. That seems like an issue in sparse.

Does anyone know why MOD_NORETURN gets set for:
extern void my_exit(const char*, ...) __attribute__ ((__noreturn__));

Quoted 6 lines
Quoted 4 lines

but not for:
extern __attribute__ ((__noreturn__)) void my_exit(const char*, ...);

GCC seems to accept both formats.

Which version of sparse are you using? Everything looks good to me here.

I'm on sparse 0.4.4. Which version are you on?

Quoted 8 lines
  extern void my_exit(const char*, ...) __attribute__ ((__noreturn__));
  extern __attribute__ ((__noreturn__)) void another_exit(const char*, ...);
  void foo(void) { my_exit(""); }
  void bar(void) { another_exit(""); }

My backend "splay" emits:

Quoted 8 lines

declare void @my_exit(i8*, ...) noreturn
declare void @another_exit(i8*, ...) noreturn
...

The noreturn attribute is set simply by:

  if (sym->ctype.modifiers & MOD_NORETURN)
      LLVMAddFunctionAttr(func, LLVMNoReturnAttribute);

Yep. I use the same test, but sym->ctype.modifiers is not set for me. The debug printf I added in handle_attributes() should have printed.

regards,
dan carpenter