text:
feat(cors): Allowed more wildcard options

A few weeks ago the allowed CORS origins have been changed from a regex to a wildcard notation (#2389). Implementation wise all kinds of wildcards are supported, however, the validation regex on the SecurityPolicy CRD limits the CORS options to hostnames prefixed with an wildcard followed by a dot, allowing all subdomains of that host. This reduces the freedom when allowing cross origins a lot compared to how it was before. This PR aims to relax the validation regex a bit to enable the following use cases:

Allowing all hosts of an specific scheme (https://*)
Allowing all hosts regardless of the scheme (*)
Allowing all ports of a specific host (http://localhost:*)

While allowing all hosts in the context of CORS might sound a bit hacky, this is sometimes required. For instance when a web service provides an API which is consumed by many third-party web applications hosted under arbitrary domains not under the control of the maintainer of aforementioned web service. In addition to that it can be very useful during application development. This is why I have added the option to allow all ports of a specific host as well.
Review the new and the old validation regexes.

@jaynis can sign your commits and repush ? DCO is failing

@jaynis Thanks for the improvement in the wildcard host matching. The implementation looks good to me.
I only have a little hesitation about the port wildcard matching. Suffix/Port wildcard matching is not a common practice for hostnames. Do you have many ports for a given hostname?

Thank you for your review @zhaohuabing.

I only have a little hesitation about the port wildcard matching. Suffix/Port wildcard matching is not a common practice for hostnames. In your use case, do you have many ports for a given hostname?

The port range matching was solely meant to be a dev feature so that one can configure CORS for a host (e.g. localhost) regardless of the port the application runs on. But this scenario could be covered by the general wildcard as well, therefore I would also be fine with deleting it again if you think it is not required. Just let me know your preference.

Thank you for your review @zhaohuabing.

I only have a little hesitation about the port wildcard matching. Suffix/Port wildcard matching is not a common practice for hostnames. In your use case, do you have many ports for a given hostname?

The port range matching was solely meant to be a dev feature so that one can configure CORS for a host (e.g. localhost) regardless of the port the application runs on. But this scenario could be covered by the general wildcard as well, therefore I would also be fine with deleting it again if you think it is not required. Just let me know your preference.

Prefer to remove the suffix matching to keep it aligned with the common practice. Thanks.

authors: arkodg jaynis zhaohuabing


text:
Enyo 2171 Add tabindex for Item to prevent accessibility timing issue

Issue
screen reader sometimes does not read child component's content when Item is focused.
Cause
Item may have components as child. However, Sometimes screen reader does not read child component's content because time to receive tabindex is late than child.
To prevent this timing issue, I add tabindex to Item.
Fix
Add tabindex in ariaObservers.
Enyo-DCO-1.1-Signed-off-by: Bongsub Kim bongsub.kim@lgepartner.com

I will re-create PR with latest code.

source: gharchive/pull-request

repo: enyojs/moonstone

license_type: permissive

license_source: bigquery


text:
[QUESTION] Path still gets generated even when told not to

Path still gets generated in the swagger.dart file when specified like the following in the build.yaml file:
targets:
$default:
sources:
- lib/**
- $package$
builders:
chopper_generator:
options:
header: "//Generated code"
swagger_dart_code_generator:
options:
input_folder: "lib/"
output_folder: "lib/swagger_generated_code/"
exclude_paths:
- "/api/mobile/actuator/"
Am I using wrong syntax or is this an actual bug?

hi @dtaskai , exclude_path and include_path are regex strings. to make your path excluded, you need to add something like this:
\/api\/mobile\/actuator\/
Please use Regex validator to check is you String passing or not. For example, you can use this validator: https://regex101.com/

@dtaskai , if something is not clear - please let us know

The exclusion didn't work on my project even after using regex syntax, so I have tried it on the example project:
Added an exclusion to /rooms
swagger_dart_code_generator:         options:           input_folder: "lib/"           output_folder: "lib/swagger_generated_code/"           exclude_paths:             - "\/rooms"
Ran flutter build run build_runner build
Then it still generated the code for /rooms
@Get(path: '/rooms')
  Future<chopper.Response<List<Room>>> roomsGet(
      {@Query('id') required String? id});

Ok good let me check it

@dtaskai  Yep you're right. We removed it in 2+ version. Let me fix.

@dtaskai Please try it on latest version. Also you can put just /rooms to exclude_path. It works.
Latest version is 2.1.3+2

Works on both the example and my personal project, thank you!

source: gharchive/issue

license_source: github-api


text:
[QUESTION] How can I config worker-pool on Chopper?

Please describe a problem.
The below is Chopper worker poll example.
/// inspired by https://github.com/d-markey/squadron_sample/blob/main/lib/main.dart
void initSquadron(String id) {
  Squadron.setId(id);
  Squadron.setLogger(ConsoleSquadronLogger());
  Squadron.logLevel = SquadronLogLevel.all;
  Squadron.debugMode = true;
}

Future<void> main() async {
  /// initialize Squadron before using it
  initSquadron('worker_pool_example');

  final jsonDecodeServiceWorkerPool = JsonDecodeServiceWorkerPool(
    // Set whatever you want here
    concurrencySettings: ConcurrencySettings.oneCpuThread,
  );

  /// start the Worker Pool
  await jsonDecodeServiceWorkerPool.start();

  /// Instantiate the JsonConverter from above
  final converter = JsonSerializableWorkerPoolConverter(
    {
      Resource: Resource.fromJsonFactory,
    },
    /// make sure to provide the WorkerPool to the JsonConverter
    jsonDecodeServiceWorkerPool,
  );

  /// Instantiate a ChopperClient
  final chopper = ChopperClient(
    client: client,
    baseUrl: 'http://localhost:8000',
    // bind your object factories here
    converter: converter,
    errorConverter: converter,
    services: [
      // the generated service
      MyService.create(),
    ],
    /* ResponseInterceptorFunc | RequestInterceptorFunc | ResponseInterceptor | RequestInterceptor */
    interceptors: [authHeader],
  );

  /// Do stuff with myService
  final myService = chopper.getService<MyService>();

  /// ...stuff...

  /// stop the Worker Pool once done
  jsonDecodeServiceWorkerPool.stop();
}

Describe the solution you'd like
How can I config worker-poll on Chopper?

Hi @dfdgsdfg , Unfortunately I have no experience with WorkerPool. We just generation swagger code. If you have an idea, how to generate it - let us know.


text:
Background for items in context menu opened from chat header should be blue (now green)

EPAM AI DIAL chat version
0.21.0
What happened?
Actual:

Expected: on the central part items are highlighted using blue color
Example:

Confidential information

[X] I confirm that do not share any confidential information

verified on staging successfully

authors: VolhaBazhkova YauheniyaH

repo: epam/ai-dial-chat


text:
fix(chat): Update the phrase "Not allowed model selected. Please, change the model to proceed" (Issue #2363)

Description:
Update the phrase "Not allowed model selected. Please, change the model to proceed"
Issues:

Issue #2363

Checklist:

[x] the pull request name complies with Conventional Commits
[x] the pull request name starts with fix(<scope>):, feat(<scope>):, feature(<scope>):, chore(<scope>):, hotfix(<scope>): or e2e(<scope>):. If contains breaking changes then the pull request name must start with fix(<scope>)!:, feat(<scope>)!:, feature(<scope>)!:, chore(<scope>)!:, hotfix(<scope>)!: or e2e(<scope>)!: where <scope> is name of affected project: chat, chat-e2e, overlay, shared, sandbox-overlay, etc.
[x] the pull request name ends with (Issue #<TICKET_ID>) (comma-separated list of issues)
[x] I confirm that do not share any confidential information like API keys or any other secrets and private URLs

/deploy-review

/deploy-review


text:
Enable SAST scan for Tekton pipelines

As an EDP user, I would like to be able to use SAST scanning out of the box for tekton pipelines.
Acceptance Criteria:

SAST scan available out of the box for Tekton pipelines;
Enable only for build pipelines;

We have recently implemented a static application security testing feature for our EDP frameworks on build pipelines using DefectDojo.
This feature is available for application templates

Python (Python 3.8, FastAPI, Flask)
Go (Beego, Gin)
JavaScript (React, Vue, Angular, Next.js, Express)
Java (Maven, Gradle)
C# (.Net 3.1, .Net6.0)

As well as library templates:

Python (Python 3.8, FastAPI, Flask)
JavaScript (React, Vue, Angular, Next.js, Express)
Java (Maven, Gradle)
C# (.Net 3.1, .Net6.0)

This implementation will allow for improved security testing measures throughout our development process and ultimately result in higher-quality applications and libraries.

repo: epam/edp-install


text:
Reference to undefined pattern comment

I tried converting http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd to rnc using this stylesheet and then trang. However, when I tried to use the .rnc file in nxml-mode in emacs, it said: nxml-display-file-parse-error: Reference to undefined pattern comment.
My XSD is a bit rusty but it looks to me like comment is defined in the .xsd file, but is not defined in the .rng or .rnc files.

I managed to workaround this by specifying the start parameter.

I was able to get this schema to work first by applying greenrd's sed script to the xsd file, renaming it with 'mod', then using
xsltproc --stringparam start databaseChangeLog XSDtoRNG.xsl dbchangelog-3.1.mod.xsd > dbchangelog-3.1.rng.  I then converted it to rnc with trang.

authors: dwhoman greenrd

repo: epiasini/XSDtoRNG


text:
Pagination Documentation

I think a pagination entry is needed  in the documentation. It works really nice and it's shame if someone overlooks it.
Using it right now with markup-tables
Thanks a lot for this wonderful template

Thanks for suggestion.
We're going to add docs as a part of vuestic-ui. Here's some not feedback ready work: http://vuestic-ui-develop-docs.sub.asva.by/components/VaPagination.html :).

Hi, any news on this?  I am looking forward in using pagination entry on this template.
Thank you :D

Here's the new link: https://vuestic.dev/en/ui-elements/pagination.
Things are very close to release. We'll time update vuestic-admin with vuestic-ui.

authors: Heavenwalker asvae haizad

repo: epicmaxco/vuestic-admin

license: MIT


text:
Split tests ...

... for parallelization, more focussed test areas, and speedup.
To be tackled post-mvp

We have tests that install/uninstall Epinio or some components. As far as I can tell, these are the features tests (which enable/disable in-cluster services etc)
There are also other tests that enable the components if they are not there already but never disable them. That mean we could simply enable those components in the BeforeSuite block.
All other tests can safely run against the same Epinio instance (and the same Kubernetes cluster). That means we don't need GINKGO_NODES number of clusters but just one. Enabling in-cluster services is optional because it will probably never be used in production environments. The gke service is optional because it need configuration (auth) that only the users who want to use google cloud will have available thus it makes no sense to do it in epinio install.
We need to find a way to run the tests that mutate the cluster serialized somehow and on a separate cluster (ginkgo doesn't seem to support this yet: https://github.com/onsi/ginkgo/issues/526). We can run all the rest in parallel on the same cluster. This limits the number of clusters we need to just 2. The mutating tests are not expected to grow as much as the other tests so it's sane to expect this to keep working for a while.
An option would be to separate the mutating tests to a new test suite.

authors: jimmykarily kkaempf

repo: epinio/epinio


text:
[v0.5] Epicli does not create PostgreSQL SET_BY_AUTOMATION values correctly

Rename SET_BY_AUTOMATION to AUTOCONFIGURED for shared_preload_libraries

/azp run

/azp run

repo: epiphany-platform/epiphany


text:
Optional property

How to make an optional property ?

They are optional by default. Please see JSON schema spec

authors: DavidIzaac epoberezkin

repo: epoberezkin/ajv


text:
fix overlaps check

The isBetween function did not return true when either top or bottom of cement was equal to top or bottom of hole. (Check was < or >, needs to be <= and >=)

Think I might have simplified it a little to much. Will check and update PR before review is needed

Fixed the overlap check and now all cements we are testing with in wellx-designer renders correctly.
Added tests

repo: equinor/esv-intersection


text:
refactor!: simplify subnet configuration

BREAKING CHANGE: remove subnet object properties network_security_group, route_table and nat_gateway. Add subnet object properties security_group_id, route_table_id and nat_gateway_id.

Depends on hashicorp/terraform-provider-azurerm#27199

repo: equinor/terraform-azurerm-network


text:
LALR parser throws gives UnexpectedToken exception with optional string

I have written a grammar that succesfully passes my testcases with the default parser. Now I am trying to convert it to an LALR parser. But this parser throws an exception when parsing a fairly sentence.
Expected Behavior
Lark should either give an error that certain constructions in the grammar are not allowed for LALR parsing or parse the grammar correctly.
Current Behavior
I have the following grammar rule:
qgate       : "QGate[" STRING "]" ["*"] "(" INT ")"

which I apply to the following sentence
QGate["not"](0)

This worked succesfully in with the normal parser, but with the LALR parser I get an error
Error
Traceback (most recent call last):
  File "/Users/eddie/dev/quippy/.venv/lib/python3.6/site-packages/lark/parsers/lalr_parser.py", line 46, in get_action
    return states[state][key]
KeyError: '__ANONSTR_8'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 605, in run
    testMethod()
  File "/Users/eddie/dev/quippy/test_quipper_parser.py", line 44, in test_gatelist_qgate
    parsed = parser.parse(basic_text)
  File "/Users/eddie/dev/quippy/.venv/lib/python3.6/site-packages/lark/lark.py", line 197, in parse
    return self.parser.parse(text)
  File "/Users/eddie/dev/quippy/.venv/lib/python3.6/site-packages/lark/parser_frontends.py", line 37, in parse
    return self.parser.parse(token_stream)
  File "/Users/eddie/dev/quippy/.venv/lib/python3.6/site-packages/lark/parsers/lalr_parser.py", line 73, in parse
    action, arg = get_action(token.type)
  File "/Users/eddie/dev/quippy/.venv/lib/python3.6/site-packages/lark/parsers/lalr_parser.py", line 50, in get_action
    raise UnexpectedToken(token, expected, seq, i)
lark.common.UnexpectedToken: Unexpected token Token(__ANONSTR_8, '](') at line 1, column 11.
Expected: dict_keys(['__RSQB'])
Context: <no context>

When I modify the text to (by adding a '*')
QGate["not"]*(0)

it parses succesfully. Alternatively, I can change the grammar rule to
qgate       : "QGate[" STRING "](" INT ")"

and that also works. It would seem to me that an optional symbol should be possible in an LR grammar (please correct me if I'm wrong), so where does this go awry?
Environment
OS: MacOS 10.13
Lark: 0.5.4

Okay, so here's the reason for the error. In LALR, the lexer is by design deterministic. So if it has two terminals somewhere in the grammar, ] and ](, and it sees ]( in the input, it has to choose between them, and cannot try both. By default it chooses the longer one, though you can change that with priority.
What I'm saying is, somewhere else in the grammar there's a ]( terminal, and I suggest you break it into ] and (.

Yes, thank you. It is clear I needed to learn how a lexer behaves.

authors: eddieschoute erezsh

repo: erezsh/lark

license: mit


text:
RuntimeError: expected scalar type BFloat16 but found Float

when i run train_eval.py and do the evaluation stage1, i met this question and have no solution.

Can you provide more error details? This part seems an auto-casting issue, which should be automatically handled by lightening.

authors: KzZheng oldwangggggg


text:
Error

Hi there, is there any thing to do in this case?
pylinkedin.exceptions.ServerIpBlacklisted: Linkedin blacklists ips for unauthentified http requests, Aws, Digital Ocean

Hey,
LinkedIn blacklists all IPs from major cloud providers so the only way i see you can use it is by using a different cloud provider. There are many - Vultr, Scaleway, OVH and many more. I haven't tried running it on any VPS. You can find great offers on lowendbox.
Do tell which one works.

Getting the same issue as @renatoluz

authors: conorg763 nithinkashyapn renatoluz

repo: ericfourrier/scrape-linkedin


text:
Twing throws: "SyntaxError: missing ) after argument list" whenever it encounters a ` character.

Hi, it took me a while to track down this issue as I'm currently porting a large project to Twing from Twig.js to be more compatible with our TwigPHP environment.
After a lot of digging I tracked down a "SyntaxError: missing ) after argument list" error to any template that contains a ` character, no matter if the ` is in a string or comment.
Example:
{% block content %}

Some text containing `back tick characters` that we use to parse with a custom markdown tag

{% endblock %}

or:
{# Some sample code `<div class="example">Your code here</div>` #}

We have a lot of templates with these characters as we parse the contents of blocks with markdown to form an internal style-guide and coding guide. To be honest I'm not sure if this is a bug or it can be avoided using some escape configuration but simply doing \` fixes the parser but won't work when producing the template.
Any ideas?
Cheers.

I've reproduced this. It happens because backticks are not escaped in getSourceContext() method.

@nedkelly, @deflock, I reproduce it when the environment debug option is set to true. I'll fix it in no time but for now you should be able to avoid this issue by setting debug to false.
@deflock, you are totally right, this comes from the getSourceContext content of the pre-compiled template. I don't remember if there is a reason for using compiler.raw instead of compiler.string. It was a bad idea, anyway.

Fixed in Twing@1.2.2

authors: deflock ericmorand nedkelly

repo: ericmorand/twing


text:
client.Describe No result returned

the code that reproduces this issue or a replay of the bug
const  imgUrl=`https://cdn.discordapp.com/attachments/1008571049039896576/1119473369813884958/manuelcorazzari_dirty_hands_holding_dirt_from_the_ground_sun_li_98bfb5e5-8c4f-4cb3-879a-bc229108e505.png`
const msg = await client.Describe(imgUrl);
console.log({ msg });

Describe the bug

No result returned
error log
No result returned

ws:true

https://github.com/erictik/midjourney-client/blob/main/example/describe.ts

I have the same problem with describe
The Code
   const msg = await client.Describe(       "https://img.ohdat.io/midjourney-image/1b74cab8-70c9-474e-bfbb-093e9a3cfd5c/0_1.png"     );
    console.log({msg});
The output:

https://github.com/erictik/midjourney-client/blob/main/example/describe.ts#L18

Yeah, I saw that client.Connect() but it gave me this error:
TypeError: client.Connect is not a function
    at main (/*******/index.js:12:18)
    at Object.<anonymous> (/*******/index.js:24:1)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Maybe I'm forgetting something important?

npm install midjourney

Ok,
ny default npm installed v 2.7.79.
I forced the package.json to 3.0.80 and it works!
Thank you!

Ok, ny default npm installed v 2.7.79. I forced the package.json to 3.0.80 and it works! Thank you!

Still no. What's wrong， "midjourney": "^3.0.81"

help @clementepestelli

The task was successfully created, but the returned result was not broadcast

有毒，仓库代码也不行，其他setting API，reset api都可以，就这个Describe 不行，救命

I have the same issue with the example. No msg is returned from Describe().

Doesn't work for me either, using the latest version. Node 20, midjourney@4.0.97, no matter if I enable websockets or not - it submits the describe request and I can find the response in the discord channel, but MJ API never catches the response. Maybe because it's a public channel?

repo: erictik/midjourney-client


text:
Folder Copying Won't Start - Returns Blank Screen

I just started using the app today and successfully used it twice this morning, including one folder that was very large (over 2000 total files). However, when I try to start a new folder now, once I click "copy folder," it goes to a blank screen and doesn't start the copy (I checked my Drive to see if the new folder had been created and it was working in the background). I also tried using "Resume" to see if a previous copy was actually still in progress, but when I click "Resume copying," the same thing happens with the blank screen

I am having the same issue, and my folder is not too large. Actually, i thought that could be the issue and tried with a smaller folder and the same happened

I can reproduce, but this isn't an issue with the app.  Google must have changed something with their Google Apps Service, which I imagine will be fixed soon.  It appears that they changed the headers that allow the google.script service to be accessed.

This is causing the google.script service to not be found.

I don't have any control over this, but I'll leave the issue open until Google resolves it.

Thanks for your quick response, Eric. Seems whatever it was has been resolved as I've been able to use the app just fine this morning.
And, thank you for creating &maintaining this - it's been a real lifesaver in managing my drive.

I´m still experiencing the issue

authors: GASPARDYP ericyd karynrose1784

repo: ericyd/gdrive-copy


text:
[automation] Updated mainnet.toml for erigon3 up to 21.141M

This is an AUTOMATIC PR raised from this machine (which is running erigon3): snapshotter-bm-e3-ethmainnet-n1

I'm closing this PR as we were waiting for the new Caplin state files, which were not produced because of a downloader glitch in creating their torrents' hashes

repo: erigontech/erigon-snapshot


text:
Fixed issue with missing migration

There were changes in the model and no makemigrations command was ran.
What's this PR do?
Fix issue #19
Where should the reviewer start?
How should this be manually tested?
Any background context you want to provide?
This template was adapted ~stolen~ from Quickleft/Sprint.ly

Codecov Report

Merging #20 into develop will increase coverage by 0.12%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           develop     #20      +/-   ##
==========================================
+ Coverage    90.78%   90.9%   +0.12%
==========================================
  Files           46      47       +1
  Lines          423     429       +6
==========================================
+ Hits           384     390       +6
  Misses          39      39

Impacted Files
Coverage Δ

familias/migrations/0005_auto_20170225_0116.py
100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9c30b5...66cab5c. Read the comment docs.

authors: codecov-io fernandolobato


text:
Different input frequencies are getting played as the same output frequency

In #2 I referenced a bug I was investigating. Here it is.
Background
I'm trying to use this library to prototype a personal data over sound project. I'm working on using the presence of a sound at any of 24 different frequencies to convey the data my application needs. Eventually I will be using several of these frequencies in parallel, which maps really well to this package's support of different tracks.
Issue
The issue I'm finding is that when I use this package to play a test sound at each of my chosen 24 frequencies I notice that some of the higher frequencies get played as the same tone.
Low Frequency Example
Here's the code:
from tones.mixer import Mixer
from tones import SINE_WAVE
from playsound import playsound

mixer = Mixer(44100, 0.5)

mixer.create_track(1, SINE_WAVE, attack=0.01, decay=0.1)

mixer.add_tone(1, 799.872020476724, .5)
mixer.add_tone(1, 899.604174163368, .5)
mixer.add_tone(1, 1000.40016006403, .5)
mixer.add_tone(1, 1100.5943209333, .5)
mixer.add_tone(1, 1301.06687483737, .5)
mixer.add_tone(1, 1400.56022408964, .5)
mixer.add_tone(1, 1500.60024009604, .5)
mixer.add_tone(1, 1601.53747597694, .5)
mixer.add_tone(1, 1799.20834832674, .5)
mixer.add_tone(1, 1899.69604863222, .5)
mixer.add_tone(1, 2000.80032012805, .5)
mixer.add_tone(1, 2100.84033613445, .5)
mixer.add_tone(1, 2296.73863114378, .5)
mixer.add_tone(1, 2396.93192713327, .5)
mixer.add_tone(1, 2497.5024975025, .5)
mixer.add_tone(1, 2597.4025974026, .5)
mixer.add_tone(1, 2801.12044817927, .5)
mixer.add_tone(1, 2903.60046457607, .5)
mixer.add_tone(1, 3001.20048019208, .5)
mixer.add_tone(1, 3105.5900621118, .5)
mixer.add_tone(1, 3306.87830687831, .5)
mixer.add_tone(1, 3401.36054421769, .5)
mixer.add_tone(1, 3501.40056022409, .5)
mixer.add_tone(1, 3607.50360750361, .5)

mixer.write_wav('tones.wav')
playsound('tones.wav')

And here's a spectrogram of the frequencies I'm getting as a result:

High Frequency Example
It appears as though playing higher frequencies exacerbates the problem. This code plays the same frequency intervals (not note intervals) but starting 3000 Hz higher than the previous example.
from tones.mixer import Mixer
from tones import SINE_WAVE
from playsound import playsound

mixer = Mixer(44100, 0.5)

mixer.create_track(1, SINE_WAVE, attack=0.01, decay=0.1)

mixer.add_tone(1, 3990.42298483639, .5)
mixer.add_tone(1, 4105.09031198686, .5)
mixer.add_tone(1, 4201.68067226891, .5)
mixer.add_tone(1, 4302.92598967298, .5)
mixer.add_tone(1, 4492.36298292902, .5)
mixer.add_tone(1, 4608.29493087558, .5)
mixer.add_tone(1, 4699.24812030075, .5)
mixer.add_tone(1, 4793.86385426654, .5)
mixer.add_tone(1, 4995.004995005, .5)
mixer.add_tone(1, 5102.04081632653, .5)
mixer.add_tone(1, 5213.76433785193, .5)
mixer.add_tone(1, 5291.00529100529, .5)
mixer.add_tone(1, 5494.50549450549, .5)
mixer.add_tone(1, 5580.35714285714, .5)
mixer.add_tone(1, 5714.28571428571, .5)
mixer.add_tone(1, 5807.20092915215, .5)
mixer.add_tone(1, 6002.40096038415, .5)
mixer.add_tone(1, 6105.0061050061, .5)
mixer.add_tone(1, 6211.1801242236, .5)
mixer.add_tone(1, 6321.11251580278, .5)
mixer.add_tone(1, 6493.50649350649, .5)
mixer.add_tone(1, 6613.75661375661, .5)
mixer.add_tone(1, 6675.56742323097, .5)
mixer.add_tone(1, 6802.72108843537, .5)

mixer.write_wav('tones.wav')
playsound('tones.wav')

Here's the resulting spectrogram.

Other Thoughts
I'm wondering if this has something to do with how this package focuses on playing specific notes (i.e. music composition). Perhaps my frequencies are simply getting rounded to the closest note? I didn't see anything that would seem to be doing that in the mixer.add_tone() function, but it's an idea that I've had nagging at me while I look through things.
I'm happy to help develop a solution to improve this great package, I'm just getting stuck when I tackle it on my own. Hoping @eriknyquist  has some added insight into why this might be occurring.

@jhale1805 I think you hit the nail on the head when you said "I'm wondering if this has something to do with how this package focuses on playing specific notes (i.e. music composition)?"
I never did any sort of detailed testing of specific frequencies, like you are doing now. This module was very much intended for producing musical tones, and the extent of my testing was pretty much just using my ears to make sure things sound musically OK.
That being said, I will take a look at the code which handles specific frequency values, and see if there is an obvious problem that could cause such a loss of precision.
Thanks!

@jhale1805 I can possibly help speed up your investigation; the problem is most likely with the _sine_wave_table function here https://github.com/eriknyquist/tones/blob/master/tones/tone.py#L6
This function is called by the Tone.samples() function (right here https://github.com/eriknyquist/tones/blob/master/tones/tone.py#L197), to obtain a set of samples that make up a single 360 degree sine wave oscillation in the desired frequency/sample rate/amplitude.
The Tone.samples() function then iterates over this table multiple times, as many times as is needed to create the number of samples we need for the requested note time.
My guess is that there is some loss of precision that occurs when I do period = int(rate / freq) in the _sine_wave_table function, and this is what's causing the anomaly you're seeing where the output seems to "snap" to certain frequencies.
I'm not sure exactly how I would resolve that, right now, but this is the area I'm drawn to right now based on your description.

OK, so after I explained that to you I'm thinking that the problem is indeed _sine_wave_table, or more specifically, the approach of generating a single period's worth of sine wave samples and then duplicating it multiple times to get the desired note length.
This approach assumes that the full period of any sine wave at any frequency can be described by a discrete number of samples, when in reality, the full period of a sine wave is likely going to have some "fractional" sample at the end (e.g. a full period of 1555Hz, at 44100 sample rate, works out to 28.36 samples), unless the sine wave frequency happens to be an exact multiple of the sample rate.
This might also explain the weird harmonics reported in #1, since the issue I described above would result in sine waves that are not perfect-- there would be little "blips" in the waveform between every period, which I'm guessing would result in some odd harmonic content.
I think the correct way to do this would be to generate all samples for the full note length at once, instead of just doing a single period and then duplicating it, just like is being done in this stackoverflow answer;
https://stackoverflow.com/questions/8299303/generating-sine-wave-sound-in-python
I don't have time to work on it and test it right now (I can get to that next weekend), but I thought I would just dump that info here in case it helps you out.

I think you're on to something. I plotted the output waveform using this Stack Overflow post as a guide (https://stackoverflow.com/a/18625294) and got the following output (zoomed in a lot).

Just as you predicted, there is an odd change of slope at the end of each period that I don't think can be attributed to the minor imperfections introduced by using digital samples instead of an analog signal.
I'll try out the solution you found and give another update in a bit.
Just for reference, the exact code that produced that image
from tones.mixer import Mixer
from tones import SINE_WAVE

mixer = Mixer(44100, 0.5)

mixer.create_track(1, SINE_WAVE, attack=0.01, decay=0.1)

mixer.add_tone(1, 2597.4025974026, .25)
mixer.add_tone(1, 2695.41778975741, .25)
mixer.add_tone(1, 2801.12044817927, .25)
mixer.add_tone(1, 3001.20048019208, .25)
mixer.add_tone(1, 3105.5900621118, .25)
mixer.add_tone(1, 3203.07495195388, .25)
mixer.add_tone(1, 3306.87830687831, .25)
mixer.add_tone(1, 3501.40056022409, .25)
mixer.add_tone(1, 3607.50360750361, .25)
mixer.add_tone(1, 3700.96225018505, .25)
mixer.add_tone(1, 3799.39209726444, .25)

mixer.write_wav('tones.wav')

#Addition
import wave
import numpy as np
import matplotlib.pyplot as plt

spf = wave.open('tones.wav')

signal = spf.readframes(-1)
signal = np.fromstring(signal, "Int16")

plt.plot(signal)
plt.show()
#/Addition

After some more tinkering it looks like your suggested solution works great!
The "Low Frequency" code from my original post now registers on the spectrogram as expected:

In addition to each distinct input frequency now getting its own distinct output, you'll notice that my original screenshot had a thin green line showing that the output frequency of the twelfth tone was 2203 Hz - a full 103 Hz off of the original ~2100 Hz. This new version now plays that same twelfth tone at 2103 Hz - only 3 Hz off of the original.
The harmonics are still present, but not as harshly as before.
The "High Frequency" example also works much better now:

And the output wave form also pretty much looks like a perfect sine wave.

You'll see that I submitted a merge request with my solution. As indicated there, I only tested for my specific use case, so you'll want to make appropriate updates to the other waveforms you support that I'm not as familiar with before re-publishing this package to pip.
Thanks again for this great package and your help with this issue!

authors: eriknyquist eriknyquist-avive jhale1805

repo: eriknyquist/tones


text:
Best practice to manipulate a field's value

Assume that I need to change the value of username input field upon the change of last name field. The reason why the username should be kept on the input is to let the user manipulating it. The way to do it is to call the change action to change the value of username input. But we need to override the onChange prop on lastName input. It seems sloppy and I wonder if it has drawbacks.
<input {...lastName} />
<input {...username} />

The best practice to manipulate field2's value based on field1's value is to use a normalizer.

Thanks.
One other thing, let's say if there was no field1. For example, if we needed to change lat and lng pair input values by dragging around a marker on a Leaflet or Google map.

Same thing. If you want to restrict a value based on anything, you can "normalize" it. The code in the readme shows how to keep a string value in all upper case, for example. Just as easy to keep a lat-long coordinate within a certain radius.

No I didn't mean to keep it in a certain radius. See the image. I mean changing those values by dragging that blue marker while the users can change it themselves.

Normalizing is done in reducer. What I say is in component layer.

Sure, that can be done with onChange calls. Ideally, you'd have a map component that would either call onChange as the user drags the marker, and/or onBlur when the marker was dropped.

I got it. :+1: Thanks.

@erikras, do you mean call the this.props.fields.xxx.onChange() directly?

@xcatliu Yes, you may do that. If onChange receives an event (if it was passed to an input), it will try to get the value from the event.target, but you can also just call onChange(newValue).

@erikras Thx~

@erikras How can I know the ending of onChange? Is there any API like this:
onChange(newValue, callback);

No, onChange is synchronous.

@erikras If I call this.props.handleSubmit() after onChange, the values seems not update. Code fragment:
handleClick() {
  // do something
  this.props.fields.xxx.onChange(newValue);
  console.log(this.props.values);                       // not update
  this.props.handleSubmit();                              // submit old values
}

That is true. The props get repopulated on a subsequent process tick.
I suspect that there is a flaw in your design if you are wanting to onChange and handleSubmit in the same code block. But you could conceivably do something like:
this.props.onSubmit({ // <---- what handleSubmit would call
  ...this.props.values,
  xxx: newValue
});

@erikras Yes I get it, thanks for helping me!

Is there any way to change multiple values at once without using initialize()? What I'm doing right now is:
const values = getValues(form.signupPF);

initialize('signupPF', Object.assign({}, values, {
  address,
  neighborhood,
  city,
  state
}), Object.keys(fields));

Is this correct?

@gabrielhpugliese No, there is no form of the CHANGE action that works on multiple fields. If you didn't want to use initialize, which will affect your dirty/pristine state, you will have to dispatch the CHANGE actions individually for each field.

No problems with initialize, just to know if it would be OK or would cause some weird side-effect. Thanks.

@erikras when I'm trying to call this.props.onSubmit I'm getting Uncaught TypeError: this.props.onSubmit is not a function. I also don't find it in http://erikras.github.io/redux-form/#/api/props - maybe the api has changed?

...I'm using 4.1.4.

Tried this.props.handleSubmit?
On Thu, Feb 11, 2016 at 5:33 PM Anselm Christophersen <
notifications@github.com> wrote:

...I'm using 4.1.4.
—
Reply to this email directly or view it on GitHub
https://github.com/erikras/redux-form/issues/152#issuecomment-183025937.

Yeah, that works, but I want to pass additional data, like this:
this.props.onSubmit({ // <---- what handleSubmit would call
  ...this.props.values,
  xxx: newValue
});

Also this.props.handleSubmit(); seems to work, while doing this and trying to manipulate the data seems to just fail silently.
this.props.handleSubmit(data => {

});

@anselmdk Because onSubmit is a specific proprietary prop for redux-form, it is removed from the props. You will need to call your prop something else (e.g. submitForm) for it to show up in the props of your decorated component.

@erikras thanks. In the end I ended up using the solution with the hidden field, as I also needed to do some different validation based on the field value - seems to work okay!

@erikras

The props get repopulated on a subsequent process tick

I am using async validation to fetch postal code from server once member changes it.
Member also has ability to change country, thus I need to rerun the validation on country change.
Currently I delay the postal code field touch to allow country field to update it's value.
Is there an option to determine when the field got updated such that I don't wait too long or too short?

the ability to run onChange on multiple values in one action would be great. Or rather, in my situation, I want to replace an entire subdocument array with a new one.
In other words, I have a "field": 'collectionFields[].orderNum'. collectionFields is an array of input fields my users can configure and reorder. So I'm changing the orderNum values for collectionFields. I was hoping to just take my array of collectionFields, change the ordering of them, and replace it with an identical array of redux-form objects, but with new values for orderNum. (my reordering component returns a new array of objects with orderNum values) Something like:
this.props.fields.collectionFields.replace(orderedFields) This assuming orderedFields is an array of redux-form instances (or whatever you call them).
My alternative working solution for now is:
this.props.fields.collectionFields.map((myFormField, index) => {
      myFormField.orderNum.onChange(orderedFields[index].orderNum.value)
    })

It's annoying though, because the redux-form/CHANGE action is dispatched a whole bunch of times for what seems could be done in a single action.
Just an enhancement recommendation.

Hi, I'm trying to do this:
addressUpdated(newAddress) {
    //TODO, tell Redux form that a value is now available!
    this.props.fields.address.onChange(newAddress.label);
  }

address is a hidden field that should get a value once addressUpdated is called.
I get an error
Uncaught TypeError: Cannot read property 'onChange' of undefined

Component is generated:
<Field id="address" name="address" type="hidden" component={fieldFactory} />

const fieldFactory = ({id, input, label, type, meta: { touched, error } }) => {
if(type.match(/hidden/)){
    return(

      <input id={id} {...input} type={type} />
      {touched && error && {error}}

    );
  }
}

Any ideas?

@szokrika I had the same issue when migrating from v5 to v6. I solved it like this by giving a ref  and adding withRef={true} to the Field I would like to modify.
<Field type='text' ref='name' withRef={true} label='Name' name='Name' component={renderInput} value={this.state.location.name}/>
When I want to change the field value I do this
this.refs.name.getRenderedComponent().props.input.onChange(newName);
Please note this Cannot be used if your component is a stateless function component

Hey!
Im kinda new to react. And couldn't figure out how and where i should rewrite my onChange to get things working. PS. Im using react-select as my selectInput component.
here is part of my form. I would appriciate of any concrete examples with the custom onChange.
const BasicForm = props => {
const { error, handleSubmit, pristine, reset, submitting, countries, phonePrefixes } = props;
return (

            <form onSubmit={handleSubmit}>
                <Field
                    name="country"
                    className="form-control"
                    component={selectInput}
                    options={countries}
                    placeholder="Country"
                />
                <Field
                    name="phonePrefix"
                    className="form-control"
                    component={selectInput}
                    options={phonePrefixes}
                    placeholder="Prefix"
                />

                <button type="submit" disabled={submitting}>REGISTER

                </button>
            </form>

)};

@Jevgenius in your case you should write the custom onChange in the selectInput file, and pass this custom onChange to the react-select.

@erikras i'm using redux-form v6, where is props.fields property ? i can't find it in the api document, Does it be removed ?

@zackshen It was removed, see the v5->v6 migration guide

Stories
storiesOf("URLField", module)
.add("default", () => (

))
code
const URLField = ({ validUrl , urlDescription, primaryLabel, warningText, secondaryLabel }) => (

{primaryLabel}
{secondaryLabel}

{urlDescription}

{warningText}

);
CSS
input {
text-align: right;
display: inline-block;
padding: 10px 2px;
background: ${props => props.validUrl === "true" ? url(${valid}) no-repeat left 10px center : url(${invalid}) no-repeat left 10px center};
}
Any idea about how to change background

@xcatliu if i may ask, where did you get the reference this.props.fields.xxx.onChange()? i wanted to try this, i cannot seems to get the fields reference from onchange of my first field?

authors: Jevgenius anmol1591 anselmdk astrauka chaitanya0bhagvan erikras gabrielhpugliese himawan-r joaoreynolds kaueburiti mohebifar saitonakamura szokrika xcatliu zackshen

repo: erikras/redux-form


text:
resetForm() leaves a ↵ when executed.

I have this form:
/**
 * React component MessagesForm
 */

import React, { PropTypes } from 'react'
import {reduxForm, reset} from 'redux-form'

const MessagesForm = p => {

  const {fields: {message}} = p

  const addMessage = e => {
    if(e.keyCode == 13 && e.shiftKey == false) {

      p.handleSubmit()
      p.resetForm()

    }
  }

  return (
    <form onSubmit={p.handleSubmit}>
      <div className="form-group">

        <textarea
          {...message}
          value={message.value || ""}
          rows="1"
          type="text"
          className="form-control"
          onKeyDown={addMessage}
          placeholder="Escribe tu mensaje y presiona Enter para enviar." />

      </div>
    </form>
  )
}

const form = reduxForm({
  form: 'message',
  fields: ['message']
})(MessagesForm)

export default form

As you can see the form is submitted when the user press the enter key (↵) and is not pressing shift. after handling the submit i reset the for immediately, but it leaves a ↵ sign instead of an empty string, so it can show the placeholder again.
I need to be reset to an empty string instead of a ↵, how can i do this?

As a workaround, adding setTimeout(p.resetForm, 1) makes it work. Still looking for a solution.

Shouldn't you have a e.preventDefault() to prevent the ↵ from making it into the input?

@erikras thanks!!! :D

Reopen if this is not solved.

authors: erikras nschurmann


text:
Remove stable RNA

Use the tool in the same package as BBMap.

Fixed in 94e634465505874002b4431c4988b9b5df34eccd with --sequence_filter parameter.

repo: erikrikarddaniel/magmap


text:
Support multiple instances of each module

Currently, every module in the Glk JS ecosystem is a global object (window.GlkOte, window.Dialog, window.Quixe, etc). We would like to support the possibility of more than one. It should be possible to create instances of each and start them running, with each one talking only to its peers.
This was one of the issues mentioned when talking about ES modules (https://github.com/erkyrath/glkote/pull/39). However, I want to address this separately and first.
The plan is as follows:
Every module will define a JS class (e.g. GlkOteClass). (Recall that JS classes are just functions that you instantiate by writing new GlkOteClass().)
For backwards compatibility, each module will define an instance of its class (GlkOte). If you load the module.js in the old-fashioned way, you will wind up with window.GlkOteClass and window.GlkOte. A page can go ahead using window.GlkOte just as before. However, you can create more instances as needed.
An instance must be inited by calling its init() method. You may pass in associated module instances if you want:
GlkOte.init({ Dialog: new DialogClass() });

If you don't, the instance will create its own module instances where needed.
Each class has two new methods:

inited(): Returns whether the instance has been succcessfully inited.
getlibrary(val): Returns the associated module instance by name.

For example, GlkOte.getlibrary('Dialog') will return the Dialog instance being used by that GlkOte instance. Glk.getlibrary('GlkOte') will return the GlkOte being used by that Glk API instance. And so on.
When implementing higher-level modules, it's generally cleaner to fetch low-level modules using getlibrary() rather than trying to cache a reference at init() time. (Init order is a pain in the butt.)

I have gone through and done this for all the modules in the glkote repo. Quixe is not yet done.

Why an init method rather than passing in the references to the constructor?

One, that's the way it works now, and I don't want to mess around with it too much. (window.GlkOte is provided as a constructed instance which has not yet been initialized.) Two, instances need to be initialized with references to each other. (E.g. Dialog needs a reference to GlkOte and vice versa.) So you need to construct them both, then initialize them.
(I see I forgot Dialog.getlibrary(), oops.)

Ahh, I hadn't thought there were any circular references, but that's because I had changed Dialog to use console.log instead of GlkOte.log.

The plan that got implemented in 2020 seems to be doing the job.

authors: curiousdannii erkyrath

repo: erkyrath/glkote


text:
ERRAI-1111: Fix a bug with interrupting a navigation hide.

This will properly allow us to interrupt the hiding process in navigation.

Can one of the admins verify this PR? Comment with 'ok to test' to start the build.

Are we able to progress this issue?

@BenDol Can you provide a more detailed description of the issue?

So when I rewrote the navigation to support more complex use cases one of them was that we have the ability to interrupt the hiding navigation control inside of onHiding(NavigationControl) when you call interrupt on this NavigationControl object you expect it to retain the page you are currently on, but since the navigation process often has already started taking place the URL state will in most cases already be updated. So what this ensures is that the previous state of the page is restored after the hiding is interrupted.
We use this when we want to protect sensitive data input for example, so if a user attempts to click off the page we have the ability to properly cancel that navigation in the onHiding.

ok to test

Jenkins, please retest this.

@BenDol Could you please add some tests to the behaviours this PR adds?
Thanks!

Can one of the admins verify this PR? Comment with 'ok to test' to start the build.

Build finished. No test results found.

Build finished. 2762 tests run, 5 skipped, 0 failed.

Build finished. 2763 tests run, 7 skipped, 0 failed.

authors: BenDol kie-ci kiereleaseuser2 tiagobento

repo: errai/errai


text:
Add mailhog support to docker-compose.yml example

This took me longer than I'd like to admit to figure out how to properly integrate MailHog into one of my own projects' dev environments, so I thought I'd save someone the time and add MailHog to the example docker-compose.yml.
MailHog will catch all outgoing mail from Moodle so that you can easily debug/troubleshoot without worrying about actually sending emails or accidentally exposing your SMTP credentials in your codebase.
Also fixed a merge conflict in the README.

Hi @aleciavogel,
Thanks for your contribution! The addition of MailHog support to the example docker-compose.yml is a thoughtful enhancement. This will undoubtedly be a great help in debugging and troubleshooting, especially in preventing accidental exposure of SMTP credentials.
I appreciate the time you took to integrate MailHog into the alpine-moodle project and for taking a step further to share this with the community. Your effort to resolve the merge conflict in the README is also recognized and appreciated.
Before we merge this, I'll run some tests to ensure everything works as expected. I'll get back to you soon.
Thanks again for your contribution!
Best

Hi @aleciavogel,
Thanks again for your valuable contribution. However, after reviewing the MailHog project, it seems to be inactive, as indicated in this issue: https://github.com/mailhog/MailHog/issues/442. This could potentially lead to support and maintenance issues down the line.
Considering this, what are your thoughts on integrating "maildev" instead, as suggested in the aforementioned issue? You can find more about it here: https://maildev.github.io/maildev/. It appears to be actively maintained and could serve the same purpose effectively.
Please let me know your thoughts on this proposed change.
Thanks again for your input and looking forward to your response.
Best

Hey Ernesto,
Thank you for your consideration and thoughtful responses! MailHog has always been my go-to but MailDev sure looks neat. I'll revise my PR to use MailDev instead!

Unfortunately, I can't seem to get MailDev to work with your image and it's not immediately apparent as to why it's not working. I've consulted the issues for the MailDev repo to see if anyone has encountered something similar. I've tried switching between "tls" and "tcp" for the protocol env variable in the moodle service to no avail, as well as setting incoming and outgoing usernames and passwords for MailDev. Even if I don't get an error upon sending the "Lost your password?" email, it never shows up in the MailDev UI.
Feel free to take a crack at it

authors: aleciavogel erseco

repo: erseco/alpine-moodle


text:
Add License

Hello
Congrats!
As any open source project, we must declare our licensing policy.

Done! Thanx.

authors: cengizIO ersinerdal

repo: ersinerdal/react-redux-immutable-ddd


text:
Issues with multiple block-level elements in definition lists

As tested on the parsedown demo: http://parsedown.org/demo?extra=1
this code does not render as it should within the definition list:
Term 1

:   This is a definition with two paragraphs. Lorem ipsum
    dolor sit amet, consectetuer adipiscing elit. Aliquam
    hendrerit mi posuere lectus.

    Vestibulum enim wisi, viverra nec, fringilla in, laoreet
    vitae, risus.

:   Second definition for term 1, also wrapped in a paragraph
    because of the blank line preceding it.

Term 2

:   This definition has a code block, a blockquote and a list.

        code block.

    > block quote
    > on two lines.

    1.  first list item
    2.  second list item

For reference: https://michelf.ca/projects/php-markdown/extra/#def-list

Thought I would provide some visuals:

Thanks.
I'll look into this as soon as I resolve #4.

Sweet! Thanks for fixing this!

authors: erusev rhukster

repo: erusev/parsedown-extra


text:
Use fixed number of threads in test262-test concurrent mode

This PR makes following changes:

Change -test262-test:concurrent option to be number.
Use fixed number of threads in test262-test concurrent mode.

It is expected to resolve issue #251 (if proper number of threads is given).

Now concurrent and timeout options work well together.
esmeta test262-test -test262-test:progress -test262-test:log \
-test262-test:concurrent=16 -test262-test:timeout=60

# ...
100.00% (48,376/48,376) - P:N = 25,276:23,100 => P/P = 25,276/25,276 (100.00%) [07:58]
# ...
- pass-rate: P/P = 25,276/25,276 (100.00%)

$ esmeta test262-test -test262-test:progress -test262-test:log -test262-test:timeout=60 -test262-test:concurrent=16
# ....
100.00% (48,376/48,376) - P:N = 25,276:23,100 => P/P = 25,276/25,276 (100.00%) [07:52]

repo: es-meta/esmeta


text:
get rid of QConv1d and co.

With pytorch 3.10 the concept of parametrization was introduced... Now pytorch provides a native way for us to inject and apply arbitrary modules to other modules parameters before they are used... E.g. A module behaving equivalently to QConv1d with Binarize can be built like this
import torch
from torch.nn import Conv1d
from torch.nn.utils.parametrize import register_parametrization
from elasticai.creator.layers import Binarize

layer = Conv1d(in_channels=2,
               out_channels=3,
               kernel_size=(1,),
               bias=False)

register_parametrization(layer, "weight", Binarize())

Therefore ~neither~ the implementations of our quantizable convolutions ~nor of our qlstm cells~ should [not] be needed anymore.
If we decide to still keep the implementations we should implement them with the help of parametrization.

edited description: In fact from what i can tell there is no easy way to set custom activations to be used in the RNN layers, so we still require a custom implementation to realize something like our QLSTM


text:
Seeing intermittent future_key errors

2023-04-25 23:12:39 ERROR:flask_shell2http:future_key ebbb407f already exists 2023-04-25 23:12:39 ERROR:flask_shell2http:No report exists for key: 'ebbb407f'.
These are interspersed with working calls.
I turned off wait=true and switched to polling. This reduced the problem but didn't eliminate it.
Are there any docs on how to endure the key doesn't already exist? I don't believe I'm managing the keys externally to shell2http.
Thanks so much.

Can you also tell if your clienttries to execute same command with the same args multiple times? If that is the case, you might wnat to set the force_unique_key parameter to true (see example).

Ah this explains it. Yes, several calls with the same parameters are possible. I'll have a look at how to force_unique_key. Thanks for the followup.


text:
Bug: false positive for security/detect-object-injection

What version of eslint-plugin-security are you using?
2.1.0
ESLint Environment
Node version: v20.10.0
npm version: v10.2.3
Local ESLint version: 8.56.0
Global ESLint version: Not found
Operating System: linux 6.2.0-1018-azure
What parser are you using?
Default (Espree)
What did you do?
minimal reproduction repo: https://github.com/AnnAngela/eslint-plugin-security-rules-detect-object-injection
What did you expect to happen?
Nothing reported.
What actually happened?
https://github.com/AnnAngela/eslint-plugin-security-rules-detect-object-injection/actions/runs/7406514870/job/20151079711#step:6:7
Participation

[ ] I am willing to submit a pull request for this issue.

Additional comments
According to the docs, I did not do any value assignment and the warning should not be reported.

From what I can tell, this rule is behaving as expected and the documentation needs updating. It currently flags any function call for which an argument in the form object[key] is passed. An assignment isn't necessary, especially because, in your case, foo is being read from the environment.

@nzakas THX but can you explain a bit more clearly why the assignment isn't necessary?
I don't understand that why the obj[foo] would cause harm even though foo is "construct" or other special string.

authors: AnnAngela nzakas

repo: eslint-community/eslint-plugin-security


text:
Bug: Local development broken

URL(s)
(All)
What did you do?
Tried writing a new blog post with a date in the future.
What did you expect to happen?
I expected the blog post to be visible at https://localhost:2022/blog. We had this set up so that future posts would be shown locally to make it easier to debug, but then would not be shown on the live site.
I also expected the blog to update whenever I edit the Markdown file.
What actually happened?
The blog post does not show up on the blog page, and even if I hack it so that it does show up, the blog post is not being watched for changes so I need to stop and restart the server just to see changes.
Participation

[ ] I am willing to submit a pull request for this issue.

Additional comments
There were a bunch of changes made to package.json that I believe are causing both of these issues.
For some reason, the environment variable CONTEXT is now being set here:
        "watch:eleventy": "cross-env CONTEXT=dev eleventy --serve --port=2022",

However, we specifically expect no CONTEXT to determine whether or not to show future blog posts.
I'm not sure why watching isn't working otherwise. It appears to work for .js files but it does not work for .md files.

https://github.com/eslint/eslint.org/blob/427e3bc27aff8e5189b240cb36187234d8281d63/package.json#L20
Renaming the CONTEXT  env fixes this issue.

authors: amareshsm nzakas


text:
Clean up image API code paths

Most commits have individual descriptions, but at a high level I'm essentially getting rid of the complex mutually-recursing-across-processes behavior previously present in image.js. I've moved the part that actually calls into ImageMagick into its own file, so instead of commands calling magick.run which calls the image API which calls magick.run again (or magick.run calling itself in a worker thread if the image API is disabled), magick.run and the image API both delegate to the new "call ImageMagick" function.
I've also gotten rid of some duplicate code for handling GIFs, removed some dead code relating to image types (it can be re-added later in a much cleaner way if needed), and fixed a bug where GIF-only commands would throw an internal error instead of displaying the intended "that isn't a GIF!" message.

When testing this out on my instance, something happened where it pulled the previous image instead of the current one when running the motivate command. No idea how these changes could have caused that (or if they even did) but I'll look into it.

When testing this out on my instance, something happened where it pulled the previous image instead of the current one when running the motivate command. No idea how these changes could have caused that (or if they even did) but I'll look into it.

Never mind, it seems to be an issue with the dev bot as well.

Never mind, it seems to be an issue with the dev bot as well.

Looks pretty good.

Looks pretty good.

authors: TheEssem adroitwhiz

repo: esmBot/esmBot


text:
Add support for MCUboot

MCUboot support was added for the ESP32-C3 in #49, we should continue adding support for additional devices. There is interest in this from other teams within Espressif currently, and as such it is likely a useful feature for some community members as well.
See esp32c3_hal/src/lib.rs as a reference. Note that additional changes to linker scripts are required, too.

[ ] ESP32
[ ] ESP32-C2
[ ] ESP32-C3
[ ] ESP32-C6
[ ] ESP32-H2
[ ] ESP32-S2
[ ] ESP32-S3

In the meantime, support for ESP32-C3 was removed

I'm going to close this for now, as we have no plans on working on this any time soon. We can open a new issue if we decide to re-visit this.

authors: bjoernQ jessebraham

repo: esp-rs/esp-hal


text:
feat: Drop support for ESP-IDF 4.4 and Python 3.6

Description
This MR includes several fixes for the pipeline to pass:

The codereport maintainer has merged my MR (https://github.com/paulgessinger/codereport/pull/4) and released a new version 0.4.0. This should resolve dependency conflicts mentioned in: https://github.com/espressif/clang-tidy-runner/pull/46#issuecomment-2258096149
Update the version of actions because we were using a deprecated version, which does not work anymore. Failed job: https://github.com/espressif/clang-tidy-runner/actions/runs/10806704544/job/29976026469
Drop support for ESP-IDF 4.4 (which was the last to support Python 3.6 so this was dropped as well)

Reasons to drop ESP-IDF 4.4
TLDR: dependency hell
I was trying to make the pipeline work on the latest IDF, but there was a conflict with the pygments package because IDF required >=3.13. The requirement is coming from the codereport package, so I fixed that upstream and wanted to update the version here to match at least that version (codereport>=0.4.0).
Then I realized that we are still stuck with codereport version 0.2.5, because of Jinja2. The newest versions of codereport (3.1+) require Jinja2==3.1.1, but ESP-IDF has this requirement set to <3.1, so there was no way to satisfy both ESP-IDF 4.4 and the latest versions.
Considering that ESP-IDF 4.4 is not supported anymore, this is IMO the best solution.
This is now working in the CI with IDF 5.0+, but if we hit some dependency issue again we should remove the dependency on the codereport package, there is not a lot of code, mostly just templates for HTML, so we should consider implementing this ourselves.
Related
Internal tracker: IDF-10919

@dobairoland PTAL, this should be ready to merge.

repo: espressif/clang-tidy-runner


text:
BLE Notifications stop working after SPI init

Hi All,
I have a weird one for you.
I have a program that communicates over BLE (peripheral and central, connected as a peripheral) to a computer. The computer sends some commands and then sends a message to enable/initialise the SPI Master.
Before the SPI is enabled, the notifications work well, as expected. After the SPI is initialised (by calling spi_bus_initialize and spi_bus_add_device) the notifications cease to work.
I have discovered that the esp_ble_gatts_send_indicate function returns ESP_FAIL and with a bit of modification to the esp_ble_gatts_send_indicate function I seem to be getting the BT_STATUS_NOMEM error.
I have checked the amount of free heap to be above 80K at all times.
I have also tried increasing the BT task stack size to 8192. This didn't help.
The strange part that I mentioned earlier is that this only seems to happen when I build on windows (with the latest pre-compiled toolchain).
If I build with the exact same source code (IDF at the same commit with no changes, and Project at the same commit with no changes) on fedora (with the latest pre-compiled toolchain), the program works fine. All notifications are sent as expected, no BT_STATUS_NOMEM occurs.
We have tried to get to the bottom of this for a couple of days now to no success.
Is there anything that could be causing this?
I am sure it is something small or stupid that is causing this..
Please let me know if there is any more information that you would like.
@projectgus @igrr

Suggest that you post the two sets of bin/elf files

I've seen bugs that appear on certain machines only due to memory corruption of static data combined with the build order & layout (ie on different systems the object files are linked in a different order, leads to different order of static memory addresses in RAM).  So for some builds the memory corruption (buffer overflow, etc.) corrupts something harmless or lands in padding, but for other builds it may break something critical.
There is an item in our ticketing system to make IDF builds more reproducable to avoid this kind of phantom problem, but there are some technical sticking points before we can achieve this.
Unfortunately the heap debugging features don't extend to static memory, so if this is indeed static memory being corrupted then they're not useful. But you could try enabling heap poisoning and calling heap_caps_check_integrity() anyhow, just in case:
https://esp-idf.readthedocs.io/en/latest/api-reference/system/heap_debug.html#configuration
You can also manually look at the linker map files or symbol dumps (via objdump) from each of the ELF files, and look for anything which might stick out.

Hi all,
Thanks for your responses.
It seems to have been related to a globally declared variable that was not declared as static. It seems to have a name the same as found in lots of the ble stack (ret).
Declaring this variable locally in a function or adding static to the global declaration fixed the issue.

Hi @lucazader,
Glad you sorted this out.

It seems to have been related to a globally declared variable that was not declared as static. It seems to
have a name the same as found in lots of the ble stack (ret).

If there's a part of IDF that includes a globally declared variable with a generic name like "ret" then this is also a bug which we should fix. I had a quick grep of the BT stack code and can't see any global symbol named "ret" (lots of local variables using this name). If you think there may be such a bug here then please reopen the issue.

Hi @projectgus
It was a global variable called "ret" in my code, however it seemed to conflict with the local ret variables, or at least one of them.
Not 100% sure what was going on. l But it definitely was to do with that variable.

authors: lucazader negativekelvin projectgus

repo: espressif/esp-idf


text:
Lacking double-checked locking optimization leads to significantly slower code for static local variables on RISC-V (IDFGH-12004)

Answers checklist.

[X] I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
[X] I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
[X] I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.
release/v5.1 and master
Espressif SoC revision.
esp32c6: v0.1, esp32c3: v0.4
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
Development Kit.
esp32c3: custom | esp32c6: esp32-c6-devkitc-1-n8 | esp32s3: custom
Power Supply used.
USB
What is the expected behavior?

C++11 standard requires the thread-safe, on-demand initialization of local static variables N2660, so GCC introduce a guard variable and guard functions to protect the underlying static variable.

When first time control passes through their declaration, the guard functions __cxa_guard_*  are called and ensure the successful initialization must be performed exactly once.
The guard variable records the current state of the local static variable.
Guard functions require some synchronization mechanisms to work, so they're somewhat heavy.
GCC introduce another inlined check (double-checked locking optimization) to bypass the guard functions after the local static variable successfully initialized.

Problem: Some targets may lack the double-checked locking optimization, and the guard functions are always called no matter whether the local static variable is initialized or not.

What is the actual behavior?

Accessing to the local static variable on some targets/gcc combination are significantly slower than others.

After a bit of disassembling, I found the double-checked locking optimization is missing from all RISC-V targets on GCC 12.2, and still missing from RV32IMC targets on GCC 13.2.

Affected targets:

IDF ver.
GCC ver.
C2
C3
C6
H2
P4
S3 (XT)

release/v5.1
riscv32-esp-elf/esp-12.2.0_20230208
+
+
+
+
x
-

master
riscv32-esp-elf/esp-13.2.0_20230928
+
+
-
-
-
-

'+' for affected, '-' for not affected, 'x' for not supported.
S3 is an Xtensa target, not affected by this problem. Just for comparison.

Summary of the implemented ISA extensions for each RISC-V target:

Target
Implemented ISA Ext.

ESP32-C2
rv32imc_zicsr_zifencei

ESP32-C3
rv32imc_zicsr_zifencei

ESP32-C6
rv32imac_zicsr_zifencei

ESP32-H2
rv32imac_zicsr_zifencei

ESP32-P4
rv32imafc_zicsr_zifencei

-march parameters were taken from the particular toolchain files.

Steps to reproduce.

Use the default config for the each target.
Design four test functions in the main/main.cpp.

Normal testing function for file-scoped static variable as baseline. main.cpp: rand_global_static()
Normal testing function for local static variable (testing function). main.cpp: rand_local_static()
Handcrafted testing function of the correctly implemented version of 2. main.cpp: rand_opt_handcraft_local_static()
Handcrafted testing function of the affected version of 2. main.cpp: rand_naive_handcraft_local_static()

Benchmark all of them.

For the expected code, performance of function 1.1 should be on par with 2.1 (Target with -march=rv32imac_zicsr_zifencei and compiled with GCC 13.2)
For the affected code, performance of function 1.1 should be similar to 2.4(Target with -march=rv32imc_zicsr_zifencei and compiled with GCC 13.2 and 12.2)

Debug Logs.
* Only C3 and C6 have been tested on the real machine. Followings are some results for {c3, c6} x {release/v5.1, master}.

* Benchmark results

  * Targets with affected codegen

    * ESP32-C3, release/v5.1

      I (135181) local-static: native local static duration:                    266015 \
      I (135181) local-static: optimized handcrafted local static duration:      13537 |
      I (135181) local-static: naive handcrafted local static duration:         266021 /
      I (135191) local-static: global static duration:                            9031
      I (135201) local-static: penalty of local static: 96.605%
      ```

    * ESP32-C3, master

      ```
      I (26840) local-static: native local static duration:                    202079 \
      I (26840) local-static: optimized handcrafted local static duration:      14353 |
      I (26850) local-static: naive handcrafted local static duration:         201665 /
      I (26860) local-static: global static duration:                            9440
      I (26860) local-static: penalty of local static: 95.329%
      ```

    * ESP32-C6, release/v5.1

      ```
      I (58125) local-static: native local static duration:                    272966 \
      I (58125) local-static: optimized handcrafted local static duration:      13946 |
      I (58135) local-static: naive handcrafted local static duration:         272560 /
      I (58145) local-static: global static duration:                            9031
      I (58145) local-static: penalty of local static: 96.692%
      ```

  * Target with expected result:
    * ESP32-C6, master

      ```
      I (62305) local-static: native local static duration:                     13944 \
      I (62305) local-static: optimized handcrafted local static duration:      13535 /
      I (62315) local-static: naive handcrafted local static duration:         199632
      I (62315) local-static: global static duration:                            9030
      I (62325) local-static: penalty of local static: 35.241%
      ```

* Disassembly of the expected code:

  * ESP32-C6, master

    ```
    420082b8 <rand_local_static()>:
    {
    420082b8:              1141                     add     sp,sp,-16
    420082ba:              c606                     sw      ra,12(sp)
            static prng_t s_pv_rng;
    420082bc:              4080c7b7                 lui     a5,0x4080c
    420082c0:              4e87c783                 lbu     a5,1256(a5) # 4080c4e8 <guard variable for rand_local_static()::s_pv_rng>

    // Here's a fence to safely load the ready flag from the guard variable.

    420082c4:              0ff0000f                 fence
    420082c8:              0ff7f793                 zext.b  a5,a5

    // Double-checked to bypass the heavy __cxa_guard_* guard functions.

    420082cc:          /-- cb85                        beqz    a5,420082fc <rand_local_static()+0x44>
            _M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x);
    420082ce:       /--|-> 4080c737                  lui     a4,0x4080c
    420082d2:       |  |   4f072503               lw      a0,1264(a4) # 4080c4f0 <rand_local_static()::s_pv_rng>
            _Tp __res = __a * __x + __c;
    420082d6:       |  |   41c657b7               lui     a5,0x41c65
    420082da:       |  |   e6d78793               add     a5,a5,-403 # 41c64e6d <g_saved_pc+0x13e4e71>
    420082de:       |  |   02f50533               mul     a0,a0,a5
    420082e2:       |  |   678d                   lui     a5,0x3
    420082e4:       |  |   03978793               add     a5,a5,57 # 3039 <RvExcFrameSize+0x2fa5>
    420082e8:       |  |   953e                   add     a0,a0,a5
                __res %= __m;
    420082ea:       |  |   800007b7               lui     a5,0x80000
    420082ee:       |  |   17fd                   add     a5,a5,-1 # 7fffffff <LP_ANA_PERI+0x1ff4d3ff>
    420082f0:       |  |   8d7d                   and     a0,a0,a5
            _M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x);
    420082f2:       |  |   4ea72823               sw      a0,1264(a4)
    }
    420082f6:       |  |   40b2                   lw      ra,12(sp)
    420082f8:       |  |   0141                   add     sp,sp,16
    420082fa:       |  |   8082                   ret
            static prng_t s_pv_rng;
    420082fc:       |  \-> 4080c537               lui     a0,0x4080c
    42008300:       |      4e850513            add     a0,a0,1256 # 4080c4e8 <guard variable for rand_local_static()::s_pv_rng>
    42008304:       |      d24fc0ef            jal     42004828 <__cxa_guard_acquire>
    42008308:       +----- d179                      beqz    a0,420082ce <rand_local_static()+0x16>
        { seed(__s); }
    4200830a:       |      4585                        li      a1,1
    4200830c:       |      4080c537            lui     a0,0x4080c
    42008310:       |      4f050513            add     a0,a0,1264 # 4080c4f0 <rand_local_static()::s_pv_rng>
    42008314:       |      f99ff0ef            jal     420082ac <std::linear_congruential_engine<unsigned int, 1103515245u, 12345u, 2147483648u>::seed(unsigned int)>
    42008318:       |      4080c537            lui     a0,0x4080c
    4200831c:       |      4e850513            add     a0,a0,1256 # 4080c4e8 <guard variable for rand_local_static()::s_pv_rng>
    42008320:       |      de2fc0ef            jal     42004902 <__cxa_guard_release>
    42008324:       \----- b76d                      j       420082ce <rand_local_static()+0x16>
    ```

  * ESP32-C3, release/v5.1 (handcrafted version of above-mentioned compiler-generated code)

    ```
    420077a6 <rand_opt_handcraft_local_static()>:
    {
    420077a6:              1141                     add     sp,sp,-16
    420077a8:              c606                     sw      ra,12(sp)
            uint8_t r = s_rng_guard_optimized.ready;
    420077aa:              3fc8c7b7                 lui     a5,0x3fc8c
    420077ae:              76c7c783                 lbu     a5,1900(a5) # 3fc8c76c <s_rng_guard_optimized>
            __sync_synchronize();
    420077b2:              0ff0000f                 fence
            if (!r) {
    420077b6:          /-- cb8d                    beqz    a5,420077e8 <rand_opt_handcraft_local_static()+0x42>
            _M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x);
    420077b8:       /--|-> 3fc8c737                  lui     a4,0x3fc8c
    420077bc:       |  |   76872503               lw      a0,1896(a4) # 3fc8c768 <s_rng_optimized>
            _Tp __res = __a * __x + __c;
    420077c0:       |  |   41c657b7               lui     a5,0x41c65
    420077c4:       |  |   e6d78793               add     a5,a5,-403 # 41c64e6d <_coredump_iram_end+0x18da66d>
    420077c8:       |  |   02f50533               mul     a0,a0,a5
    420077cc:       |  |   678d                   lui     a5,0x3
    420077ce:       |  |   03978793               add     a5,a5,57 # 3039 <_esp_memprot_align_size+0x2e39>
    420077d2:       |  |   953e                   add     a0,a0,a5
                __res %= __m;
    420077d4:       |  |   800007b7               lui     a5,0x80000
    420077d8:       |  |   fff7c793               not     a5,a5
    420077dc:       |  |   8d7d                   and     a0,a0,a5
            _M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x);
    420077de:       |  |   76a72423               sw      a0,1896(a4)
    }
    420077e2:       |  |   40b2                   lw      ra,12(sp)
    420077e4:       |  |   0141                   add     sp,sp,16
    420077e6:       |  |   8082                   ret
                    if (__cxxabiv1::__cxa_guard_acquire((__cxxabiv1::__guard *)&s_rng_guard_optimized)) {
    420077e8:       |  \-> 3fc8c537           lui     a0,0x3fc8c
    420077ec:       |      76c50513            add     a0,a0,1900 # 3fc8c76c <s_rng_guard_optimized>
    420077f0:       |      c34fd0ef            jal     42004c24 <__cxa_guard_acquire>
    420077f4:       +----- d171                      beqz    a0,420077b8 <rand_opt_handcraft_local_static()+0x12>
        { seed(__s); }
    420077f6:       |      4585                        li      a1,1
    420077f8:       |      3fc8c537            lui     a0,0x3fc8c
    420077fc:       |      76850513            add     a0,a0,1896 # 3fc8c768 <s_rng_optimized>
    42007800:       |      ef9ff0ef            jal     420076f8 <std::linear_congruential_engine<unsigned int, 1103515245u, 12345u, 2147483648u>::seed(unsigned int)>
                            __cxxabiv1::__cxa_guard_release((__cxxabiv1::__guard *)&s_rng_guard_optimized);
    42007804:       |      3fc8c537            lui     a0,0x3fc8c
    42007808:       |      76c50513            add     a0,a0,1900 # 3fc8c76c <s_rng_guard_optimized>
    4200780c:       |      cf4fd0ef            jal     42004d00 <__cxa_guard_release>
    42007810:       \----- b765                      j       420077b8 <rand_opt_handcraft_local_static()+0x12>
    ```

* Disassembly of the affected ()```:

  * ESP32-C3, release/v5.1
  * ESP32-C6, release/v5.1 (disassembly for these two targets are almost identical)
  * ESP32-C3, master (only slightly different from the previous one, omitted)

    ```
    42007706 <rand_local_static()>:
    {
    42007706:              1141                     add     sp,sp,-16
    42007708:              c606                     sw      ra,12(sp)
            static prng_t s_pv_rng;
    4200770a:              3fc8c537                 lui     a0,0x3fc8c
    4200770e:              77050513                 add     a0,a0,1904 # 3fc8c770 <guard variable for rand_local_static()::s_pv_rng>

    // Always call the guard function without checking
    42007712:              d12fd0ef                 jal     42004c24 <__cxa_guard_acquire>
    42007716:          /-- e90d                        bnez    a0,42007748 <rand_local_static()+0x42>
            _M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x);
    42007718:       /--|-> 3fc8c737                lui     a4,0x3fc8c
    4200771c:       |  |   77872503               lw      a0,1912(a4) # 3fc8c778 <rand_local_static()::s_pv_rng>
            _Tp __res = __a * __x + __c;
    42007720:       |  |   41c657b7               lui     a5,0x41c65
    42007724:       |  |   e6d78793               add     a5,a5,-403 # 41c64e6d <_coredump_iram_end+0x18da66d>
    42007728:       |  |   02f50533               mul     a0,a0,a5
    4200772c:       |  |   678d                   lui     a5,0x3
    4200772e:       |  |   03978793               add     a5,a5,57 # 3039 <_esp_memprot_align_size+0x2e39>
    42007732:       |  |   953e                   add     a0,a0,a5
                __res %= __m;
    42007734:       |  |   800007b7               lui     a5,0x80000
    42007738:       |  |   fff7c793               not     a5,a5
    4200773c:       |  |   8d7d                   and     a0,a0,a5
            _M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x);
    4200773e:       |  |   76a72c23               sw      a0,1912(a4)
    }
    42007742:       |  |   40b2                   lw      ra,12(sp)
    42007744:       |  |   0141                   add     sp,sp,16
    42007746:       |  |   8082                   ret
        { seed(__s); }
    42007748:       |  \-> 4585                   li      a1,1
    4200774a:       |      3fc8c537            lui     a0,0x3fc8c
    4200774e:       |      77850513            add     a0,a0,1912 # 3fc8c778 <rand_local_static()::s_pv_rng>
    42007752:       |      fa7ff0ef            jal     420076f8 <std::linear_congruential_engine<unsigned int, 1103515245u, 12345u, 2147483648u>::seed(unsigned int)>
            static prng_t s_pv_rng;
    42007756:       |      3fc8c537            lui     a0,0x3fc8c
    4200775a:       |      77050513            add     a0,a0,1904 # 3fc8c770 <guard variable for rand_local_static()::s_pv_rng>
    4200775e:       |      da2fd0ef            jal     42004d00 <__cxa_guard_release>
    42007762:       \----- bf5d                        j       42007718 <rand_local_static()+0x12>
    ```

More Information.

Workarounds:

constinit keyword for the type with constexpr constructor and default destructor.
Use file-scoped static variable instead rand_global_static();

Testing code:

CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

project(static-local-variable-test)

main/CMakeLists.txt
idf_component_register(SRCS "main.cpp")

main/main.cpp
#include "esp_log.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

#include <chrono>
#include <cxxabi.h>
#include <numeric>
#include <random>

// Faster if using power of two. Make cpu busy for a while.
using prng_t = std::linear_congruential_engine<unsigned, 1103515245, 12345, 1u << 31>;

static const char TAG[] = "local-static";

prng_t g_rng;
int rand_global_static()
{
    return g_rng();
}

/** @brief Normal local static getter */
int rand_local_static()
{
    static prng_t s_pv_rng;
    return s_pv_rng();
}

/**
 * @brief ABI-defined guard variable for local static variable and lock functions
 * @note  Defined in the ${IDF_PATH}/components/cxx/cxx_guards.cpp
 */
typedef struct {
    uint8_t ready;
    uint8_t pending;
} guard_t;

static guard_t s_rng_guard_optimized = {0, 0};
static prng_t s_rng_optimized;
int rand_opt_handcraft_local_static()
{
#ifdef __xtensa__
    // Only S3 has this extra fence
    __sync_synchronize();
#endif
    uint8_t r = s_rng_guard_optimized.ready;
    __sync_synchronize();
    if (!r) {
        if (__cxxabiv1::__cxa_guard_acquire((__cxxabiv1::__guard *)&s_rng_guard_optimized)) {
            new (&s_rng_optimized) prng_t;
            __cxxabiv1::__cxa_guard_release((__cxxabiv1::__guard *)&s_rng_guard_optimized);
        }
    }
    return s_rng_optimized();
}

static guard_t s_rng_guard_naive = {0, 0};
static prng_t s_rng_naive;
int rand_naive_handcraft_local_static()
{
    if (__cxxabiv1::__cxa_guard_acquire((__cxxabiv1::__guard *)&s_rng_guard_naive)) {
        new (&s_rng_naive) prng_t;
        __cxxabiv1::__cxa_guard_release((__cxxabiv1::__guard *)&s_rng_guard_naive);
    }
    return s_rng_naive();
}

static constexpr size_t repeat = UINT16_MAX;

template <int (*Fn)(void)>
static unsigned test_runner()
{
    unsigned randval = 0;
    std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
    for (size_t i = 0; i < repeat; i++) {
        randval += Fn();
    }
    std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
    unsigned dur = std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1).count();
    return dur;
}

static void test_task(void *)
{
    static constexpr auto width = std::numeric_limits<unsigned>::digits10;

    while (true) {
        auto dur_l = test_runner<rand_local_static>();
        auto dur_oh = test_runner<rand_opt_handcraft_local_static>();
        auto dur_nh = test_runner<rand_naive_handcraft_local_static>();
        auto dur_g = test_runner<rand_global_static>();
        ESP_LOGI(TAG, "native local static duration:                 %*u", width, dur_l);
        ESP_LOGI(TAG, "optimized handcrafted local static duration:  %*u", width, dur_oh);
        ESP_LOGI(TAG, "naive handcrafted local static duration:      %*u", width, dur_nh);
        ESP_LOGI(TAG, "global static duration:                       %*u", width, dur_g);
        ESP_LOGI(TAG, "penalty of local static: %.3f%%", (1.0f - (float)dur_g / dur_l) * 100.0f);
        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}

extern "C" void app_main()
{
#if portNUM_PROCESSORS > 1
    const BaseType_t core = 1;
#else
    const BaseType_t core = 0;
#endif
    TaskHandle_t p_tsk;
    assert(xTaskCreatePinnedToCore(&test_task, TAG, 4096, nullptr, CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT, &p_tsk,
                                core) == pdPASS);
}

Problem: Some targets may lack the double-checked locking optimization, and the guard functions are always called no matter whether the local static variable is initialized or not.

Unfortunately, I think this is probably expected, since the double-checked lock initialization using an atomic guard variable is only implemented in GCC on targets with support for atomic instructions (i.e. a extension on RISC-V):

Static initialization expansion relies on get_guard_cond (code)
get_guard_cond generates a constant zero expression if is_atomic_expensive_p is true (code)
is_atomic_expensive_p calls can_compare_and_swap_p with the 2nd argument (allow_libcall) set to false (code)

So if the target doesn't support atomics via instructions (only via library calls) then is_atomic_expensive_p will return true, and the atomic guard related code won't be generated.
I think this probably needs to be reported in upstream GCC as a "allow atomic libcalls for double-check guard implementation" type of a feature request.
Newer Espressif RISC-V chips should all have the "A" extension, so this probably won't be an issue going forward.

Hi igrr:
But even on the RV32IMAC targets (C6 and onward), it seems like the generated code doesn't utilize any instructions from the A extension at all?

That's right, the load operation generated by build_atomic_load_type is lbu, which isn't an atomic instruction. Since the "initialized" flag is represented by 1 byte, and we don't need to atomically modify the flag, it's not necessary to use lr/sc instructions there, so seems like the compiler is doing the right thing there.
Unfortunately, I don't know enough about other architectures which GCC targets to tell if there is a specific reason for using build_atomic_load_type there. I do see the same behavior for other architectures, though — https://godbolt.org/z/cz5cvabv8 illustrates the same issue on Xtensa. On ESP32-S2 (no atomic instructions) no double-checked locking is used, but on ESP32 (has atomic instructions) it is used.

authors: andylinpersonal igrr


text:
NO_AP_FOUND_IN_AUTHMODE_THRESHOLD while threshold's condition is respected (IDFGH-12863)

Answers checklist.

[X] I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
[X] I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
[X] I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.
v5.2.1
Espressif SoC revision.
ESP32-C6 v0.0
Operating System used.
Windows
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
Development Kit.
ESP32-C6-WROOM-1
Power Supply used.
USB
What is the expected behavior?
I expect the ESP32 STA to connect to the AP, as the STA threshold is set to WIFI_AUTH_WPA2 and the AP's authmode is set to >WPA2.
What is the actual behavior?
I am getting NO_AP_FOUND_IN_AUTHMODE_THRESHOLD, while the authmode.threshold in the STA is greater than AP's one.
No matter what threshold i put in authmode.threshold, the only AP configuration that it will connect to is WPA3
Steps to reproduce.

Set station config's authmode.threshold to anything/don't set it
Connect to a wifi network with a security inferior to WPA3

Debug Logs.
SCAN RESULT : SSID=TestReseau, AUTHMODE=3

I (241251) http_server: POST /connect.json
I (241261) http_server: ssid: TestReseau, password: Password1!
I (241261) wifi_manager: MESSAGE: ORDER_CONNECT_STA
I (241271) wifi_manager: wifi_sta_config: ssid:TestReseau password:Password1!
I (241281) wifi_manager: wifi_sta_config: sta_authmode 3
I (241291) wifi_manager: wifi_sta_config: RM enabled 1
I (241291) wifi_manager: wifi_sta_config: BTM enabled 1
I (241301) wifi_manager: wifi_sta_config: MBO enabled 1
I (241311) wifi_manager: wifi_sta_config: FT enabled 1
I (241311) wifi_manager: wifi_sta_config: OWE enabled 1
I (241321) wifi_manager: wifi_sta_config: PMF capable enabled 1
I (241331) wifi_manager: wifi_sta_config: PMF required enabled 0
I (241341) wifi_manager: wifi_sta_config: transition_disable enabled 0
I (244171) wifi_manager: WIFI_EVENT_STA_DISCONNECTED
I (244171) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with Reason code: 211
I (244181) wifi_manager: MESSAGE: EVENT_STA_DISCONNECTED with rssi: -128
I (244181) wifi_manager: Set STA IP String to: 0.0.0.0

### More Information.

I have tried setting OWE to 1 in the STA config, and also setting transition_disable to 1 in the STA config.
Ultimately, the STA will only connect to the AP if the security of the AP is set to WPA3

Hi @evoon
Could you please enable WIFI debug print and share the log?
CONFIG_WPA_DEBUG_PRINT=y
CONFIG_MBEDTLS_DEBUG=y
CONFIG_MBEDTLS_DEBUG_LEVEL_VERBOSE=y
CONFIG_MBEDTLS_DEBUG_LEVEL=4
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
CONFIG_LOG_DEFAULT_LEVEL=4

authors: evoon vik-gokhale


text:
Loading application from openOCD

Hi,
Is it possible to upload the firmware through GDB ? When I try it, I got this error from openOCD
Error: esp32.cpu0: xtensa_write_memory (line 1024): DSR (8020CC13) indicates DIR instruction generated an exception! Warn : esp32.cpu0: Failed writing 4096 bytes at address 0x3F400010
Regards
Jonathan

Not yet; OpenOCD is not aware that the application lives in flash and will try to write to the flash as if it's RAM. Remedying this is on our ToDo-list, but we haven't gotten around to this.

Hi,
Thanx for the Info.
Jonathan

Hi,
I got this problem as well. The extensa-gdb works OK when start from the command line. But it fails with this message when I try start it from eclipse (Neon.3) - it try write to the drom0_0_seg, and, obviously fails - it read-only memory.  So, can somebody point me to the eclipse configuration for avoid this write?
Thanks.

Never mind, I find a fix for that ..Thanks.

authors: Spritetm dantonets dumarjo


text:
using ccache with esp-idf

Hi all,
is possible to use ccache to speed up the build?
Thanks
Nicola Lunghi

totally you can ;) many of us already use it :)

ok i managed to create a directory called bin-ccache in the xtensa installation directory and link all the executables in bin to ccache
then I've added the xtensa bin-ccache folder to path before the bin folder itself.
and ccache works perfectly

Hi @nicola-lunghi ,
Just FYI, if you're still using the cmake branch then you should get ccache enabled automatically if it's on your PATH:
https://github.com/espressif/esp-idf/blob/feature/cmake/tools/cmake/idf_functions.cmake#L101
(But setting up links in the way you mention will also work - I have this set on my local system as well.)
Angus

authors: me-no-dev nicola-lunghi projectgus


text:
SPI slave broken by commit 58955a7 (IDFGH-702)

Environment

Development Kit:      [ESP32-DevKitC|]

Using VSPI with IOMUX pins as described in https://github.com/espressif/esp-idf/blob/master/docs/en/api-reference/peripherals/spi_slave.rst

No dma

Init code:

host_(VSPI_HOST);
//...
spi_bus_config_t buscfg = {
  .mosi_io_num = 23,
  .miso_io_num = 19,
  .sclk_io_num = 18,
  .quadwp_io_num = -1,
  .quadhd_io_num = -1
};
spi_slave_interface_config_t slvcfg = {
  .spics_io_num = 5,
  .flags = 0,
  .queue_size = 1,
  .mode = 0
};
 //...
RETURN_NOT_OK(spi_slave_initialize(host_, &buscfg, &slvcfg, 0));

Problem Description
Using ESP32 as an SPI slave, running against a non-esp MCU master. As found by git bisect, before commit 58955a7 data was transmitted reliably, after that commit started getting errors on the master (see below for the types of errors). The anatomy of the error (1 or 2 bit shifts) seems to hint at timing problems.
Reverting the changes to spi_slave.c on top of master as of a few days ago (ebdcbe8c) makes the problem go away.
Expected Behavior
Data transmitted by the slave arrives at the master as sent.
Actual Behavior
Data is usually bit shifted by 1 bit (e.g. an xFE byte sent by the ESP32 slave becomes xFF at the master), sometimes (rarely) arrives correctly, sometimes it's bit shifted by 2 bits.

Sorry could you please double check the commit id — 58955a you've mentioned doesn't seem to be a commit in IDF repo?

Hi @igrr
I was missing one more letter to be uniquely identifiable :)
I changed the title/links to the right one, but here's a more direct one: https://github.com/espressif/esp-idf/commit/58955a79a27d3c7331eaec6e464878df42615a36
I'm talking specifically about the changes to spi_slave.c. I haven't tested or reverted the other changes.

@dralves Can you provide the MCU you are using, as well as the spi clock speed?
The problem is that, ESP32 slave has a delay (quite large!!!!!) on the MISO line after the SPI clock launch edge. When the GPIO matrix is used, it's 62.5ns, and if IOMUX isused, it's 37.5ns. Which means, it cannot meet the timing requirements when the SPI clock is above 8MHz (GPIO matrix), or 13MHz (IOMUX) (See the programming guide).
In the code before, we mistakenly shifted the timing of both launch and latch edge by half a spi clock ahead. This solves some DMA issues, and made the timing performance better in some high frequency cases.
But basicly it's incorrect, and complained by someone else in #1346 and #2393 . So we fixed it.
If you prefer the timing configurations, you can:

If you are using mode 1/3, set the mode of slave to mode 0/2, it's half a clock ahead then mode 1/3. But the DMA should be disabled.
If you are using mode 0/2, turn on the DMA. The workaround in 58955a7 will help you shift the edges half a clock ahead.

Hi @ginkgm
The MCU/SPI master is a PIC32, mode 0, the master sets the speed at 10Mhz.
I read the docs you wrote :), so even though at first I was using the GPIO matrix I changed to IOMUX. Then I started reducing the speed I went all the way down to 5MHz and stlll the comms were unreliable. That's when I finally tried looking into reverting the changes. SPI had been super-reliable before.

Oh, btw, not sure if relevant this exact same code & mode & frequency on the master works flawlessly against an ESP8266.

Another note I did see the comma becoming slightly better as I reduced speed. But at 5 MHz they were still very unreliable and that’s the lowest I could go in terms of speed

Yet another note:
The table in #1346 states:

Registers
mode0
mode1
mode2
mode3

SPI_CK_IDLE_EDGE
0
0
1
1

SPI_CK_I_EDGE
0
1
1
0

SPI_MISO_DELAY_MODE
0
0
0
0

SPI_MISO_DELAY_NUM
0
0
0
0

SPI_MOSI_DELAY_MODE
2
1
1
2

SPI_MOSI_DELAY_NUM
0
0
0
0

but the currently checked in code is:
    if (mode == 0) {
        //The timing needs to be fixed to meet the requirements of DMA
        spihost[host]->hw->pin.ck_idle_edge = 1;
        spihost[host]->hw->user.ck_i_edge = 0;
        spihost[host]->hw->ctrl2.miso_delay_mode = 0;
        spihost[host]->hw->ctrl2.miso_delay_num = 0;
        spihost[host]->hw->ctrl2.mosi_delay_mode = 2;
        spihost[host]->hw->ctrl2.mosi_delay_num = 2;

If I understand things correctly, this doesn't match the table. Not sure whether the table is accurate, but according to the table this should be:
    if (mode == 0) {
        //The timing needs to be fixed to meet the requirements of DMA
        spihost[host]->hw->pin.ck_idle_edge = 0;
        spihost[host]->hw->user.ck_i_edge = 0;
        spihost[host]->hw->ctrl2.miso_delay_mode = 0;
        spihost[host]->hw->ctrl2.miso_delay_num = 0;
        spihost[host]->hw->ctrl2.mosi_delay_mode = 2;
        spihost[host]->hw->ctrl2.mosi_delay_num = 0;

@dralves
The TRM is already updated: https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf

@ginkgm might it be hardware rev dependent? I have quite a few esp32 boards, but mainly use adafruits huzzah32 with the ESP-WROOM-32 (not sure which rev, but think it's pretty old). I say this because the current implementation is supposed to work well at low frequencies, (<7MHz even if I got the GPIO/IOMUX thing wrong) and that's not what I observed.

@ginkgm in any case if this is only a problem for me, I already have my own fork of esp-idf (where I include arduino as a component) so I can just maintain my fork with this additional change. Feel free to close this if you think it's not relevant/not a problem for other folks.
I just raised the issue in case others run into the same problem where their boards are working fine and suddenly stop working after an update.

Some suggestions on using PIC32:
I assume you are using the model as this spec

Mode 0 correspond to CKP=0, CKE=1.

SP40=15ns, 1/(15ns+62.5ns)/2=6.5MHz. I think the slack is small, and maybe you are still via the GPIO matrix? Maybe you can enable the debug message in the spi_common.c to see whether you're using the IOMUX or not.
Finally, you can set SMP=1 to delay the master sample time, or use the trick I mentioned above to advance the slave launch time.

thanks @dralves

@ginkgm

@dralves thanks alot!

authors: dralves ginkgm igrr