Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Support running on 32bit ARM platform #198

Merged
merged 1 commit into from
Oct 16, 2018
Merged

Support running on 32bit ARM platform #198

merged 1 commit into from
Oct 16, 2018

Conversation

adrienkohlbecker
Copy link
Contributor

On 32 bits system like armv7 (raspberry pi), using atomic.AddInt64 (and other variants) resulted in a nil pointer exception. I understand datadog does not officially support arm, but since the fix is pretty easy in this case, it seemed like a good candidate for a PR.

This go issue has more details golang/go#599

In our case we make limited use of 64 bits atomic functions, in two places:

  • runCounter: This is only used for logging and assuming an increment each second would overflow in 70 years if 32 bits, so is most likely safe
  • realTimeEnabled: This is used as a pseudo bolean so 0/1 and is safe

I've recompiled the agent 6.5.2 from source using this fix and I'm successfully running it on my Raspberry Pi, with processes reporting.

For the record, log output without the fix:

Oct 14 22:26:18 unifi systemd[1]: Started "Datadog Process Agent".
Oct 14 22:26:18 unifi process-agent[15985]: 2018-10-14 22:26:18 INFO (proc.go:210) - pid '15985' written to pid file '/opt/datadog-agent/run/process-agent.pid'
Oct 14 22:26:18 unifi process-agent[15985]: 2018-10-14 22:26:18 INFO (config.go:417) - config.Load()
Oct 14 22:26:18 unifi process-agent[15985]: 2018-10-14 22:26:18 INFO (config.go:426) - config.load succeeded
Oct 14 22:26:18 unifi process-agent[15985]: 2018-10-14 22:26:18 INFO (tagger.go:81) - starting the tagging system
Oct 14 22:26:20 unifi process-agent[15985]: panic: runtime error: invalid memory address or nil pointer dereference
Oct 14 22:26:20 unifi process-agent[15985]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x13a88]
Oct 14 22:26:20 unifi process-agent[15985]: goroutine 99 [running]:
Oct 14 22:26:20 unifi process-agent[15985]: runtime/internal/atomic.goXadd64(0x2cb40cc, 0x1, 0x0, 0x0, 0x0)
Oct 14 22:26:20 unifi process-agent[15985]:         /usr/local/go/src/runtime/internal/atomic/atomic_arm.go:96 +0x1c
Oct 14 22:26:20 unifi process-agent[15985]: main.(*Collector).runCheck(0x2cb40a0, 0x10975a0, 0x1c0a2c8)
Oct 14 22:26:20 unifi process-agent[15985]:         /opt/agent/go/src/github.com/DataDog/datadog-process-agent/agent/collector.go:74 +0x38
Oct 14 22:26:20 unifi process-agent[15985]: main.(*Collector).run.func2(0x2cb40a0, 0x2a9ef80, 0x10975a0, 0x1c0a2c8)
Oct 14 22:26:20 unifi systemd[1]: datadog-agent-process.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Oct 14 22:26:20 unifi systemd[1]: datadog-agent-process.service: Unit entered failed state.
Oct 14 22:26:20 unifi systemd[1]: datadog-agent-process.service: Failed with result 'exit-code'.

@bits-bot
Copy link

bits-bot commented Oct 16, 2018

CLA assistant check
All committers have signed the CLA.

@adrienkohlbecker adrienkohlbecker changed the title Support running on 32bit platform Support running on 32bit ARM platform Oct 16, 2018
On 32 bits system like armv7 (raspberry pi), using `atomic.AddInt64` (and other variants) resulted in a nil pointer exception. I understand datadog does not officially support arm, but since the fix is pretty easy in this case, it seemed like a good candidate for a PR.

This go issue has more details golang/go#599

In our case we make limited use of 64 bits atomic functions, in two places:
- `runCounter`: This is only used for logging and assuming an increment each second would overflow in 70 years if 32 bits, so is most likely safe
- `realTimeEnabled`: This is used as a pseudo bolean so 0/1 and is safe

I've recompiled the agent 6.5.2 from source using this fix and I'm successfully running it on my Raspberry Pi, with processes reporting.
Copy link
Member

@sunhay sunhay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for putting this together!

Hope we don't get a support case because of this in 70 years!

@sunhay sunhay merged commit 2da91c5 into DataDog:master Oct 16, 2018
@adrienkohlbecker adrienkohlbecker deleted the ak/fix-arm branch October 16, 2018 00:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants