# Unable to start cpufreqd

## fangwen

I installed cpufreqd and used the default configuration file in /etc/cpufreqd.conf. When I ran "/etc/init.d/cpufreqd start", it threw out these error messages:

```
*** buffer overflow detected ***: /usr/sbin/cpufreqd terminated

======= Backtrace: =========

/lib/libc.so.6(__fortify_fail+0x50)[0xb780f6f0]

/lib/libc.so.6(+0xe668a)[0xb780d68a]

/lib/libc.so.6(+0xe6de8)[0xb780dde8]

/usr/sbin/cpufreqd(main+0x834)[0x804b304]

/lib/libc.so.6(__libc_start_main+0xe6)[0xb7741126]

/usr/sbin/cpufreqd[0x804a441]

======= Memory map: ========

08048000-08052000 r-xp 00000000 08:08 206326     /usr/sbin/cpufreqd

08052000-08053000 r--p 00009000 08:08 206326     /usr/sbin/cpufreqd

08053000-08054000 rw-p 0000a000 08:08 206326     /usr/sbin/cpufreqd

083ec000-0840d000 rw-p 00000000 00:00 0          [heap]

b7708000-b7723000 r-xp 00000000 08:08 1237000    /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b7723000-b7724000 r--p 0001a000 08:08 1237000    /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b7724000-b7725000 rw-p 0001b000 08:08 1237000    /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/libgcc_s.so.1

b7725000-b7727000 rw-p 00000000 00:00 0 

b7727000-b787f000 r-xp 00000000 08:08 2269216    /lib/libc-2.12.2.so

b787f000-b7880000 ---p 00158000 08:08 2269216    /lib/libc-2.12.2.so

b7880000-b7882000 r--p 00158000 08:08 2269216    /lib/libc-2.12.2.so

b7882000-b7883000 rw-p 0015a000 08:08 2269216    /lib/libc-2.12.2.so

b7883000-b7886000 rw-p 00000000 00:00 0 

b7886000-b788a000 r-xp 00000000 08:08 206023     /usr/lib/libcpufreq.so.0.0.0

b788a000-b788b000 r--p 00003000 08:08 206023     /usr/lib/libcpufreq.so.0.0.0

b788b000-b788c000 rw-p 00004000 08:08 206023     /usr/lib/libcpufreq.so.0.0.0

b788c000-b788e000 r-xp 00000000 08:08 2269494    /lib/libdl-2.12.2.so

b788e000-b788f000 r--p 00001000 08:08 2269494    /lib/libdl-2.12.2.so

b788f000-b7890000 rw-p 00002000 08:08 2269494    /lib/libdl-2.12.2.so

b7897000-b7898000 rw-p 00000000 00:00 0 

b7898000-b7899000 r-xp 00000000 00:00 0          [vdso]

b7899000-b78b5000 r-xp 00000000 08:08 2269498    /lib/ld-2.12.2.so

b78b5000-b78b6000 r--p 0001b000 08:08 2269498    /lib/ld-2.12.2.so

b78b6000-b78b7000 rw-p 0001c000 08:08 2269498    /lib/ld-2.12.2.so

bfc53000-bfc74000 rw-p 00000000 00:00 0          [stack]

 * start-stop-daemon: failed to start `/usr/sbin/cpufreqd'

 * ERROR: cpufreqd failed to start

