Today, we’ll look at a crash that occurred when trying to erase an element from a std::set.
The Case of the Crash When Trying to Erase an Element from a std::set
by Raymond Chen
From the article:
rax=000001f565bc046e rbx=000001f589b20340 rcx=000001f565bc046e
rdx=000000e6658feca8 rsi=000001f589b20690 rdi=000001f589b203c0
rip=00007ffdd4726bc4 rsp=000000e6658fec30 rbp=0000388a1713ab55
r8=000001f589b895d0 r9=000001f589b895d0 r10=000001f589000140
r11=0000000000000000 r12=0000000000000001 r13=000000007ffe0385
r14=0000000000000000 r15=000001f589b8f900
LitWare!std::_Tree<std::_Tset_traits<WidgetWatcher *,
std::less<WidgetWatcher *>,
std::allocator<WidgetWatcher *>,0> >::_Eqrange+0x14
[inlined in LitWare!std::_Tree<std::_Tset_traits<
WidgetWatcher *,std::less<WidgetWatcher *>,
std::allocator<WidgetWatcher *>,0> >::erase+0x18]:
00007ffd`d4726bc4 cmp byte ptr [rax+19h],r11b ds:000001f5`65bc0487=??
The stack trace has some information about how we got here.
LitWare!std::_Tree<std::_Tset_traits<Widget *,
std::less<Widget *>,
std::allocator<Widget *>,0> >::_Eqrange+0x14
LitWare!std::_Tree<std::_Tset_traits<Widget *,
std::less<Widget *>,
std::allocator<Widget *>,0> >::erase+0x18
LitWare!Widget::~Widget+0xc8
LitWare!Widget::`scalar deleting destructor'+0x14
LitWare!DestroyWidget+0x15
Fabrikam!Doodad::~Doodad+0x75
Fabrikam!Doodad::`scalar deleting destructor'+0x14
Fabrikam!Doodad::Release+0x40
Contoso!Gadget::~Gadget+0x66
ucrtbase!<lambda_⟦...⟧>::operator()+0xa5
ucrtbase!__crt_seh_guarded_call<int>::operator()<⟦...⟧>+0x3b
ucrtbase!__acrt_lock_and_call+0x1c
ucrtbase!_execute_onexit_table+0x3d
Contoso!dllmain_crt_process_detach+0x45
Contoso!dllmain_dispatch+0xe6
ntdll!LdrpCallInitRoutine+0xb0
ntdll!LdrShutdownProcess+0x260
ntdll!RtlExitUserProcess+0x114
kernel32!FatalExit+0xb
ucrtbased!exit_or_terminate_process+0x3a
ucrtbased!common_exit+0x85
ucrtbased!exit+0x16
View the full article
Hey all, Today we've added a new sub-domain under our roof. It is for the official Technical Documentation of Horizon. The files are configured using doxygen. Doxygen is a great tool for generating C++ documentation and we've added some features and tweaked the settings a lot for - Better website readability with JS and Graph Images. Generated Graphs for hierarchical view of the project structures. Generated Call and Caller Graphs for over 8000 functions in the specification. PHP powered (server-sided) search for more control on the code base. Feel free to test drive these features by yourself and have a good time understanding our codebase. New Sub-domain: http://documentation.projecthorizon.xyz/ Example of the documentation with call and caller graphs - Best of luck Sephus
Updated our forum version 5.0.0 to 5.0.3. Upgrade was successful and below are the changes made to the forum codebase. #3871: Disable extensions for recovery mode
#3802: Badges in ACP tables were wrapping
#3824: Fix issue where guest comments hang instead of showing a "pending approval" message
#3843: Removed backgrounds, backdrops and conditionally hid captions from Images Widget
#3865: Force Account Settings page to use any predefined FURLs
#3883: Fix exception when viewing Blog RSS feeds
#3832: Fix issue where banned users still have menu options on mobile
#3902: Filter out empty club field values
#3826: Mitigate Icon Picker Lagginess
- Issue #3594: Big Lag when using the icon picker...
- Issue #3770: Editor icon picker configuration
#3854: Active inbox message titles are no longer dark
#3857: Ensure widgets with custom backgrounds inherit border-radius
#3859: Added ipsBox styles to edit form
#3863: Filter out empty secondary group IDs
#3870: Fix Elasticsearch Similar Content issue
#3881: Fix http links in the privacy page
#3882: Fix exception when editing featured content with images
#3885: Fixed width of avatar on profile page
#3887: Updated gallery stat icons
#3891: Fixed minor UI issue in Messenger
#3892: Fixed toggling Activity Stream as default
#3893: Improved spacing of edit form inside posts/comments
#3894: Fixed border-radius of loading dialogs
#3895: Fixed spacing in Account Settings
#3896: Fixed the UI of "Drag to upload files.." on tablets
#3898: Fixed some minor UI issues with ModCP and Notifications page
#3864: Forums may not show if last poster has been anonymised.
#3852: Advertisements optimisation
#3844: Removed gridspan and restored htmlId from radioImages
#3840: Fix PII Export XML issue
- Issue #3794: Request PII Data XML file invalid
- Issue #3830: Cannot export PII Data
#3764: Fix issues with importing themes
#3835: Sync content promoted in v4 with featured content in v5
#3838: Catch exceptions in the deletion log
#3839: Hide items from DatabaseNavigation widget if there is no permission to see them
#3842: Improved contrast of form headers in ACP.
#3833: Remove hard-coded ipsWidget--transparent class from builder widgets
#3790: Hide "Featured By" from Our Picks if the member is not available
#3823: Fix issue where all blog comments are moderated
#3792: Improved performance of navigation "More" menu
#3798: Removed stray '>' in includeJS
#3804: Fixed alignment of color settings in Theme Editor
#3812: Fix issue where deleting a menu item did not give the option to publish
#3814: Don’t share config object between instances
#3729: Fix issue where both an address and an online link can show on an event
#3785: Include URL in disk log
#3787: Add can_edit_tags permission to control cover photo permissions for tags
#3820: Made blog/category header UI consistent with other areas of the suite
#3789: Fix incorrect tooltip in ActiveUsers widget
#3821: Bring back the our picks in email setting
#3813: Don't send assignment notifications to the assignee if they are the one assigning
#3793: Fixed an issue where archived posts were not deleted on topic delete
#3327: Modify Stripe gateway to check for test vs live keys based on NEXUS_TEST_GATEWAYS
In today's post, I'll learn how modern C++ can influence the code you write for your embedded system. You will see code using up to C++23. The example I show you below circles around at least two questions I got various times from customers: What is consteval good for? What is that user-defined literal operator, and why should I care?
C++ for Embedded Systems: constexpr and consteval
by Andreas Fertig
From the article:
Chapter One: What is a MAC address?
I teach a lot of classes to customers who are developing embedded systems. That makes sense. I worked for a long time in that domain, and I enjoyed it so much.
One recurring topic is networking. While nowadays we have various different network types and technologies, let's use the Internet Protocol (IP) today. The base of network communication is your Network Interface Card (NIC). Each NIC has a unique Medium Control Address (MAC) assigned. The MAC address is the base layer for everything on top, like TCP/IP.
A MAC address consists of exactly six bytes. One way to represent a MAC address in code is this:
View the full article
Hey everyone, As we push forward and prepare for the first release of Horizon, it is crucial for us to protect and maintain several rules and strict guidelines shaping the code written in the software. Software can't be written without rules and impositions which create a generic and obedient command over the software and its structure. We cannot disobey the logic followed when the application of concepts and philosophies in our software are imposed, and we cannot create transgression when building software. Transgressed software is detrimental to our concerns and will illogically provide us bugs and details of unethical conduct of manner which we cannot permit in software. We want our manner to be behaved and rules to be followed. To help us get to this extensive requirement of identifying flaws and areas for improvement we require a team of reviewers or a Software Review Committee who need to create powerful structures and code of conduct within the developer community. Here are the rules that the committee should seek upon adding to our codebase and its developers alike - [For Core Development]Core development is the foundation and the foothold of the software that agrees with the top and structural "machina" of the software. The architecture of the core creates a founding control and stability over the structures and systems that are created above it. The core decides whether the software is sound, stable and right in its design and architecture, while the structures above give it shape and nothing but little structure to understand its design requirements. The core of the software or the foundations comprise of its kernel, and the additional components that make the kernel work and function as a whole. The kernel provides the system above a large foundation to be built on top of. The system doesn't rely on any underlying architecture except for some libraries and dependencies which are outside the scope of the software being built. The core or foundation of the software will guarantee that the structures above don't fail and are provided with what they require to function. [For Support Development]Support development is the framework and surrounding structure development of software built on top of its core framework. The support developer team will focus on the business requirements of the software not the founding architectural needs or the dependencies. Support architecture is less focused on when building support systems. The need for several features are important in support development such as the Game requirements or the game logic that functions the business needs and the functioning of game components. For example support developers need to focus on features such as - Player objects, Map objects, Search algorithms, Monster behavior and core technology that will help them function. Additional examples include UI related requests to the server, the UI needs to be made functional by implementing support algorithms and features that will enable the functionality on the client. This is the requirement of the Support Developers that the Review Committee should be well aware of. [For Script Development]Script development includes the building of Lua scripts to extend and modify the behavior of the entire software. We have designed scripts to be an extension to almost all parts of Horizon and are welcoming developers to share their ideas on extending areas of the software that we haven't explored yet. For script development, the Lua Review Commitee is a team designated to work with the developers and provide them with the guidelines and help the require to frame and shape Horizon's script codebase. Guidelines For Each Review Committee MemberAs a Review Committee team member you are required to assess the changes (Pull Requests and Merges) that are made by all the core developers and the support developers. We on the review team decide how the software is shaped and how it functions. The Review Committee team will abide by the following rules in reviewing software - Ensuring Architectural Congruence and Systemic Integrity: The committee serves as an agreement on architectural modifications, meticulously evaluating proposed code to ascertain an adherence with the laws and congruence to the overall architectural blueprint of the software. Cultivating Codebase Homogeneity and Maintainability: Through rigorous scrutiny of coding style, conventions, and best practices, the review committee fosters a cohesive and uniform codebase, thereby significantly enhancing its long-term maintainability, reducing cognitive load for developers, and mitigating the accumulation of technical debt. Facilitating Proactive Bug Identification and Mitigation: Functioning as a critical quality assurance layer, the committee diligently examines code for logical flaws, potential edge cases, and latent bugs, thereby enabling the early detection and rectification of defects before they propagate into production environments, ensuring greater software robustness. Promoting Knowledge Dissemination and Collaborative Learning: The review process acts as a vital conduit for the cross-pollination of technical expertise and domain knowledge within the development team, affording opportunities for less experienced members to glean insights from seasoned professionals and fostering a culture of continuous learning and collective ownership of the codebase. Upholding Performance Efficacy and Resource Optimization: The committee critically assesses the efficiency and scalability implications of proposed code changes, identifying potential performance bottlenecks or resource-intensive implementations, thereby ensuring the software operates optimally under anticipated load and minimizes unnecessary resource consumption. Guarding Against Security Vulnerabilities and Ensuring Robustness: A crucial mandate of the review committee is the proactive identification and mitigation of potential security vulnerabilities embedded within the code, safeguarding the application and its data against malicious exploitation and ensuring the overall resilience of the software system. Verifying Test Adequacy and Quality Assurance Protocols: The committee extends its purview to the evaluation of accompanying test suites, ensuring comprehensive test coverage and adherence to established quality assurance protocols, thereby bolstering confidence in the reliability and correctness of the implemented features. Enforcing Adherence to Project Standards and Regulatory Compliance: The review committee plays a pivotal role in ensuring that all code contributions comply with predefined project standards, industry best practices, and any relevant regulatory requirements, thereby mitigating potential legal and operational risks. Serving as a Repository of Collective Wisdom and Best Practices: Over time, the deliberations and decisions of the review committee establish a valuable institutional memory of coding standards, architectural rationale, and effective problem-solving techniques, contributing to the ongoing evolution and refinement of the development process. How to apply?There are 3 review committees in Horizon's Development Team - The Core Review Committee The Support Review Committee The Script Review Committee To apply, send in your application as a personal message to @Sephus here on the forums with the following form filled - Review Committee Application Form Name: Designation: (Which committee are you applying to): Date of Birth: Occupation: Credentials / Qualifications (Work that would make you an ideal candidate for being on the desired review committee): How many days/months/years will you dedicate to our project? (More days are preferred) Best of luck, Sephus
Hey everyone, As we push forward and prepare for the first release of Horizon, it is crucial for us to protect and maintain several rules and strict guidelines shaping the code written in the software. Software can't be written without rules and impositions which create a generic and obedient command over the software and its structure. We cannot disobey the logic followed when the application of concepts and philosophies in our software are imposed, and we cannot create transgression when building software. Transgressed software is detrimental to our concerns and will illogically provide us bugs and details of unethical conduct of manner which we cannot permit in software. We want our manner to be behaved and rules to be followed. To help us get to this extensive requirement of identifying flaws and areas for improvement we require a team of reviewers or a Software Review Committee who need to create powerful structures and code of conduct within the developer community. Here are the rules that the committee should seek upon adding to our codebase and its developers alike - [For Core Development]Core development is the foundation and the foothold of the software that agrees with the top and structural "machina" of the software. The architecture of the core creates a founding control and stability over the structures and systems that are created above it. The core decides whether the software is sound, stable and right in its design and architecture, while the structures above give it shape and nothing but little structure to understand its design requirements. The core of the software or the foundations comprise of its kernel, and the additional components that make the kernel work and function as a whole. The kernel provides the system above a large foundation to be built on top of. The system doesn't rely on any underlying architecture except for some libraries and dependencies which are outside the scope of the software being built. The core or foundation of the software will guarantee that the structures above don't fail and are provided with what they require to function. [For Support Development]Support development is the framework and surrounding structure development of software built on top of its core framework. The support developer team will focus on the business requirements of the software not the founding architectural needs or the dependencies. Support architecture is less focused on when building support systems. The need for several features are important in support development such as the Game requirements or the game logic that functions the business needs and the functioning of game components. For example support developers need to focus on features such as - Player objects, Map objects, Search algorithms, Monster behavior and core technology that will help them function. Additional examples include UI related requests to the server, the UI needs to be made functional by implementing support algorithms and features that will enable the functionality on the client. This is the requirement of the Support Developers that the Review Committee should be well aware of. [For Script Development]Script development includes the building of Lua scripts to extend and modify the behavior of the entire software. We have designed scripts to be an extension to almost all parts of Horizon and are welcoming developers to share their ideas on extending areas of the software that we haven't explored yet. For script development, the Lua Review Commitee is a team designated to work with the developers and provide them with the guidelines and help the require to frame and shape Horizon's script codebase. Guidelines For Each Review Committee MemberAs a Review Committee team member you are required to assess the changes (Pull Requests and Merges) that are made by all the core developers and the support developers. We on the review team decide how the software is shaped and how it functions. The Review Committee team will abide by the following rules in reviewing software - Ensuring Architectural Congruence and Systemic Integrity: The committee serves as an agreement on architectural modifications, meticulously evaluating proposed code to ascertain an adherence with the laws and congruence to the overall architectural blueprint of the software. Cultivating Codebase Homogeneity and Maintainability: Through rigorous scrutiny of coding style, conventions, and best practices, the review committee fosters a cohesive and uniform codebase, thereby significantly enhancing its long-term maintainability, reducing cognitive load for developers, and mitigating the accumulation of technical debt. Facilitating Proactive Bug Identification and Mitigation: Functioning as a critical quality assurance layer, the committee diligently examines code for logical flaws, potential edge cases, and latent bugs, thereby enabling the early detection and rectification of defects before they propagate into production environments, ensuring greater software robustness. Promoting Knowledge Dissemination and Collaborative Learning: The review process acts as a vital conduit for the cross-pollination of technical expertise and domain knowledge within the development team, affording opportunities for less experienced members to glean insights from seasoned professionals and fostering a culture of continuous learning and collective ownership of the codebase. Upholding Performance Efficacy and Resource Optimization: The committee critically assesses the efficiency and scalability implications of proposed code changes, identifying potential performance bottlenecks or resource-intensive implementations, thereby ensuring the software operates optimally under anticipated load and minimizes unnecessary resource consumption. Guarding Against Security Vulnerabilities and Ensuring Robustness: A crucial mandate of the review committee is the proactive identification and mitigation of potential security vulnerabilities embedded within the code, safeguarding the application and its data against malicious exploitation and ensuring the overall resilience of the software system. Verifying Test Adequacy and Quality Assurance Protocols: The committee extends its purview to the evaluation of accompanying test suites, ensuring comprehensive test coverage and adherence to established quality assurance protocols, thereby bolstering confidence in the reliability and correctness of the implemented features. Enforcing Adherence to Project Standards and Regulatory Compliance: The review committee plays a pivotal role in ensuring that all code contributions comply with predefined project standards, industry best practices, and any relevant regulatory requirements, thereby mitigating potential legal and operational risks. Serving as a Repository of Collective Wisdom and Best Practices: Over time, the deliberations and decisions of the review committee establish a valuable institutional memory of coding standards, architectural rationale, and effective problem-solving techniques, contributing to the ongoing evolution and refinement of the development process. How to apply?There are 3 review committees in Horizon's Development Team - The Core Review Committee The Support Review Committee The Script Review Committee To apply, send in your application as a personal message to @Sephus here on the forums with the following form filled - Review Committee Application Form Name: Designation: (Which committee are you applying to): Date of Birth: Occupation: Credentials / Qualifications (Work that would make you an ideal candidate for being on the desired review committee): How many days/months/years will you dedicate to our project? (More days are preferred) Best of luck, Sephus
So today I attempted to create a project which logged the sent and received times of the walking packet from an openkore client. By modifying the openkore client, I timed the packet sending and receiving functions to mark the time in which the emulator could perform a quick calculation (in this example the walking algorithm) and send back a response to the client. By making the character move on the client I achieved multiple responses and ergo the average response time it took for the emulator to achieve a successful transmission of packets from client to server (request) and back to client (response). The openkore was a fresh install and I had only modified a few lines of code. The patch for this file is attached in this post, feel free to use it in your own openkore to check the packet reception times in your emulator 0001-PacketTimer-Patch.patch Doing this tells me how fast our emulator is and whether what we are doing is the right thing. By looking at the data received from this patch, it seems our emulator is quite close to the eAthena emulators. Keep in mind that Horizon is not at all optimized at this point and we will be doing so only in a few releases into the future. Horizon is a very fast emulator and you can see the results in this patch that we're able to meet the qualifications of a competent emulator in the online gaming industry. We're there with the top emulators in the RO emulation scene and the MMORPG world. We're quite competent even in our less optimized, not bug-tested and unreleased codebase. We're quite there with the top few emulators which achieve the importance of providing a platform based on the "competition" element of online gaming. We want our emulator to maximize competition in online gaming and we're making it possible with rigorous efforts as seen in the results today. We can see that we're just off by 0.001 marks. Which is 1 millisecond of time. We are that much closer to competitive online gaming and we can achieve the difference by working on optimizations on the emulator. Horizon also leverages Hyperthreading (or Multithreading) technology, which means that characters are simultaneously processed on our server compared to the one-by-one processing of them in eAthena based servers. For more clarity, take a look at the diagram below - In eAthena servers, characters are loaded and processed one after the other. This can cause an issue in processing thousands of characters online. In Horizon, characters are logged into maps which are divided amongst the threads of the Game Logic Layer (GLL). In the GLL multiple threads process a group of maps. If two players happen to be in different groups, they are processed differently.
The std::map subscript operator ([]) is a convenient but sometimes dangerous feature, as it can create unintended default-constructed entries. By understanding the behavior of various map insertion and lookup methods—such as insert, emplace, try_emplace, and insert_or_assign—developers can write more efficient and predictable code while avoiding unnecessary key-value creations and duplicate lookups.
A Simplified Overview of Ways to Add or Update Elements in a std::map
by Raymond Chen
From the article:
Some time ago, I mentioned how the std::map subscript operator is a dangerous convenience. In that article, I linked to an overview of the insertion emplacement methods, but I’m going to recapture the essential points in a table.¹
In the table below, the discussion of “consumed” or “not consumed” refers to the case that v is an rvalue reference like std::move(something).
We can reorganize the table by effect.
Exercise: Why are the bottom left two boxes blank?View the full article
C++26 introduces pack indexing as a core language feature, making it significantly easier to extract specific elements from parameter packs using a familiar subscript syntax. This improvement, proposed by Corentin Jabot and Pablo Halpern, eliminates the need for cumbersome workarounds like recursive templates or boolean expression tricks, providing a more intuitive and readable approach.
C++26: pack indexing
by Sandor Dargo
From the article:
C++11 introduced parameter packs to provide a safer way to pass an undefined number of parameters to functions instead of relying on variadic functions.
While packs are a useful feature, and since C++17 it’s so easy to use them in fold expressions, extracting a specific element of a pack is somewhat cumbersome.
You either have to rely on some standard functions not made for the purpose or use “awkward boolean expression crafting or recursive templates”. None of them is unbearable, but it might be error-prone or simply expensive regarding compile-time performance. Nevertheless, they are not the most readable solutions.
C++26 brings us pack indexing as a core language feature thanks to the proposal of Corentin Jabot and Pablo Halpern, P2662R3.
Before discussing some interesting points, first, let’s look at an example:
View the full article
On 12th March, 2025 we have reinstalled our runners. Runners are those which compile the project in its development environment and release key data that is crucial to the project's stability and testing. We are testing the project on 6 Linux VMs which compile the codebase in both GCC and Clang environments, each having Debug and Release configurations. Debug and Release configurations are the two different kind of configurations that the project can be compiled in. Debug means the project will hold debug information in its compiled state, while Release means a more optimized version of the software is compiled. Both these configuration was well as RelWithDebInfo are an important configuration for the project to be compiled in each runner pipeline. An example of a runner can be seen inside the laboratory each commit will have a check mark of whether it is passed or failed. Passed indicates a good working state of the project, while fail means a cross mark in red. Both these states are declared by each of the runners. That is why the runners are an important part of the project's development. For example, take a look at the image below - Each job has either passed or failed or is currently being worked on. These are automations which compile the code as and when it is pushed to the repository. Having this in our project simply boosts the quality and performance of the system.
Horizon is now a public software. I went up and down with it a few times thinking that making a paid software out of it was not a priority for me and something that I didn't want to do in the long run because of the kind of work it is. Horizon is a free open source emulator and it should be kept that way for a lot of reasons. I started it as an open source software and so it should be kept as such. The heart of it is an open and free world of code where you can do anything you can dream or imagine. That shouldn't be taken away, the software will grow as it has been parented and taking it away from its free spirited philosophy makes the dream of it become unkept. So in the spirit of its freedom and the services we provide for free in this community, Horizon is back on its feet walking itself into the strength and integrity it needs to run like Forrest Gump ran for his freedom. Horizon's codebase is available at our laboratory - http://lab.projecthorizon.xyz/horizon/horizon Packet parsers, stress testers and Hercules to Horizon packet converters are all available and listed under our group named Horizon.
So after a long time of dealing with a problem in Windows Server 2022, I finally decided to give it up because I can't be bothered to use it if it keeps giving me issues. I've decided to shift to Proxmox. Some of the data has been lost due to Invision Community being a tardy software as well. Images and files uploaded via our forum are gone, we'll need to reupload them. All things in all we managed to upgrade ourselves from the shitty lapse of a software Windows has made itself to Proxmox which is running on Linux. Now I'm converting all my drives to the ext4 format for Linux compatibility. 3 Machines have been transferred and I'm looking to do the rest tomorrow or the day after. A lot of work to be done to keep this community going! I love it! No worries about the work to be done, it's all good. If anything, the site should be much faster due to the lightweight host operating system, kvm benefits and linux host machine hypervisors. Lets hope that this lasts us well a long time unlike Windows which gave up on us 6 months into our production phase.
In this blog post, we’ll explore ways to improve the safety of a simple configuration manager. We’ll handle common pitfalls like dangling references and excessive stack usage. Additionally, we’ll see how C++26 helps enforce safer coding practices with stricter diagnostics and improved handling of large objects.
Improving Code Safety in C++26: Managers and Dangling References
by Bartlomiej Filipek
From the article:
Step 1: The Buggy Implementation
Below is a simple example of a manager object that stores various configs in a map and provides a method to retrieve them. When a requested configuration isn’t found, the code attempts to return a default certificate:
Do you see a potential error in this code?
. . .
At first glance, the code looks harmless. However, if the requested entry isn’t found, the function returns a reference to a temporary std::vector. Once the function exits, that temporary is destroyed—leaving you with a dangling reference and undefined behavior.
View the full article
Last time, we looked at how the Microsoft C++ standard library implements wait and notify_* for std::atomic<std::shared_ptr<T>>. Today, we’ll look at the other library that (as of this writing) implements std::atomic<std::shared_ptr<T>>: libstdc++.
Inside STL: Waiting for a std::atomic<std::shared_ptr<T>> to change, part 2
by Raymond Chen
From the article:
The first thing to note is that the traditional “wait for a value to change” mechanism on unix is the futex, but futexes (futexen?) are limited to 4-byte values, which is insufficient for a 64-bit pointer, much less the two pointers inside a shared_ptr.
At this point, I will refer you to learn about how libstdc++ implements waits on atomic values, particularly the section on how it handles types that do not fit in a __platform_wait_t. The remainder of this discussion will treat that as an already-solved problem and focus on the shared pointer part.
Okay, back to atomic<shared_ptr<T>>::wait():
// atomic<shared_ptr<T>>::wait
void
wait(value_type __old,
memory_order __o = memory_order_seq_cst) const noexcept
{
_M_impl.wait(std::move(__old), __o);
}
When you wait on a shared_ptr, the work is done by _Sp_atomic::wait:
// _Sp_atomic<shared_ptr<T>>::wait
void
wait(value_type __old, memory_order __o) const noexcept
{
auto __pi = _M_refcount.lock(memory_order_acquire);
if (_M_ptr == __old._M_ptr && __pi == __old._M_refcount._M_pi)
_M_refcount._M_wait_unlock(__o);
else
_M_refcount.unlock(memory_order_relaxed);
}
View the full article
The ACCU conference has a range of workshops, including online options, this year:
Workshops for Everyone
by ACCU Conference
From the article:
See all the offerings, from Jason Turner, Nicolai Josuttis, Robert Seacord, Gail Ollis, Mateusz Pusz, Phil Nash and Mike Shah.
View the full article
Should you start new projects in C++, these days? Is language safety an issue for you? What can be done, today?
Making C++ Safer
by Greg Law
From the article:
I believe that over time C++ will become a lot safer, maybe even some kind of ΓÇÿsafeΓÇÖ. Competition is good: Clang was the best thing to happen to GCC, and Rust might turn out to be the best thing to happen to C++. That journey has already begun, with proposals for the evolution of the language including Contracts and Profiles, and simply changing some of the defaults in C++26. While the language custodians work to make the language itself safer, what can you do today?
  View the full article
