Bug 362223 - assertion failed when .valgrindrc is a directory instead of a file
Summary: assertion failed when .valgrindrc is a directory instead of a file
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.10.0
Platform: Mint (Ubuntu based) Linux
: NOR crash
Target Milestone: ---
Assignee: Ivo Raisr
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-25 09:09 UTC by nickolayzhosov
Modified: 2017-05-12 01:39 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
strace valgrind report (8.29 KB, text/plain)
2016-04-25 10:24 UTC, nickolayzhosov
Details
strace without sortby (6.74 KB, text/plain)
2016-04-25 10:27 UTC, nickolayzhosov
Details
proposed patch (3.23 KB, patch)
2017-05-11 08:38 UTC, Ivo Raisr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nickolayzhosov 2016-04-25 09:09:14 UTC
-The error appeared than I typed:

valgrind asan locate

-And I got the message:

valgrind: m_commandline.c:79 (read_dot_valgrindrc): Assertion 'n >= 0 && n <= stat_buf.size+1' failed.

-After this error appears each time I try to use valgrind with or without any keys or arguments. Package reinstall didn't solve the problem.

-Also I tried to install valgrind-3.11.0. Trying to use valgrind  I recieve the message:

valgrind: m_commandline.c:79 (read_dot_valgrindrc): Assertion 'n >= 0 && n <= stat_buf.size+1' failed.

- uname -a: Linux nick-virtual-machine 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Comment 1 nickolayzhosov 2016-04-25 09:20:36 UTC
-Attention!
-The version of valgrind is 3.10.1 and full message was:

valgrind: m_commandline.c:77 (read_dot_valgrindrc): Assertion 'n >= 0 && n <= stat_buf.size+1' failed.

host stacktrace:
==10093==    at 0x3805DB16: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)

sched status:
  running_tid=0


Note: see also the FAQ in the source distribution.
It contains workarounds to several common problems.
In particular, if Valgrind aborted or crashed after
identifying problems in your program, there's a good chance
that fixing those problems will prevent Valgrind aborting or
crashing, especially if it happened in m_mallocfree.c.

If that doesn't help, please report this bug to: www.valgrind.org

In the bug report, send all the above text, the valgrind
version, and what OS and version you are using.  Thanks.

-For the 3.11.0 message was one line, represented in first report.
Comment 2 Tom Hughes 2016-04-25 10:08:09 UTC
This doesn't really make any sense - it appears that read() has returned more bytes than stat() says exist in the file!

How big is your .valgrindrc file?

Can you strace valgrind and attach the trace?
Comment 3 nickolayzhosov 2016-04-25 10:24:38 UTC
Created attachment 98581 [details]
strace valgrind report
Comment 4 nickolayzhosov 2016-04-25 10:27:40 UTC
Created attachment 98582 [details]
strace without sortby
Comment 5 nickolayzhosov 2016-04-25 10:29:44 UTC
Size of  ./.valgrindrc is 4,0K
Comment 6 Tom Hughes 2016-04-25 13:10:34 UTC
Well 4K seems extremely large, but it seems the real problem is that your .valgrindrc is a directory:

read(3, 0x802001230, 4096)              = -1 EISDIR (Is a directory)

It is supposed to be a file...
Comment 7 nickolayzhosov 2016-04-25 14:51:54 UTC
Ok. It seems like this is neither directory as cd doesn't see it nor regular file as mcedit can't open it (with error "it's not a regular file").

 After deletion of valgrind, the folder still exists. I tried to move it and install the package again. Caught the same message.

!Found some strange solution:
I renamed this thing just as valgrind and moved to /home, also restarted system (needed as terminal couldn't find the command valgrind). Now, it works. Also I can open the moved folder and it is empty.
The question is should I delete it or keep on disk, as I couldn't find the .valgrindrc file?
Comment 8 Tom Hughes 2016-04-25 15:06:07 UTC
Well it's a bug that valgrind crashes when .valgrindrc is a folder, but the easy workaround is for you to remove that folder (it serves no purpose - firstly because .valgrindrc is optional and secondly because it should be a file).

If you can't delete it then it suggests you have filesystem corruption and you should probably fsck your filesystem.

The .valgrindrc is nothing to do with valgrind itself, so removing valgrind was neither necessary not appropriate really. The .valgrindrc file is just somewhere where you can put configuration options to be applied by default whenever you run valgrind. It's not owned by your system's valgrind package (or at least it shouldn't be...) but rather is something you would normally create yourself.
Comment 9 nickolayzhosov 2016-04-25 15:12:42 UTC
Ok, thanks for help and explanation. I deleted it without any problem
.
Can I ask you some question about usage of valgrind (everything crached as I was trying to find how to use valgrind to check my programme)?
Comment 10 Tom Hughes 2016-04-25 15:33:38 UTC
Please use the mailing lists for general questions - it's not really appropriate for the bug tracker. See http://valgrind.org/support/mailing_lists.html for more information.
Comment 11 nickolayzhosov 2016-04-25 15:35:45 UTC
Ok. Thank you.
Comment 12 Ivo Raisr 2017-05-11 08:38:36 UTC
Created attachment 105438 [details]
proposed patch
Comment 13 Julian Seward 2017-05-11 14:55:40 UTC
(In reply to Ivo Raisr from comment #12)
> Created attachment 105438 [details]
> proposed patch

Looks OK to me.
Comment 14 Ivo Raisr 2017-05-11 17:00:45 UTC
Committed in Valgrind SVN as r16364.
Comment 15 Ivo Raisr 2017-05-12 01:39:07 UTC
Follow up commit SVN r16366.