[ZBX-6584] Possible agent crash when processing logrt[] key on windows platform Created: 2013 May 08  Updated: 2017 May 30  Resolved: 2013 May 10

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 1.8.16rc2
Fix Version/s: 1.8.17rc1, 2.0.7, 2.1.0

Type: Incident report Priority: Critical
Reporter: Andris Zeila Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: log, logrt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows


Issue Links:
Duplicate

 Description   

If the monitored log file was moved in the time before checking for its existence and opening it, then on windows platform agent would crash.



 Comments   
Comment by Andris Zeila [ 2013 May 08 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-6584

Comment by dimir [ 2013 May 08 ]

The problem happens when a log file was removed between agent calling stat() and open() on a log file. When this happens open() results in an error and next call to close() results in crash. Steps to reproduce:

  • let zabbix agent call stat() on the log file
  • sleep
  • remove the log file
  • let zabbix agent call open() on the log file (open() fails which results in file descriptor set to -1)
  • let zabbix agent call close(-1), it crashes

Before the fix the check for close was in place but it just checked for file descriptor != 0, it did not handle situation when it would be -1. The fix is to call close() only when file descriptor is greater than 0.

Successfully tested.

Comment by dimir [ 2013 May 09 ]

The problem does not happen with log items, only logrt.

Comment by Andris Zeila [ 2013 May 09 ]

Released in:
pre-1.8.17rc1 r35519
pre-2.0.7 r35520
pre-2.1.0 r35521

Comment by Oleksii Zagorskyi [ 2013 May 10 ]

Reopen to add labels - could be useful for future.
Closed again.

Comment by dimir [ 2013 May 10 ]

So, a real world case could be as follows:

  • foo.log file is monitored by zabbix agent
  • also foo.log file is being rotated by logrotater
  • zabbix agent checks if foo.log exists, success
  • now at this point logrotater decides the log is too big and compresses it, moving the contents to a new file foo.log.gz.1
  • foo.log disappears
  • zabbix agent continues it's routines with foo.log, it's time to read the data from it
  • crash

Technically the problem is incorrect error handling of open() system call.

Comment by dimir [ 2013 May 10 ]

Another point, the crash is possible only on a Windows platform.

Generated at Thu Apr 25 14:19:51 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.