```

I don't know does it mean.

Any ideas?

----------

## Erdie

If you dont get this solved, try powernowd. I made very good experience on Intel and AMD systems with this. One advantage is that it scales the cpu frequency independed on all cores.

----------

## BlueDragonX

I can confirm I'm having the same issue. Not sure what the problem is yet but I'm going to work towards a solution.

----------

## BlueDragonX

It looks like a new patch was integrated into 2.4.2-r1 without doing a version bump! They should have bumped it to r2.

Do an emerge --sync and re-emerge cpufreqd. If you're using a custom ebuild you'll need to integrated the MAX_PATH patch from the portage tree into your ebuild.

I was using a custom ebuild. It was a copy of the 2.4.2-r1 ebuild with an additional patch added in. When they added the new patch without doing a version bump mine broke, too.

Hope this helps.

----------

## WvR

 *BlueDragonX wrote:*   

> I can confirm I'm having the same issue. Not sure what the problem is yet but I'm going to work towards a solution.

 

That would be very interesting. The segfault of cpufreqd is a "well known" bug. It has something to do with an incompatible version of glibc. There was a discussion on one of the Gentoo bug tracking lists but I cannot find it at the moment. The basic conclusion was that unless the cpufreqd is patched, it will always segfault - unless you downgrade the system's glibc, which is not a sensible thing to do.

Personally, I have switched to cpufrequtils, works fine on my laptop (Lenovo Thinkpad X201i)

----------

## pd1986

Have you solved the problems? I have the same issue

----------

## gnujiri

hey. think, that i got it.

what i had:

 1] /etc/cpufreqd.conf properly configured

 2] when i start /usr/sbin/cpufreqd it works properly

 3] rc-update add cpufreqd default

 4] and the problem: it wasn't able to start daemon while booting

so i checked /etc/init.d/cpufreqd by vim, like this: 

```
#vim /etc/init.d/cpufreqd
```

found start() function

and there was line:

```
start-stop-daemon --start --exec /usr/sbin/cpufreqd -- \

-f ${CONFIGFILE}
```

in fact, this line runs command "/usr/sbin/cpufreqd -- -f /etc/cpufreqd.conf" which have problem with syntax, so..

because i dont need special config files for cpufreqd, i can make every changes in /etc/cpufreqd.conf, it means that i dont need the -f parameter and certainly i don't like -- parameter, which imho caused the error.

file /etc/init.d/cpufreqd after edit:

```
#!/sbin/runscript

# Copyright 1999-2009 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

# $Header: /var/cvsroot/gentoo-x86/sys-power/cpufreqd/files/cpufreqd-init.d,v 1.2 2009/10/20 10:21:34 bangert Exp $

CONFIGFILE=/etc/cpufreqd.conf

depend() {

   need localmount

   use logger lm_sensors

}

checkconfig() {

   if [[ ! -f ${CONFIGFILE} ]]; then

      eerror "Configuration file ${CONFIGFILE} not found"

      return 1

   fi

   if [[ ! -e /proc/cpufreq ]] ; then

      for cpu in /sys/devices/system/cpu/cpu[0-9]* ; do

                        # We need just one cpu supporting freq scaling.

                        [[ -e ${cpu}/cpufreq ]] && return 0

      done

      eerror "cpufreqd requires the kernel to be configured with CONFIG_CPU_FREQ"

      eerror "Make sure that the appropiate kernel drivers for your CPU are"

      eerror "built-in or loaded."

      return 1

   fi

}

start() {

   checkconfig || return 1

   ebegin "Starting CPU Frequency Daemon"

   start-stop-daemon --start --exec /usr/sbin/cpufreqd

   eend ${?}

}

stop() {

   ebegin "Stopping CPU Frequency Daemon"

   start-stop-daemon --stop --exec /usr/sbin/cpufreqd

   eend ${?}

}

