Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327507 - MemoryProxy not properly processing non-zero offsets in range containing multiple entries
Summary: MemoryProxy not properly processing non-zero offsets in range containing mult...
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 critical (vote)
Target Milestone: 0.4.0   Edit
Assignee: Project Inbox CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-12 02:27 EDT by Kirk Beitz CLA
Modified: 2013-06-05 07:56 EDT (History)
2 users (show)

See Also:


Attachments
bugfix to subtract original address from error address to get offset (includes changes found in patch in Bug 326270) (927 bytes, patch)
2010-10-12 02:27 EDT, Kirk Beitz CLA
eugene: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kirk Beitz CLA 2010-10-12 02:27:11 EDT
Created attachment 180635 [details]
bugfix to subtract original address from error address to get offset (includes changes found in patch in Bug 326270)

org.eclipse.tm.internal.tcf.services.remote.MemoryProxy.MemoryErrorReport.MemoryErrorReport() appears to contain a bug w.r.t. the processing of addresses that are offset from the originally requested address passed as a parameter to org.eclipse.tm.internal.tcf.services.remote.MemoryProxy.MemContext.get() .

this snippet of code (also seen in the attached patch) appears to be incorrect:

                BigInteger addr_bi = addr instanceof BigInteger ?
                        (BigInteger)addr : new BigInteger(addr.toString());
                for (Map<String,Object> m : c) {
                    Range r = new Range();
                    Number x = (Number)m.get(RANGE_KEY_ADDR);
                    BigInteger y = x instanceof BigInteger ?
                            (BigInteger)x : new BigInteger(x.toString());
this call =======>  r.offs = y.subtract(addr_bi).intValue();
                    r.size = ((Number)m.get(RANGE_KEY_SIZE)).intValue();
                    r.stat = ((Number)m.get(RANGE_KEY_STAT)).intValue();
                    r.msg = Command.toErrorString(m.get(RANGE_KEY_MSG));
causes this =====>  assert r.offs >= 0;
to fire the         assert r.size >= 0;
second time         this.ranges[n++] = r;
thru the loop   }

it would seem to be more appropriate to have it be

better ==========>  r.offs = addr_bi.subtract(y).intValue();

making this a critical due to it blocking the ability to implement an agent mechanism to send back address blocks in a single TCF message that are at appropriate offests.
Comment 1 Kirk Beitz CLA 2010-10-12 02:31:00 EDT
arrgh … why can't you edit own mistakes in bugzilla?!?

the bad snippet and the better substitution in the description are inverted!!!


try the following instead:

this snippet of code (also seen in the attached patch) appears to be incorrect:

                BigInteger addr_bi = addr instanceof BigInteger ?
                        (BigInteger)addr : new BigInteger(addr.toString());
                for (Map<String,Object> m : c) {
                    Range r = new Range();
                    Number x = (Number)m.get(RANGE_KEY_ADDR);
                    BigInteger y = x instanceof BigInteger ?
                            (BigInteger)x : new BigInteger(x.toString());
this call =======>  r.offs = addr_bi.subtract(y).intValue();
                    r.size = ((Number)m.get(RANGE_KEY_SIZE)).intValue();
                    r.stat = ((Number)m.get(RANGE_KEY_STAT)).intValue();
                    r.msg = Command.toErrorString(m.get(RANGE_KEY_MSG));
causes this =====>  assert r.offs >= 0;
to fire the         assert r.size >= 0;
second time         this.ranges[n++] = r;
thru the loop   }


it would seem to be more appropriate to have it be

better ==========>  r.offs = y.subtract(addr_bi).intValue();
Comment 2 Eugene Tarassov CLA 2010-10-12 19:37:54 EDT
subtract() method has a mystical power to get its arguments inverted :-)
Yes, it a bug. I have committed the patch.
Thanks!
Comment 3 Doug Schaefer CLA 2011-05-17 10:49:47 EDT
Moving bugs to new home for IP log.
Comment 4 Martin Oberhuber CLA 2013-06-05 06:27:17 EDT
Bulk change: Marking all bugs from the TM era (until June 2011) target 0.3