This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] -Wwrite-strings: Fix Solaris "set procfs-file"


*** TEST RESULTS FOR COMMIT 3e83a920090130052a407621b94b94513f539fda ***

Author: Pedro Alves <palves@redhat.com>
Branch: master
Commit: 3e83a920090130052a407621b94b94513f539fda

-Wwrite-strings: Fix Solaris "set procfs-file"

Compiling GDB with -Wwrite-strings flags this code in gdb/proc-api.c:

  static char *procfs_filename = "procfs_trace";

as needing a cast.  However, this variable is a command variable, and
as such it's incorrect to initialize it to a literal, since when you
use the corresponding set command, gdb frees the old string...

I didn't manage to fully build Solaris gdb (fails for other reasons),
but I confirmed that the system GDB on Solaris 11 crashes when running
this command:

 (gdb) set procfs-file foo
 Segmentation Fault (core dumped)

So I don't think this commit can make it worse than the status quo.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

	* proc-api.c (procfs_filename): Don't initialize
        procfs_filename.
	(prepare_to_trace): Assume procfs_filename is non-NULL.
	(_initialize_proc_api): Give procfs_filename a default value here.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]