Skip to content
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

crash when logging empty line #4907

Closed
seanstory opened this issue Jun 11, 2024 · 4 comments · Fixed by #4910
Closed

crash when logging empty line #4907

seanstory opened this issue Jun 11, 2024 · 4 comments · Fixed by #4910
Assignees
Labels
bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Comments

@seanstory
Copy link
Member

  • Version: 8.13.2
  • Operating System: OSX 14.5
  • Steps to Reproduce:
    1. create a new component binary or modify one
    2. have your component log an empty line. In python, I did:
    print(f"""
    This line has text
    this line too. But not the next
    
    """)
    
    1. modify elastic-agent.yml to use your new/modified component
    2. run ./elastic-agent

It crashes with an error like:

$ sudo ./elastic-agent
panic: runtime error: index out of range [0] with length 0

goroutine 186 [running]:
github.com/elastic/elastic-agent/pkg/component/runtime.(*logWriter).Write(0x140003de320, {0x14000684000, 0xf0, 0x8000})
	github.com/elastic/elastic-agent/pkg/component/runtime/log_writer.go:110 +0x490
io.copyBuffer({0x106cf8620, 0x140003de320}, {0x106cf4538, 0x140001a8230}, {0x0, 0x0, 0x0})
	io/io.go:432 +0x1a8
io.Copy(...)
	io/io.go:389
os/exec.(*Cmd).writerDescriptor.func1()
	os/exec/exec.go:560 +0x44
os/exec.(*Cmd).Start.func2(0x0?)
	os/exec/exec.go:717 +0x34
created by os/exec.(*Cmd).Start in goroutine 184
	os/exec/exec.go:716 +0x7bc
@seanstory seanstory added the bug Something isn't working label Jun 11, 2024
@ycombinator
Copy link
Contributor

Hi @seanstory, please share your complete elastic-agent.yml. Also, what do you mean by "component" in this context?

@cmacknz
Copy link
Member

cmacknz commented Jun 11, 2024

Component is a process run by agent, this issue was discovered in the process of writing a new agent sub-process.

This should be reproducible with our fake-component

@ycombinator
Copy link
Contributor

Ah, thanks @cmacknz, sounds like you had the additional context I was missing for triage.

@ycombinator ycombinator added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Jun 11, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

blakerouse added a commit to blakerouse/elastic-agent that referenced this issue Jun 11, 2024
@blakerouse blakerouse self-assigned this Jun 11, 2024
blakerouse added a commit that referenced this issue Jun 12, 2024
* Fix #4907.

* Add changelog.

* Apply suggestions from code review

Co-authored-by: Julien Lind <julien.lind@elastic.co>

---------

Co-authored-by: Julien Lind <julien.lind@elastic.co>
mergify bot pushed a commit that referenced this issue Jun 12, 2024
* Fix #4907.

* Add changelog.

* Apply suggestions from code review

Co-authored-by: Julien Lind <julien.lind@elastic.co>

---------

Co-authored-by: Julien Lind <julien.lind@elastic.co>
(cherry picked from commit 3df9f8b)
blakerouse added a commit that referenced this issue Jun 12, 2024
* Fix #4907.

* Add changelog.

* Apply suggestions from code review

Co-authored-by: Julien Lind <julien.lind@elastic.co>

---------

Co-authored-by: Julien Lind <julien.lind@elastic.co>
(cherry picked from commit 3df9f8b)

Co-authored-by: Blake Rouse <blake.rouse@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants