Skip to content

Commit

Permalink
Fix #4469 (#4473)
Browse files Browse the repository at this point in the history
* Fix #4469

Errors now look like:

```
Internal Compiler Explorer error: Error: Internal error running asm parser:
./dump-and-parse.sh: line 4: /usr/local/bin/asm-parser: No such file or directory

    at CEAsmParser.parseAsmExecResult (/home/matthew/dev/ce/compiler-explorer/lib/external-parsers/base.ts:77:19)
    at CEAsmParser.objdumpAndParseAssembly (/home/matthew/dev/ce/compiler-explorer/lib/external-parsers/base.ts:101:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async DefaultCompiler.objdump (/home/matthew/dev/ce/compiler-explorer/lib/base-compiler.ts:414:31)
    at async Promise.all (index 0)
    at async DefaultCompiler.checkOutputFileAndDoPostProcess (/home/matthew/dev/ce/compiler-explorer/lib/base-compiler.ts:1356:16)
    at async /home/matthew/dev/ce/compiler-explorer/lib/base-compiler.ts:2236:41
    at async run (/home/matthew/dev/ce/compiler-explorer/node_modules/p-queue/dist/index.js:163:29)
Compiler returned: -1
```

which at least gives context on why the parsing failed. And per discussion with @partouf we'll blow up at construction time if the file isn't there, which means the above is more to cover "what if the tool dies".
  • Loading branch information
mattgodbolt committed Dec 20, 2022
1 parent 6348917 commit 9f29543
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/external-parsers/base.ts
Expand Up @@ -4,6 +4,7 @@ import path from 'path';
import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces';
import {TypicalExecutionFunc, UnprocessedExecResult} from '../../types/execution/execution.interfaces';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces';
import {logger} from '../logger';
import {maskRootdir} from '../utils';

import {IExternalParser} from './external-parser.interface';
Expand All @@ -22,6 +23,10 @@ export class ExternalParserBase implements IExternalParser {
this.envInfo = envInfo;
this.objdumperPath = compilerInfo.objdumper;
this.parserPath = compilerInfo.externalparser.props('exe', '');
if (!fs.existsSync(this.parserPath)) {
logger.error(`External parser ${this.parserPath} does not exist`);
process.exit(1);
}
this.execFunc = execFunc;
}

Expand Down Expand Up @@ -73,6 +78,9 @@ export class ExternalParserBase implements IExternalParser {
}

private parseAsmExecResult(execResult: UnprocessedExecResult): ParsedAsmResult {
if (execResult.code !== 0) {
throw new Error(`Internal error running asm parser: ${execResult.stdout}\n${execResult.stderr}`);
}
const result = Object.assign({}, execResult, JSON.parse(execResult.stdout));
delete result.stdout;
delete result.stderr;
Expand Down

0 comments on commit 9f29543

Please sign in to comment.