<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56489>56489</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLDB crashes when loading core file due to divide-by-zero in ObjectFileELF::ParseSymbolTable()
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lldb
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Enna1
</td>
</tr>
</table>
<pre>
@Cossack9989 found a crash when fuzzing lldb.
This crash is cause by SIGFPE. a divide-by-zero bug occured if `symtab_hdr->sh_entsize` equals 0
https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp#L2350
A simple workaround approach is to add a non-zero check like this:
```patch
if (ReadSectionData(symtab, symtab_data) &&
ReadSectionData(strtab, strtab_data)) {
+ if (symtab_hdr->sh_entsize == 0)
+ return 0;
size_t num_symbols = symtab_data.GetByteSize() / symtab_hdr->sh_entsize;
return ParseSymbols(symbol_table, start_id, section_list, num_symbols,
symtab_data, strtab_data);
}
```
I'm not sure if this is the correct approach to fix this.
This can be reproduced with the attached bundle, [lldb-sigfpe.zip](https://github.com/llvm/llvm-project/files/9091047/lldb-sigfpe.zip), with ELF file and core file.
```
$ lldb -c corefile test
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVMlu2zAQ_Rr5QliQKS_SQYc4josCARo0vRtcRhYbWlRJqqn99R2STmIn6aEEIXHIWd8s3Mhjk82LW-McE091XdWkNWMvCSPCMteR5w560o6nk-r3RGvJ86zYZMVN-v7olDszhgMbHRB-JI9fv2wf7nJUItVvJWHKj9MTWEP4uCdGiNGCJKol2bJwx4NnfNdJO83KO9ftoPdOnQCfCPwamXakSLY67weXlTcZ3eLeK9-NPBfmgITWv19-08GanyA8klwbjr8DU318lIFyZrQC8PCgx73qHZ6-8SCwVTpc391vr66QzsUwZLS8p-WiuAz-hjh1GDSQZ2OfmE2wDWifiQiHN4TJgGRv-hS-6EA8Ea2egHhELgST9C2LtAfmRZfuCK4AEa2-A5OP6I4y_YZ5hjcJtIzekjN8Mt7XyL0M-1VBWJ-Ie_siHk8v4lHDan32ia6TfHLiX3kiWbnBjUlC-WtBYsGPtsencn3pUhDbedKPhx1q5QZTHDRchJJ_Ab8-engMhUCrFNmW_LNWXvRfWjkbf2DWwWMyk8LA0w7VhGwHAJj1OyXjOYG008r5QF84iOQ1qB_XVSY-IHuJQLbavEt7Ir9mdHXAYvHEYYME3EORxErqgAhjLTr4VmFYXq36E3k-6UnWEw4IAjLLUWC7PWPDREXMexTHG44Fm1DIFuvQHlOn9u0A-UkN2WKDaP13y7XYMaGl6qKeFfPVue0u9YYqu03OYGuRIEAYNg6GB5HKP8Umo_M4fchURNYo5wET9Sl3_E5kU8q6rNnEK6-hub_frNOwApfmmjZMhrn2apzIEQKw78aW6snVRAiQlDcXpfUj1VOo1MlodfPfwCnnxojcYjmv6knXgJiLklK2kEIsKlaVy9W85PWqbUUFBZQTzTho12DqMkrTcKOYtYlqaEFpsZrRoqLVbJFzBu2qgnImBZdVMcNxDzgTdR5cyI3dT2wTvcHh7PAxlL97e2QOs9cDREuon42-M7a563s2m0S3m-jzXxQ69sw">