question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue loading binary with exceptions

See original GitHub issue

Heyo! So I was curious to see how angr/cle parses exceptions so I have this library:

#include <iostream>

class DinosaurException { 

public:
    int i;
    DinosaurException() {}
    ~DinosaurException() {}
};

void throw_the_exception(bool throwit) {
    if (throwit) {
        throw DinosaurException();
    }
}

void hello_dinosaur() {
    std::cout << "Hello Dinosaur!" << std::endl;
}

void log(unsigned int count) {
    std::cout << count << std::endl;
}

void catch_the_exception() {
    log(0);
    try {
        log(1);
        hello_dinosaur();
        throw_the_exception(true);
        log(2);
    } catch (const DinosaurException& e) {        
        log(3);
    }

    // more catch statements here
    log(4);
}

int main() {
    catch_the_exception();
    return 0;
}

And then I build it:

g++ -g -c exception.cpp

And then try to load it:

import cle
path = sys.argv[1]
if not os.path.exists(path):
    sys.exit('%s does not exist' % path)
ld = cle.Loader(path, load_debug_info=True, auto_load_libs=False)

And I get the following error:

Traceback (most recent call last):
  File "dev.py", line 11, in <module>
    ld = cle.Loader(path, load_debug_info=True, auto_load_libs=False)
  File "/home/vanessa/Desktop/Code/cle/cle/loader.py", line 133, in __init__
    self.initial_load_objects = self._internal_load(main_binary, *preload_libs, *force_load_libs, preloading=(main_binary, *preload_libs))
  File "/home/vanessa/Desktop/Code/cle/cle/loader.py", line 673, in _internal_load
    obj = self._load_object_isolated(main_spec)
  File "/home/vanessa/Desktop/Code/cle/cle/loader.py", line 855, in _load_object_isolated
    result = backend_cls(binary, binary_stream, is_main_bin=self.main_object is None, loader=self, **options)
  File "/home/vanessa/Desktop/Code/cle/cle/backends/elf/elf.py", line 178, in __init__
    self._load_exception_handling(dwarf)
  File "/home/vanessa/Desktop/Code/cle/cle/backends/elf/elf.py", line 540, in _load_exception_handling
    lsda_exception_table = lsda.parse_lsda(entry.lsda_pointer, file_offset)
  File "/home/vanessa/Desktop/Code/cle/cle/backends/elf/lsda.py", line 97, in parse_lsda
    header = self._parse_lsda_header()
  File "/home/vanessa/Desktop/Code/cle/cle/backends/elf/lsda.py", line 127, in _parse_lsda_header
    raise NotImplementedError("Unsupported modifier %#x." % modifier)
NotImplementedError: Unsupported modifier 0xf0.

I’m guessing there is something specific about my example program (e.g., the “unsupported modifier” I see above) and for the time being I’ll try to inspect exceptions in another program! But I’m wondering what the specific issue is above and if I can fix it?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rhelmotcommented, Aug 22, 2022

Yes - since we’re hardcoding properties about the binaries themselves in our testcases (occasionally to the level of individual instruction addresses), we can’t rely on compilers to not change this stuff out from under us!

The expectation is that the binaries repository is cloned into the same directory that cle or angr or whatever is. We have the angr-dev repository to set up this structure. The testcases manually reach outside their repository to get to these files. Here is a good example of a testcase using that model.

1reaction
rhelmotcommented, Jun 4, 2022

we generally like tests that are as end-to-end as possible around here, so if you have some notion of a set of “in the wild” inputs and a way to validate the outputs of processing those inputs, that would be totally acceptable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception in reading a binary file - java - Stack Overflow
I am getting this exception. Is it because I am not catching them? java.io.EOFException at java.io.ObjectInputStream$BlockDataInputStream.
Read more >
IOException when trying to load from binary file - CodeRanch
I have log.dat binary file to store some application data in it. It is stored in applicationdata package.
Read more >
Java Exception Handling-Custom Exception Classes,Writing ...
Also included in this video is the basics of working with binary files! ... Exception Classes,Writing to binary files, Reading binary files.
Read more >
Why we use try and except in Binary Files? - YouTube
In this video, you will understand the concept of Exception Handling and why we use this in Binary Files.Text Files:Introduction of Data ...
Read more >
File Reader error: Exception while reading binary data from ...
I am getting this error in higher environment, but i executed the same file reader snap in lower environment successfully with the same...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found