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

Memory corruption crashes every few days #319

Closed
joeshaw opened this issue May 12, 2022 · 16 comments
Closed

Memory corruption crashes every few days #319

joeshaw opened this issue May 12, 2022 · 16 comments
Labels
bug Something isn't working
Milestone

Comments

@joeshaw
Copy link

joeshaw commented May 12, 2022

Describe the bug
I have been seeing SwiftBar crashes (either SIGSEGV or SIGABRT) due to memory corruption.

I haven't been able to detect a consistent pattern with the crashes. They seem to happen every couple of days, typically after I've put my machine to sleep. They seem to happen when my machine does a macOS "power nap" wakeup, though I am not certain on that.

I'm attaching 3 crash reports to the bug. Two are segfaults (SIGSEGV) and one is a SIGABRT triggered by malloc() detecting heap corruption.

Environment:

  • macOS version: 12.3.1 on Intel
  • SwiftBar version: 1.4.3, installed from the homebrew cask

Additional Context:

I have 3 scripts running:

  • A bash script that runs every 5 seconds
  • A Go program that runs every 5 seconds
  • A Go program that runs every 30 seconds

I do run Bartender. I have not (yet) tried running without it, though I previously ran earlier 1.4.x versions under it without issue.

I've attached the crash reports generated my macOS below. GitHub did not like the original ips extension, so I appended .txt to them. They are JSON files, however, but can be rendered more prettily by Console.app.

SwiftBar-2022-05-05-191332.ips.txt
SwiftBar-2022-05-06-165801.ips.txt
SwiftBar-2022-05-11-205124.ips.txt

@gimbo
Copy link

gimbo commented Jul 19, 2022

As a curious user considering migrating from xbar, can I ask: when it crashes, do the icons disappear from your menubar (i.e. SwiftBar is completely gone/stopped) or is it just that it stops updating?

I'm asking because I'm motivated to move by xbar issue #714 ("Crashing after a large number of refreshes") and there's no point migrating if the same behaviour occurs here!

I'd be surprised if it is the same error, but wanted to check. 😄

@joeshaw
Copy link
Author

joeshaw commented Jul 19, 2022

@gimbo It crashes and the items leave the menubar.

An older version (1.4.1 iirc) had an issue where items stopped updating, but that was fixed and I haven't had any problems with updating since.

@melonamin
Copy link
Contributor

I'm trying to catch this in a debug session, I've been running 3 simple plugins with 5s refresh period for a week and a half now... no luck.

I'll try to have more complex plugins and somehow trigger sleep-wake. Stay tuned...

@melonamin
Copy link
Contributor

@joeshaw can you share with me any of your plugins?

So far SwiftBar is solid for me, with two caveats:

  • I'm running an unrelease version(but I don't think it matters)
  • I'm on ARM

@bobobox
Copy link

bobobox commented Jul 27, 2022

Similar experience here - two SIGSEGV crashes this week, on 1.4.3 (422), on M1 running 12.4.

@melonamin
Copy link
Contributor

@bobobox plz give me an example plugin, I can't catch this

@joeshaw
Copy link
Author

joeshaw commented Jul 29, 2022

I run 3, but I can only give you two of them.

utc.5s.bash

#!/bin/bash
exec date -u +':globe: %H:%M | size=13'

stock-ticker.30s. -- This is a Go program. I'm including the source below but if you want me to attach a binary instead I can do that. If you have go installed, drop it in a directory and run go build -o stock-ticker.30s. .

package main

import (
        "encoding/json"
        "fmt"
        "io/ioutil"
        "log"
        "net/http"
)

type result struct {
        Chart struct {
                Result []struct {
                        Meta struct {
                                Symbol    string  `json:"symbol"`
                                Price     float64 `json:"regularMarketPrice"`
                                PrevPrice float64 `json:"chartPreviousClose"`
                        } `json:"meta"`
                } `json:"result"`
        } `json:"chart"`
}

const urlFmt = "https://query1.finance.yahoo.com/v7/finance/chart/%s?interval=1d"

func main() {
        symbols := []string{"AAPL", "^SPX"}
        for i, s := range symbols {
                u := fmt.Sprintf(urlFmt, s)
                resp, err := http.Get(u)
                if err != nil {
                        log.Fatal(err)
                }
                defer resp.Body.Close()

                body, err := ioutil.ReadAll(resp.Body)
                if err != nil {
                        log.Fatal(err)
                }

                if resp.StatusCode != http.StatusOK {
                        log.Fatalf("%d: %s", resp.StatusCode, body)
                }

                var r result
                if err := json.Unmarshal(body, &r); err != nil {
                        log.Fatalf("%v: %s", err, body)
                }

                price := r.Chart.Result[0].Meta.Price
                prev := r.Chart.Result[0].Meta.PrevPrice
                net := price - prev
                pct := net / prev * 100

                var arrow string
                if net > 0 {
                        arrow = "↑"
                } else if net < 0 {
                        arrow = "↓"
                }

                if i == 0 {
                        fmt.Printf("%s $%.2f%s | size=13\n", s, price, arrow)
                        fmt.Println("---")
                }
                fmt.Printf("%s %.2f %+.2f (%+.2f%%)\n", s, price, net, pct)
        }
}

The third is another Go program that runs every 5s. Unfortunately I can't share that one.

@melonamin
Copy link
Contributor

@joeshaw hey, I think I'm ready to give up...

I've been running these two plugins on two different machines(Intel and M1) for two weeks straight, with at least 20 sleep-wake cycle on both of them. It just works.🤷‍♂️

@joeshaw
Copy link
Author

joeshaw commented Sep 1, 2022

@melonamin Is there anything more I can do to help? A debugging build, additional logs, anything like that?

I appreciate your effort trying to reproduce it so far.

@melonamin
Copy link
Contributor

I’m researching how to add a better crash reporting at the moment

@melonamin
Copy link
Contributor

@joeshaw I've added crash reportiing, please try running this build SwiftBar.1.4.4b448.zip

@joeshaw
Copy link
Author

joeshaw commented Sep 12, 2022

Just as an FYI, I've been running this build for about a week now without any crashes. I'll update if and when I see one.

@melonamin
Copy link
Contributor

Hey @adamkdean, since you are expiriencing a simmilar issue in xbar, I would love you to take this build of SwiftBar for a spin.

@adamkdean
Copy link

@melonamin once I'm done with testing xbar, I'll give SwiftBar a whirl too and get back to you

@melonamin
Copy link
Contributor

@joeshaw please tell me it's been rock solid for you all this time, I want to release 1.4.4 soon-ish

@joeshaw
Copy link
Author

joeshaw commented Oct 3, 2022

@melonamin No issues here. I feel comfortable with it, and I think you can probably close this issue now. I'll reopen it or file another if I start seeing the issue again. I'm sorry we couldn't precisely identify it!

@melonamin melonamin added this to the 1.4.4 milestone Oct 4, 2022
@melonamin melonamin added the bug Something isn't working label Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants