Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use-after-free bug in typeCode #9261

Merged
merged 1 commit into from May 28, 2015

Conversation

davidlt
Copy link
Contributor

@davidlt davidlt commented May 25, 2015

edm::TypeWithDict::name() returns a std::string. The code was
taking a pointer to temporary string. Thus causing CutParser to
fail depending on random values in memory.

GDB output below. Memory pattern was set to 0x04, thus the name is just a sequence of 0x04.

Breakpoint 3, reco::parser::ExpressionVarSetter::push (this=0x12fda930,
    begin=0x12fd7b58 "strip < 400000 && pixel < 40000 && (strip < 50000 + 10*pixel) && (pixel < 5000 + 0.1*strip)",
    end=0x12fd7b5d " < 400000 && pixel < 40000 && (strip < 50000 + 10*pixel) && (pixel < 5000 + 0.1*strip)")
    at /build/davidlt/debug/CMSSW_7_5_0_pre4/src/CommonTools/Utils/src/ExpressionVarSetter.cc:17
17        edm::TypeWithDict type = typeStack_.back();
(gdb) n
18        method::TypeCode retType = reco::typeCode(type);
(gdb) p type
$25 = {ti_ = 0x7ffff6546b20 <typeinfo for int>, class_ = 0x0, enum_ = 0x0, dataType_ = 0x3a0fd10, arrayDimensions_ = {myP = 0x0}, property_ = 0}
(gdb) s
reco::typeCode (t=...) at /build/davidlt/debug/CMSSW_7_5_0_pre4/src/CommonTools/Utils/src/returnType.cc:46
46          const char* name = t.name().c_str();
(gdb) n
51            });
(gdb) p name
$26 = 0x12fda128 '\004' <repeats 16 times>, "\061"
----- Begin Fatal Exception 25-May-2015 10:35:59 CEST-----------------------
An exception of category 'Configuration' occurred while
   [0] Constructing the EventProcessor
   [1] Constructing module: class=SeedGeneratorFromRegionHitsEDProducer label='initialStepSeedsPreSplitting'
Exception Message:
Cut parser error:member "strip" has an invalid return type: "int" (char 0)
----- End Fatal Exception -------------------------------------------------

Signed-off-by: David Abdurachmanov David.Abdurachmanov@cern.ch

`edm::TypeWithDict::name()` returns a `std::string`. The code was
taking a pointer to temporary string. Thus causing CutParser to
fail depending on random values in memory.

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
@cmsbuild
Copy link
Contributor

A new Pull Request was created by @davidlt for CMSSW_7_5_X.

Fix use-after-free bug in typeCode

It involves the following packages:

CommonTools/Utils

@nclopezo, @cvuosalo, @monttj, @cmsbuild, @slava77, @vadler can you please review it and eventually sign? Thanks.
@makortel this is something you requested to watch as well.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.
If you are a L2 or a release manager you can ask for tests by saying 'please test' in the first line of a comment.
@nclopezo you are the release manager for this.
You can merge this pull request by typing 'merge' in the first line of your comment.

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

@Dr15Jones
Copy link
Contributor

Do we need the same fix in 7_4?

@Dr15Jones
Copy link
Contributor

+1

@wmtan
Copy link
Contributor

wmtan commented May 25, 2015

This bug was introduced in 7_4_X, and should be fixed there as well. The same bug occurs in the ROOT5 versions of 7_4_X and 7_5_X, so the fixes should be carried forward to the ROOT5 branches, as is normally done.

@slava77
Copy link
Contributor

slava77 commented May 27, 2015

@davidlt David, could you please make a PR for 74X as well.
Thank you.

@slava77
Copy link
Contributor

slava77 commented May 27, 2015

+1

for #9261 1ef5ad9

  • this is a somewhat technical change
  • jenkins tests pass and comparisons with the baseline show no differences

@davidlt
Copy link
Contributor Author

davidlt commented May 28, 2015

This is a technical change. It extends lifetime of a std::string. It does nothing more, thus there should be no differences (unless you were unlucky and previously that string was a garbage).

@davidlt
Copy link
Contributor Author

davidlt commented May 28, 2015

7_4_X: #9310

davidlange6 added a commit that referenced this pull request May 28, 2015
@davidlange6 davidlange6 merged commit 381b37e into cms-sw:CMSSW_7_5_X May 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants