Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing exception address by `longjmp` #30

Closed
vgxbj opened this issue Jun 17, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@vgxbj
Copy link
Contributor

commented Jun 17, 2019

In chapter SjLj exception handling, I noticed that we passed an address of pointer by longjmp which is not reasonable (IMO). Usually, when handling exception, we use longjmp to pass error/exception type, which is can be represent by a predefined integer. I didn't dig much about it, what's your opinion?

%5 = ptrtoint %Exception* %3 to i32
call void @longjmp(%jmp_buf* %throw, i32 %5)

[1] Setjmp.h on Wikipedia

Regards.

@archfrog

This comment has been minimized.

Copy link
Collaborator

commented Jun 17, 2019

I am to blame :) I did the original sample for 32-bit architectures. The idea is to pass the pointer to the exception instance up the call stack, but I am not sure how to do this with 64-bit pointers. I'd prefer if we can somehow pass a pointer to the exception instance, but if this is impossible, I guess we'll have to resort to an error code. After all, it is just a sample.

As far as I can see, longjmp takes a 32-bit integer (even on 64-bit platforms), so if you feel like changing the sample to use an error code, it is definitely fine with me :-)

@vgxbj vgxbj closed this Jun 19, 2019

@f0rki

This comment has been minimized.

Copy link
Owner

commented Jun 21, 2019

FYI: I added a paragraph that clarifies this issue to the text.

@vgxbj

This comment has been minimized.

Copy link
Contributor Author

commented Jun 21, 2019

Thanks a lot 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.