Skip to content

jsglue: add a method to retrieve ErrorInfo from the pending exception stack#723

Open
Gae24 wants to merge 1 commit intoservo:mainfrom
Gae24:exception-stack
Open

jsglue: add a method to retrieve ErrorInfo from the pending exception stack#723
Gae24 wants to merge 1 commit intoservo:mainfrom
Gae24:exception-stack

Conversation

@Gae24
Copy link
Copy Markdown
Contributor

@Gae24 Gae24 commented Mar 23, 2026

Attempt to retrieve ErrorInfo from the stack of the pending exception, to avoid empty messages on uncaught exceptions.

Testing: Need to test it with servo.
Servo PR: servo/43632

Comment thread mozjs/src/rust.rs Outdated
cx,
message_buf.as_mut_ptr(),
filename_buf.as_mut_ptr(),
1024,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number

@Gae24 Gae24 force-pushed the exception-stack branch 7 times, most recently from eaa132f to a0c40b2 Compare March 27, 2026 12:05
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
@Gae24 Gae24 force-pushed the exception-stack branch from dedee71 to 10423b3 Compare April 10, 2026 17:58
@Gae24 Gae24 marked this pull request as ready for review April 11, 2026 19:56
Comment thread mozjs-sys/src/jsglue.cpp
if (!message) {
message = builder.toStringResult().c_str();
}
*message_len = std::min<size_t>(1024, strlen(message));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might reasonable strategy for filename, but not for message. Also we are doing two copies, one to message_buffer and one with to_string. Maybe we should impl this with callbacks, that receive len and char* and create rust string from it.

We might also skip utf8 validation if I understand https://searchfox.org/firefox-main/source/js/public/CharacterEncoding.h#135 correctly.

Copy link
Copy Markdown
Contributor Author

@Gae24 Gae24 Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry could you expand on it? Is the issue that the selected length could be insufficient?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and the fact that implementation is not optimal we copy it twice, firstly into rust array then into rust String.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants