0

I tried to run strace in linux for my Program.

Here is the example Output :

brk(0)                                  = 0x804b000
brk(0x806c000)                          = 0x806c000
open("test.txt", O_RDONLY)              = 3
fstat64(3, {st_mode=S_IFREG|0600, st_size=216, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7728000
read(3, "10\n10\n2\t3\t3\t5\t4\t7\t7\t2\t2\t7\t\n8\t3\t1"..., 4096) = 216
read(3, "", 4096)                       = 0
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0xb7728000, 4096)                = 0
**open(NULL, O_RDONLY)                    = -1 EFAULT (Bad address)**
dup(2)                                  = 3
fcntl64(3, F_GETFL)                     = 0x2 (flags O_RDWR)
fstat64(3, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7728000
**_llseek(3, 0, 0xbfc97a44, SEEK_CUR)     = -1 ESPIPE (Illegal seek)**
write(3, "Can't open file!: Bad address\n", 30Can't open file!: Bad address

Why i get some errors in that two line. what **open(NULL, O_RDONLY)** does it means?

MSK
  • 159
  • 1
  • 2
  • 7

1 Answers1

3
**open(NULL, O_RDONLY)  

You're passing a NULL string as file name. According to the documentation, EFAULT is generated when the pathname points outside your accessible address space.

_llseek(3, 0, 0xbfc97a44, SEEK_CUR)

You are trying to set the offset of a file descriptor which does not support this function.

In fact, you are trying to move the offset of the STANDARD ERROR (3 is the result of dup(2)), which does not make sense as it is not a real file. According to the documentation, ESPIPE is generated when a file descriptor is associated with a pipe, socket, or FIFO.

Olsonist
  • 2,051
  • 1
  • 20
  • 35
Giuseppe Pes
  • 7,772
  • 3
  • 52
  • 90