0
caesar.c:9:20: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/stdlib.h:105:33: note: nonnull attribute specified here
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==3639==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7ff1e17f71b0 bp 0x00
0000000000 sp 0x7fff04148f10 T3639)
==3639==The signal is caused by a READ memory access.
==3639==Hint: address points to the zero page.
    #0 0x7ff1e17f71af  (/lib/x86_64-linux-gnu/libc.so.6+0x451af)
    #1 0x7ff1e17f268f  (/lib/x86_64-linux-gnu/libc.so.6+0x4068f)
    #2 0x42254e  (/root/sandbox/caesar+0x42254e)
    #3 0x7ff1e17d3b96  (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #4 0x402c59  (/root/sandbox/caesar+0x402c59)

UndefinedBehaviorSanitizer can not provide additional info.
==3639==ABORTING
0

You pass a null pointer to atoi, in line 9 of your code, I guess there's something like atoi(argv[1]).

As I don't know the code, I'll guess a bit.

Valid indices to argv range from 0 to argc-1, with argv[0] being the name of the executable, and the arguments (if any) starting at index 1. My guess would be that you call atoi on argv[1] before you checked that one actually exists. If the index points you outside the memory dedicated to argv, you will still read a value, it's just what comes next in memory.

If that's the problem, check argc before you access any of the strings in argv.

1
  • thanks for your help you were right i was checking for valid input before ckecking for argc it work now finally , much appreciation
    – ox0o
    Sep 2 '19 at 12:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .