public inbox for frysk-bugzilla@sourceware.org
help / color / mirror / Atom feed
* [Bug general/4777] New: fd smash from Elf exception
@ 2007-07-11 17:09 cagney at redhat dot com
  2007-07-12 14:17 ` [Bug general/4777] " pmuldoon at redhat dot com
  2007-07-12 22:45 ` cagney at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: cagney at redhat dot com @ 2007-07-11 17:09 UTC (permalink / raw)
  To: frysk-bugzilla

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1741 bytes --]

modifying lib.elf.cni.Elf.cxx to throw an uncaught exception when the open fails
causes this behavior on FC 5:

$  /home/scratch/frysk/native/frysk-core/frysk/bindir/fhpd $$
Attached to process 3891
\x03EL4ûELFFF
Error: Unrecognized command: À\x03EL4û.
(fhpd) 4(\x1f\x1e44pException in thread "main" java.lang.NullPointerException
   at frysk.debuginfo.DebugInfo.complete(fhpd)
   at frysk.cli.hpd.CLI.complete(fhpd)
   at frysk.bindir.fhpd$FhpdCompletor.complete(fhpd)
   at jline.ConsoleReader.complete(fhpd)
   at jline.ConsoleReader.readLine(fhpd)
   at jline.ConsoleReader.readLine(fhpd)
   at frysk.bindir.fhpd.main(fhpd)

and under TestRunner:

$  /home/scratch/frysk/native/frysk-core/TestRunner -c FINE
'testHpdCommand(frysk.bindir.TestFhd)'

11-Jul-07 1:05:51 PM frysk.expunit.Expect expectMilliseconds
FINE: frysk.expunit.Expect@3abb40 poll -> <<PtyTerminal.<init>(fhpd)
   at frysk.bindir.fhpd.main(fhpd)
>> giving <<Exception in thread "main" tcsetattr: Bad file descriptor (fd 0)
   at frysk.sys.termios.Termios.get(fhpd)
   at frysk.sys.termios.Termios.<init>(fhpd)
   at frysk.util.PtyTerminal.initializeTerminal(fhpd)
   at frysk.util.PtyTerminal.<init>(fhpd)
   at frysk.bindir.fhpd.main(fhpd)
>>

-- 
           Summary: fd smash from Elf exception
           Product: frysk
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: general
        AssignedTo: frysk-bugzilla at sourceware dot org
        ReportedBy: cagney at redhat dot com
                CC: pmuldoon at redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=4777

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug general/4777] fd smash from Elf exception
  2007-07-11 17:09 [Bug general/4777] New: fd smash from Elf exception cagney at redhat dot com
@ 2007-07-12 14:17 ` pmuldoon at redhat dot com
  2007-07-12 22:45 ` cagney at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pmuldoon at redhat dot com @ 2007-07-12 14:17 UTC (permalink / raw)
  To: frysk-bugzilla


------- Additional Comments From pmuldoon at redhat dot com  2007-07-12 14:17 -------
The problem is in part the way the Elf object is being used in various parts of
Frysk's code like this:

        try {
            elf = new Elf(proc.getExe(), ElfCommand.ELF_C_READ);
            dwarf = new Dwarf(elf, DwarfCommand.READ, null);
        }
        catch (lib.elf.ElfException ignore) {
            // FIXME: Why is this ignored?
        }

The problem here is two-fold. The elf exception should be caught in it's own
try, not in a composite try block and dealt with. And the code should fail at
that point. Also fd = 0 was a poor choice of an initial value in the Elf's
native code.

The other part if that that Elf object is not valid, yet still allows access to
the native sections. In Java, a constructor is never allowed to return null, so
I suggest we gate further calls with a boolean gate. something like
nativeSuccess = true.


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4777

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug general/4777] fd smash from Elf exception
  2007-07-11 17:09 [Bug general/4777] New: fd smash from Elf exception cagney at redhat dot com
  2007-07-12 14:17 ` [Bug general/4777] " pmuldoon at redhat dot com
@ 2007-07-12 22:45 ` cagney at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: cagney at redhat dot com @ 2007-07-12 22:45 UTC (permalink / raw)
  To: frysk-bugzilla


------- Additional Comments From cagney at redhat dot com  2007-07-12 22:44 -------
This replaces the integer file descriptor with a FileDescriptor object;
eliminating the possability of the uninitialized fd=0 being closed :-)

Index: frysk-imports/lib/elf/ChangeLog
2007-07-12  Andrew Cagney  <cagney@redhat.com>

        * Elf.java (fd): Change type to FileDescriptor.
        (elfBegin): Declare.
        (Elf(String,ElfCommand)): Use FileDescriptor and elfBegin.
        (Elf(int,ElfCommand): Use this to construct Elf object.
        * cni/Elf.cxx (elfBegin): Define.
        (elf_begin): Delete.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://sourceware.org/bugzilla/show_bug.cgi?id=4777

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-12 22:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-11 17:09 [Bug general/4777] New: fd smash from Elf exception cagney at redhat dot com
2007-07-12 14:17 ` [Bug general/4777] " pmuldoon at redhat dot com
2007-07-12 22:45 ` cagney at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).