When using std::atomic<std::shared_ptr<T>>, the C++ standard defines a "change" as a modification to either the stored pointer or the control block pointer. However, since atomic wait mechanisms typically track only a single memory address, the Microsoft implementation handles this limitation by using a timeout-based polling strategy to detect changes in the control block.
Inside STL: Waiting for a std::atomic<std::shared_ptr<T>> to change, part 1
by Raymond Chen
From the article:
Like other std::atomic specializations, std::atomic<std::shared_ptr<T>> supports the wait and notify_* methods for waiting for the value to change and reporting that the value has changed. The definition of “changed” in the C++ language specification is that the value has changed if either the stored pointer or the control block pointer has changed. A shared pointer is implemented as a pair of pointers, but Wait­On­Address can wait on at most 8 bytes, and unix futexes can wait on only four bytes, so how does this work?¹
The Microsoft implementation waits for the stored pointer to change, and the notify_* methods signal the stored pointer. But wait, this fails to detect the case where the stored pointer stays the same and only the control block changes.
std::atomic<std::shared_ptr<int>> p =
std::make_shared<int>(42);
void change_control_block()
{
auto old = p.load();
auto empty = std::shared_ptr<int>();
// Replace with an indulgent shared pointer
// with the same stored pointer.
p.store({ empty, old.get() });
p.notify_all();
}
void wait_for_change()
{
auto old = p.load();
p.wait(old);
}
View the full article
Let me rephrase what I said, If your project is founded on Horizon and is using our software, you are more than welcome to talk about your game dev and emu development but if you're using your own custom project that is entirely different from Ragnarok Online then it is not allowed. Infact I would be more than happy to shortlist this thread in the likes that we can discuss more about it in our community. There may be others who would want to speak about their projects and get help from us.
This issue has resumed, what I analyzed was that Caddy hangs when asked to serve a high load of clients. I think there were a large volume of users concurrently accessing the site in which time the webserver required more RAM than available (2GB at that time.) I've increased this to 4GB past the recent incident in which caddy had stopped resolving requests and just left the browser continuously hanging. Waiting for more data on the new configuration so that we can estimate a resolution for this situation. Edit: Another angle to this problem could be that caddy has memory leaks, still to devise.
Horizon's PTS is used for testing and serving the community with a server that showcases Horizon and its features. The community is welcome to use it for the benefit of testing and finding errors. So lets get down to it - Download the @bio provided Horizon client from here. Change the IP Address in data/clientinfo.xml to 15.235.163.198. Connect using the "_m" or "_f" method. In this method you add a suffix "_m" for male characters or "_f" for female characters to your username in your account creation for only the first time and only during account creation. The next time you log in you don't need to add this suffix to your username. That's it, you're connected to the PTS and you can start playing on a Horizon powered server. Watch the following video which showcases the login and registration process - Screen Recording 2025-03-01 143407.mp4