Skip to content

Conversation

@axic
Copy link
Contributor

@axic axic commented Feb 5, 2017

Fixes #583.

@axic axic requested a review from chriseth February 6, 2017 11:11
@chriseth
Copy link
Contributor

chriseth commented Feb 6, 2017

I think both the changelog, the error description and the implementation should be changed to:

Warn only if this.f() is used, i.e. both this and this.f are fine. It would also be great to include functions called from the constructor (i.e. record function calls like this.f() while traversing the tree together with the function they are used in and then compile a report in the endVisit function of the contract).

@axic axic changed the title Warn if using this in constructor WIP: Warn if using this in constructor Feb 7, 2017
@axic axic changed the title WIP: Warn if using this in constructor [WIP] Warn if using this in constructor Feb 7, 2017
@axic axic force-pushed the this-in-constructor branch from fcc05ef to c3a3941 Compare March 15, 2017 22:25
@axic
Copy link
Contributor Author

axic commented Mar 15, 2017

Rebased for good measure.

@axic
Copy link
Contributor Author

axic commented May 3, 2017

@roadriverrail would you be interested in working on this?

@axic axic force-pushed the this-in-constructor branch 2 times, most recently from f239592 to 529a8ec Compare May 3, 2017 18:51
@roadriverrail
Copy link
Contributor

@axic Yes, I'll look into this soon

@roadriverrail
Copy link
Contributor

With all my other stuff done or gated only on questions about style, I'm now actively working on this. I'm late to the party, but it seems like we would like to do the following:

  1. Identify all function calls made in constructor, and all function calls that those functions call, etc.
  2. Determine if any of these functions ever perform a this.foo( ) style call.
  3. Report it as a warning.

Yes?

@axic axic force-pushed the this-in-constructor branch from 529a8ec to b2279fa Compare May 23, 2017 09:54
@axic
Copy link
Contributor Author

axic commented May 30, 2017

@roadriverrail seems correct. The problem here is that while the contract address (this) and function types (this.f) are valid, but the contract at the destination is not yet present, so calling it results in failure. That is what we're warning for.

@roadriverrail
Copy link
Contributor

@axic after talking with @chriseth earlier in the week, I'd effectively be building up a call graph for the contract for the purposes of implementing this analysis fully. We really ought to have a general-purpose call graph and then make the "no this in constructor call tree" part implemented on top of that, rather than building up a call graph for a single purpose. As such, and because there's a lot of enthusiasm for other things I'm working on, @chriseth and I agreed that I'd actually get this working for calls through this directly in the constructor and leave checking functions called by the constructor for later. There are some commits already here, so I'll look into finishing them up and writing tests for them. Perhaps we should break off the rest of the work to a separate issue in the issue tracker?

@chriseth please correct me if I'm wrong about any of that.

@roadriverrail
Copy link
Contributor

Hey...the source branch for this PR is on the ethereum/solidity remote, which I can't push to. I can push it over to my remote, but that will cause a separate PR. Since I'm going to be leaving this work soon to work on other things, maybe I could just get push access to ethereum/solidity for a little while so I can put the clean up and rebase in? There's not much else to do, if we're not going to work on things that require a call graph to do.

@axic
Copy link
Contributor Author

axic commented Jul 19, 2017

@roadriverrail if you would like to work on this, feel free to open a new PR and we can close this one.

@roadriverrail
Copy link
Contributor

roadriverrail commented Jul 19, 2017 via email

@roadriverrail
Copy link
Contributor

Obviated by pull request #2605

@axic axic closed this Jul 19, 2017
@axic axic deleted the this-in-constructor branch July 19, 2017 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants