Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5986709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:42:38+00:00 2026-05-22T22:42:38+00:00

My c++ program gives me a seg fault when I run as root from

  • 0

My c++ program gives me a seg fault when I run as root from my computer but not when I start a remote session. My program run from my computer only as a user. What can be the problem? I wrote my program for an embedded device and I’m using this to compile:

gcc -Werror notify.cc -o notify `pkg-config --libs --cflags gtk+-2.0 hildon-notifymm hildonmm hildon-fmmm'

I’m not getting any error. Could it be a flag problem? I can post my code.

EDIT: When I start my program with gdb I get this:

Program received signal SIGSEGV, Segmentation fault.
0x40eed060 in strcmp () from /lib/libc.so.6
0x40eed060 <strcmp+0>:  ldrb    r2, [r0], #1

Backtrace give this:

(gdb) backtrace
 #0  0x40eed060 in strcmp () from /lib/libc.so.6
 #1  0x40b7f190 in dbus_set_g_error ()
 from /usr/lib/libdbus-glib-1.so.2
 #2  0x40b7d060 in dbus_g_bus_get () from /usr/lib/libdbus-glib-1.so.2
 #3  0x400558ec in notify_init () from /usr/lib/libnotify.so.1
 #4  0x4004a240 in Notify::init(Glib::ustring const&) ()
 from /usr/lib/libnotifymm-1.0.so.7
 #5  0x40033794 in Hildon::notify_init(Glib::ustring const&) ()
 from /usr/lib/libhildon-notifymm-1.0.so.1

Here is my code:

#include <hildonmm.h>
#include <hildon-notifymm.h>
#include <hildon/hildon-notification.h>
#include <libnotifymm/init.h>
#include <gtkmm/stock.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <iostream>

int main(int argc, char *argv[])
{
// Initialize gtkmm and maemomm:

Hildon::init();
Hildon::notify_init("Notification Example");

// Initialize D-Bus (needed by hildon-notify):
DBusConnection* conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
dbus_connection_setup_with_g_main(conn, NULL);

// Create a new notification:
Glib::RefPtr<Hildon::Notification> notification =   Hildon::Notification::create("Something Happened", "A thing has just happened.", Gtk::Stock::OPEN);

// Show the notification:
std::auto_ptr<Glib::Error> ex;
notification->show(ex);
if(ex.get())
{ 
std::cerr << "Notification::show() failed: " << ex->what() << std::endl;
}
return 0;
}

EDIT: Problem solved. Program needs a DBUS_SESSION_ADDRESS in the env of the terminal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:42:39+00:00Added an answer on May 22, 2026 at 10:42 pm

    You might want to run your program under valgrind. I wrote a tiny program that writes outside of an allocated array:

    $ valgrind ./segfault
    ==11830== Memcheck, a memory error detector
    ==11830== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
    ==11830== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
    ==11830== Command: ./segfault
    ==11830== 
    ==11830== Invalid write of size 1
    ==11830==    at 0x4004BF: main (in /tmp/segfault)
    ==11830==  Address 0x7feff65bf is not stack'd, malloc'd or (recently) free'd
    ==11830== 
    ==11830== 
    ==11830== Process terminating with default action of signal 11 (SIGSEGV)
    ==11830==  Access not within mapped region at address 0x7FEFF65BF
    ==11830==    at 0x4004BF: main (in /tmp/segfault)
    ==11830==  If you believe this happened as a result of a stack
    ==11830==  overflow in your program's main thread (unlikely but
    ==11830==  possible), you can try to increase the size of the
    ==11830==  main thread stack using the --main-stacksize= flag.
    ==11830==  The main thread stack size used in this run was 8388608.
    ==11830== 
    ==11830== HEAP SUMMARY:
    ==11830==     in use at exit: 0 bytes in 0 blocks
    ==11830==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
    ==11830== 
    ==11830== All heap blocks were freed -- no leaks are possible
    ==11830== 
    ==11830== For counts of detected and suppressed errors, rerun with: -v
    ==11830== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)
    Segmentation fault
    

    The most important part of this output is here:

    ==11830== Invalid write of size 1
    ==11830==    at 0x4004BF: main (in /tmp/segfault)
    

    The write of size 1 might help you figure out which line was involved:

    int main(int argc, char *argv[]) {
        char f[1];
        f[-40000]='c';
        return 0;
    }
    

    Another very useful tool to know is gdb. If you set your rlimits to allow dumping core (see setrlimit(2) for details on the limits, and your shell’s manual (probably bash(1)) for details on the ulimit built-in command) then you can get a core file for use with gdb:

    $ ulimit -c 1000
    $ ./segfault 
    Segmentation fault (core dumped)
    $ gdb --core=core ./segfault
    GNU gdb (GDB) 7.2-ubuntu
    Copyright (C) 2010 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "x86_64-linux-gnu".
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>...
    Reading symbols from /tmp/segfault...(no debugging symbols found)...done.
    [New Thread 11951]
    
    warning: Can't read pathname for load map: Input/output error.
    Reading symbols from /lib/libc.so.6...Reading symbols from /usr/lib/debug/lib/libc-2.12.1.so...done.
    done.
    Loaded symbols for /lib/libc.so.6
    Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.12.1.so...done.
    done.
    Loaded symbols for /lib64/ld-linux-x86-64.so.2
    Core was generated by `./segfault'.
    Program terminated with signal 11, Segmentation fault.
    #0  0x00000000004004bf in main ()
    (gdb) bt
    #0  0x00000000004004bf in main ()
    (gdb) quit
    

    Depending upon the size of your program, you might need to give way more than 1000 blocks to the allowed core file. If this program were remotely complicated, knowing the call chain to get to the segfault could be vital information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Changing a Linux C++ program which gives the user limited file access. Thus the
Tried to install some program, it gives above message requiring 1.1.4322. BUT as the
I'm trying to get console input in my Clojure program, but when it gives
the program gives following exception: Exception in thread main java.lang.NullPointerException at myclasses.BubbleSort.run(BubbleSort.java:42) at acm.program.Program.runHook(Program.java:1519)
consider the program below char str[5]; strcpy(str,Hello12345678); printf(%s,str); When run this program gives segmentation
I am trying to start a long running program that gives lots of output
When I run the program the first time (the output file is not yet
when I'm trying to compile my c program it gives me this error warning:
Why gives the following Windows 7 .cmd command script: set SUN_JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_17 if
This program is meant to generate a dynamic array, however it gives an access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.