9

After upgrading to geth 1.4.4 I am no longer able to from to reference the compiler from geth.

The solc compiler is installed in /usr/local/bin but this is what I get when I check for available compilers:

> eth.getCompilers();
I0520 10:22:45.501340 common/compiler/solidity.go:114] solc, the solidity compiler commandline interface
Version: 0.3.2-7a51852a/Release-Darwin/appleclang/JIT

path: /usr/local/bin/solc

[]

Then I try to set the compiler path again:

> admin.setSolc("/usr/local/bin/solc")
I0520 10:25:49.234999 common/compiler/solidity.go:114] solc, the solidity compiler commandline interface
Version: 0.3.2-7a51852a/Release-Darwin/appleclang/JIT

path: /usr/local/bin/solc
"solc, the solidity compiler commandline interface\nVersion: 0.3.2-7a51852a/Release-Darwin/appleclang/JIT\n\npath: /usr/local/bin/solc"

When I check the compilers again I still get:

> eth.getCompilers();
[]

I get the same using:

> web3.eth.getCompilers();
[] 

I have reinstalled go-ethereum, npm.

Can anybody give me a hint of what to do or where to look to look.

I had no problems before upgrading to geth 1.4.4

Thanks in advance

4

Summary

Segmentation fault with solc version 0.3.2-7a51852a/Release-Darwin/appleclang/JIT , fixed with later updated version.

UPDATE 26/06/2016

This is a bug in the Solidity compiler.

Here is a quick test:

user@Kumquat:~$ echo '' | solc
Unknown exception during compilation.

See eth.compile.solidity fails with solc version 0.3.5 #2703, which links to Exception on compilation from stdin #651.

And the issue Fix crash for input from stdin. #652 has been fixed, but will take an unknown (hopefully short) amount of time to make it into the repository packages.

This is the code change for the fix - Fix crash for input from stdin. #652 - Files changed.

You can try installing the previous version of solc.

Or one workaround offered in the first link above:

For anyone who wants a temporary workaround, you can clone this repo: https://github.com/mattdf/solidity-static and do a build in docker, then copy the solc file to your install. It makes a statically compiled build of solc so it should work on most distros.



Details

Check Solidity Compiler Within geth

I just checked by installation (Linux) and the output that you are getting is consistent with the output I get, but the compiler works correctly.

Run the test below to check if your compiler is configured correctly.

I'm using the following code:

contract Test { 
    function double(int a) constant returns(int) {
        return 2*a;
    } 
}

I've flattened the code above to:

> var testSource='contract Test {  function double(int a) constant returns(int) { return 2*a; } }'
undefined

I've tried compiling the code using the following statement:

> var testCompiled = web3.eth.compile.solidity(testSource);
undefined

And checked the results of the compilation:

> testCompiled
{
  Test: {
    code: "0x6060604052602a8060106000396000f3606060405260e060020a60003504636ffa1caa8114601a575b005b6002600435026060908152602090f3",
    info: {
      abiDefinition: [{...}],
      compilerOptions: "--bin --abi --userdoc --devdoc --add-std --optimize -o /tmp/solc935251869",
      compilerVersion: "0.3.2",
      developerDoc: {
        methods: {}
      },
      language: "Solidity",
      languageVersion: "0.3.2",
      source: "contract Test {  function double(int a) constant returns(int) { return 2*a; } }",
      userDoc: {
        methods: {}
      }
    }
  }
}

And if you want to check if the code runs correctly:

> var testContract = web3.eth.contract(testCompiled.Test.info.abiDefinition);
var test = testContract.new({
    from:web3.eth.accounts[0], 
    data: testCompiled.Test.code, gas: 2000000}, 
    function(e, contract) {
      if (!e) {
        if (!contract.address) {
          console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
        } else {
          console.log("Contract mined! Address: " + contract.address);
          console.log(contract);
        }
    }
})
...
Contract mined! Address: 0x5e3361efa79827d8a53a397b454770c6816585d7
> test.double(5)
10


Check Solidity Compiler

If you are still encountering problems, let's try compiling the source code outside geth.

Save the following code into Test.sol:

contract Test { 
    function double(int a) constant returns(int) {
        return 2*a;
    } 
}

From your terminal, you should be able to run the following commands if your solidity compiler is working correctly:

user@Kumquat:~$ solc --bin Test.sol

======= Test =======
Binary: 
606060405260728060106000396000f360606040526000357c0100000000000000000000000000000000000000000000000000000000900480636ffa1caa146037576035565b005b604b60048080359060200190919050506061565b6040518082815260200191505060405180910390f35b6000816002029050606d565b91905056

user@Kumquat:~$ solc --abi Test.sol

======= Test =======
Contract JSON ABI
[{"constant":true,"inputs":  [{"name":"a","type":"int256"}],"name":"double","outputs":[{"name":"","type":"int256"}],"type":"function"}]

If the commands above do not produce similar output, there is something not quite right with your solc binary.


Check web3.js

You have an error message that includes the text web3.js. The problem could be with this module. I'll update when I've researched it a bit more.

  • Hi, Thanks ofr answer. I am getting an error when I try to compile: "solc: signal: segmentation fault at web3.js:3119:20 at web3.js:6023:15 at web3.js:4995:36 at <anonymous>:1:20 >" – Starfish May 20 '16 at 9:22
  • Just confirming that you are not adding the > at the beginning of each statement? This is the prompt in geth. – Bokky WeAreAllAssange PooBah May 20 '16 at 9:24
  • Hi, I have compiled many contracts before. So no problem with that :-) – Starfish May 20 '16 at 9:25
  • I have also reinstalled cpp-ethereum (which installs the solc). I think it may be a problem with the node.js but not sure – Starfish May 20 '16 at 9:28
  • Yup. Can you check that you can compile the code from your command line (outsite geth)? – Bokky WeAreAllAssange PooBah May 20 '16 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.