```

the most important is edited start() function

hope that it will help you..

----------

## pd1986

 *gnujiri wrote:*   

> hey. think, that i got it.
> 
> what i had:
> 
>  1] /etc/cpufreqd.conf properly configured
> ...

 

sorry to reply late.

I tried. It truly starts but when I check the status, it give "crashed"

----------

## WvR

 *gnujiri wrote:*   

> because i dont need special config files for cpufreqd, i can make every changes in /etc/cpufreqd.conf, it means that i dont need the -f parameter and certainly i don't like -- parameter, which imho caused the error.

 

Well, you didn't "solve" the problem. You may have found a quick fix (or a "workaround") - you have cured the symptom but the underlying disease remains  :Very Happy: 

The problem with cpufreqd is exactly with the string handling functions which are used to manipulate file names, and somehow somewhere there is an error. Indeed, if you don't specify the log file then cpufreqd does not need to manipulate the file name and it will probably not crash.

However, until the string handling error is solved in the source of cpufreqd you have not solved the bug   :Smile: 

----------

## pd1986

 *WvR wrote:*   

>  *gnujiri wrote:*   because i dont need special config files for cpufreqd, i can make every changes in /etc/cpufreqd.conf, it means that i dont need the -f parameter and certainly i don't like -- parameter, which imho caused the error. 
> 
> Well, you didn't "solve" the problem. You may have found a quick fix (or a "workaround") - you have cured the symptom but the underlying disease remains 
> 
> The problem with cpufreqd is exactly with the string handling functions which are used to manipulate file names, and somehow somewhere there is an error. Indeed, if you don't specify the log file then cpufreqd does not need to manipulate the file name and it will probably not crash.
> ...

 

Thanks. Frankly speaking, I don't totally understand what you are talking about. I still don't know where I could start to fix the string error. In this case, waiting may be a choice. Anyway, everything that I do aims at fixing my fan problem. I have to try everything about power management to find where the problem is(still don't find it). In fact, I don't really need cpufreqd, as the cpu frequency control works well even without cpufreqd.

----------

## s_j_newbury

I've recently made patches for a couple of bugs:

Crash bug: https://bugs.gentoo.org/show_bug.cgi?id=410033

Multi-cpu bug: https://bugs.gentoo.org/show_bug.cgi?id=410037

cpufreqd is workiing fine for me with those applied.

----------

## pd1986

 *s_j_newbury wrote:*   

> I've recently made patches for a couple of bugs:
> 
> Crash bug: https://bugs.gentoo.org/show_bug.cgi?id=410033
> 
> Multi-cpu bug: https://bugs.gentoo.org/show_bug.cgi?id=410037
> ...

 

Thanks. One question.

Given that the status is marked "unconfirmed", does it mean that the patch hasn't been put into the cpufreqd package in the emerge tree? so that it will change nothing if I remerge cpufreqd from emerge tree?

----------

## theven

 *gnujiri wrote:*   

> because i dont need special config files for cpufreqd, i can make every changes in /etc/cpufreqd.conf, it means that i dont need the -f parameter and certainly i don't like -- parameter, which imho caused the error.
> 
> ```
> start-stop-daemon --stop --exec /usr/sbin/cpufreqd
> ```
> ...

 

Work for me, fix "crashes" in cpufreqd-2.4.2

----------

## gnumber9

editing this line 

```
start-stop-daemon --start --exec /usr/sbin/cpufreqd -- \ 

-f ${CONFIGFILE}

```

to be this line

```
start-stop-daemon --stop --exec /usr/sbin/cpufreqd
```

Also worked here. 

Sorry if i posted this in an old thread. however, i can now throttle my cpu with a command. which is nice.

[edit] this actually did not work. the program started, but once i set a governor the cpu would not throttle. too,  i could not return the cpu to any other speed with the command . so i did what i should have done in the first place and that was to have paid attention to the thread and then follow the gentoo wiki. my CPU now throttles as it should. [/edit]Last edited by gnumber9 on Mon Feb 03, 2014 2:45 pm; edited 2 times in total

----------

## Logicien

I do not have this problem.

In the past I ever had troubles with Cpufreqd on other distributions than Gentoo. So I stop to use it and just set the cpu frequency policy with Cpufrequtils. Recently, I came back to Cpufreqd on Debian and start using it with Gentoo too. After setting /etc/cpufreqd.conf properly to make Cpufreqd do what I want, it start, stop, restart and status normally on both systems. It is set to start at boot time and never fail. I got exactly what I set when I execute the cpufreqd-get command

```
cpufreqd-get

Name (#1):   Conservative

Active on CPU#:   0, 1

Governor:   conservative

Min freq:   1400000

Max freq:   2700000

Name (#2):   Powersave

Governor:   powersave

Min freq:   1400000

Max freq:   1400000
```

and Cpufreqd behave accordingly.  I never edit /etc/init.d/cpufreqd. ps and rc-service tell me

```
 ps aux|grep cpufreqd

root      2473  0.2  0.0  43816  1324 ?        Ssl  janv.29  13:31 /usr/sbin/cpufreqd -f /etc/cpufreqd.conf

gnu      26149  0.0  0.0  12356   960 pts/0    S+   20:00   0:00 grep --colour=auto cpufreqd
```

```
sudo rc-service cpufreqd status

 * status: started
```

These are my Cpufreqd and Glilc versions

```
 equery l cpufreqd glibc

 * Searching for cpufreqd ...

[IP-] [  ] sys-power/cpufreqd-2.4.2-r2:0

 * Searching for glibc ...

[IP-] [  ] sys-libs/glibc-2.17:2.2
```

----------

