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

Segmentation fault on startup while trying to initialize monitors #57

Open
Sigmanificient opened this issue Aug 17, 2024 · 0 comments
Open

Comments

@Sigmanificient
Copy link
Contributor

Sigmanificient commented Aug 17, 2024

Describe the bug

Using Xephyr -br -ac -noreset -screen 800x600 :1, and DISPLAY=:1 bin/ragnar I get a segmentation fault
The config file is the example from the repository.

While debugging, I found out that after this line:

uint32_t registered_monitors = updatemons(s);

registered_monitors is equal to 0.

Valgrind dump

[nix-shell:~/ragnar]$ DISPLAY=:1 valgrind bin/ragnar
==862634== Memcheck, a memory error detector
==862634== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==862634== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
==862634== Command: bin/ragnar
==862634== 
sh: line 1: ragnarstart: command not found
==862634== Conditional jump or move depends on uninitialised value(s)
==862634==    at 0x40834A: cursormon (ragnar.c:3149)
==862634==    by 0x40BBFD: setupatoms (ragnar.c:1803)
==862634==    by 0x40D6AE: setup (ragnar.c:198)
==862634==    by 0x404B10: main (ragnar.c:3602)
==862634== 
==862634== Conditional jump or move depends on uninitialised value(s)
==862634==    at 0x40BC11: setupatoms (ragnar.c:1805)
==862634==    by 0x40D6AE: setup (ragnar.c:198)
==862634==    by 0x404B10: main (ragnar.c:3602)
==862634== 
==862634== Use of uninitialised value of size 8
==862634==    at 0x406E21: uploaddesktopnames (ragnar.c:1695)
==862634==    by 0x40BC9E: setupatoms (ragnar.c:1816)
==862634==    by 0x40D6AE: setup (ragnar.c:198)
==862634==    by 0x404B10: main (ragnar.c:3602)
==862634== 
==862634== Invalid read of size 4
==862634==    at 0x406E21: uploaddesktopnames (ragnar.c:1695)
==862634==    by 0x40BC9E: setupatoms (ragnar.c:1816)
==862634==    by 0x40D6AE: setup (ragnar.c:198)
==862634==    by 0x404B10: main (ragnar.c:3602)
==862634==  Address 0x28 is not stack'd, malloc'd or (recently) free'd
==862634== 
==862634== 
==862634== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==862634==  Access not within mapped region at address 0x28
==862634==    at 0x406E21: uploaddesktopnames (ragnar.c:1695)
==862634==    by 0x40BC9E: setupatoms (ragnar.c:1816)
==862634==    by 0x40D6AE: setup (ragnar.c:198)
==862634==    by 0x404B10: main (ragnar.c:3602)
==862634== 
==862634== HEAP SUMMARY:
==862634==     in use at exit: 103,623 bytes in 1,076 blocks
==862634==   total heap usage: 1,934 allocs, 858 frees, 1,336,850 bytes allocated
==862634== 
==862634== LEAK SUMMARY:
==862634==    definitely lost: 640 bytes in 116 blocks
==862634==    indirectly lost: 0 bytes in 0 blocks
==862634==      possibly lost: 448 bytes in 3 blocks
==862634==    still reachable: 102,535 bytes in 957 blocks
==862634==         suppressed: 0 bytes in 0 blocks
==862634== Rerun with --leak-check=full to see details of leaked memory
==862634== 
==862634== Use --track-origins=yes to see where uninitialised values come from
==862634== For lists of detected and suppressed errors, rerun with: -s
==862634== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)

The following code seems to detect 1 monitor:

  xcb_generic_error_t *err;
  xcb_randr_get_monitors_reply_t *monitors =
      xcb_randr_get_monitors_reply(
          s->con, xcb_randr_get_monitors(s->con, s->screen->root, true), &err);
    if (err != NULL) {
        free(err);
        return false;
    }

  int32_t num_outputs = xcb_randr_get_monitors_monitors_length(monitors);

However, I couldn't fully solve the issue and get ragnar to work

@Sigmanificient Sigmanificient changed the title Segmentation fault on startup Segmentation fault on startup while trying to initialize monitors (uploaddesktopnames) Aug 17, 2024
@Sigmanificient Sigmanificient changed the title Segmentation fault on startup while trying to initialize monitors (uploaddesktopnames) Segmentation fault on startup while trying to initialize monitors Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant